From patchwork Thu May 23 11:04:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Wollny X-Patchwork-Id: 1104124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 458r0F1SbGz9s1c for ; Thu, 23 May 2019 23:27:39 +1000 (AEST) Received: from localhost ([127.0.0.1]:36227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTnkv-0005YT-NS for incoming@patchwork.ozlabs.org; Thu, 23 May 2019 09:27:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTlWd-0004e9-4D for qemu-devel@nongnu.org; Thu, 23 May 2019 07:04:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTlWc-0002U4-0T for qemu-devel@nongnu.org; Thu, 23 May 2019 07:04:43 -0400 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]:59570) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTlWb-0002Py-RX for qemu-devel@nongnu.org; Thu, 23 May 2019 07:04:41 -0400 Received: from Isengard.homenet.telecomitalia.it (unknown [IPv6:2a02:810a:940:4421:55f7:11f5:99cb:72c6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: gerddie) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id D6A672808DF; Thu, 23 May 2019 12:04:37 +0100 (BST) From: Gert Wollny To: qemu-devel@nongnu.org Date: Thu, 23 May 2019 13:04:34 +0200 Message-Id: <20190523110434.23830-1-gert.wollny@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1098:0:82:1000:25:2eeb:e3e3 X-Mailman-Approved-At: Thu, 23 May 2019 09:18:29 -0400 Subject: [Qemu-devel] [PATCH] virtio_gpu_3d: make it possible to configure the fence poll time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gert Wollny Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The default fence poll time of 10ms (100 Hz) is sufficent for normal work loads, but if one wants to play games within the virtual machine this value might be too high, so make it possible to configure this value by using the environment variable QEMU_VIRGL_POLL_FREQ where the poll is given in Hz. To acommodate higher poll frequencies also change the timer to use micro seconds as base instead of milliseconds. Signed-off-by: Gert Wollny --- hw/display/virtio-gpu-3d.c | 18 ++++++++++++++++-- include/hw/virtio/virtio-gpu.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 5ee3566ae0..120e593e76 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -17,6 +17,7 @@ #include "trace.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" +#include "qemu/cutils.h" #ifdef CONFIG_VIRGL @@ -580,7 +581,8 @@ static void virtio_gpu_fence_poll(void *opaque) virgl_renderer_poll(); virtio_gpu_process_cmdq(g); if (!QTAILQ_EMPTY(&g->cmdq) || !QTAILQ_EMPTY(&g->fenceq)) { - timer_mod(g->fence_poll, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1); + timer_mod(g->fence_poll, qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + + g->fence_poll_timeout); } } @@ -605,13 +607,25 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g) int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; + const char *val; ret = virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs); if (ret != 0) { return ret; } - g->fence_poll = timer_new_ms(QEMU_CLOCK_VIRTUAL, + g->fence_poll_timeout = 10000; /* default 10 ms */ + val = getenv("QEMU_VIRGL_POLL_FREQ"); + if (val) { + unsigned long long poll_freq; + if (parse_uint_full(val, &poll_freq, 10) || poll_freq > UINT32_MAX) { + fprintf(stderr, "VIRGL_POLL_FREQ: Invalid integer `%s'\n", val); + exit(1); + } + g->fence_poll_timeout = 1000000 / (uint32_t)poll_freq; + } + + g->fence_poll = timer_new_us(QEMU_CLOCK_VIRTUAL, virtio_gpu_fence_poll, g); if (virtio_gpu_stats_enabled(g->conf)) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 60425c5d58..a9e03b25aa 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -116,6 +116,7 @@ typedef struct VirtIOGPU { bool renderer_reset; QEMUTimer *fence_poll; QEMUTimer *print_stats; + uint32_t fence_poll_timeout; uint32_t inflight; struct {