From patchwork Sun Sep 4 22:20:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 665581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sS77F3lPZz9sR9 for ; Mon, 5 Sep 2016 08:38:33 +1000 (AEST) Received: from localhost ([::1]:51295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgg3a-0008FA-Gh for incoming@patchwork.ozlabs.org; Sun, 04 Sep 2016 18:38:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgfnQ-0003Au-53 for qemu-devel@nongnu.org; Sun, 04 Sep 2016 18:21:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgfnO-0006TS-68 for qemu-devel@nongnu.org; Sun, 04 Sep 2016 18:21:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgfnO-0006TO-0V for qemu-devel@nongnu.org; Sun, 04 Sep 2016 18:21:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7C8C3B3C2 for ; Sun, 4 Sep 2016 22:21:45 +0000 (UTC) Received: from localhost (ovpn-116-72.phx2.redhat.com [10.3.116.72]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u84MLhT9023359; Sun, 4 Sep 2016 18:21:44 -0400 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 5 Sep 2016 02:20:37 +0400 Message-Id: <20160904222039.11460-17-marcandre.lureau@redhat.com> In-Reply-To: <20160904222039.11460-1-marcandre.lureau@redhat.com> References: <20160904222039.11460-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 04 Sep 2016 22:21:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 16/18] virtio-gpu: use virgl thread sync with the data-plane 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: airlied@redhat.com, kraxel@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's not use a timer but rather an additional thread to wait for sync. Signed-off-by: Marc-André Lureau --- hw/display/virtio-gpu-3d.c | 22 +++++++++++++++++++--- hw/display/virtio-gpu.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 728c940..42e62a8 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -773,17 +773,33 @@ void virtio_gpu_virgl_dp_destroy(VirtIOGPU *g) g_free(dp); } +static void render_poll_handler(void *opaque) +{ + virgl_renderer_poll(); +} + int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; + int flags = 0; + + if (VIRTIO_GPU_DATA_PLANE_OK(g->dp)) { + flags |= VIRGL_RENDERER_THREAD_SYNC; + } - ret = virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs); + ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs); if (ret != 0) { return ret; } - g->fence_poll = timer_new_ms(QEMU_CLOCK_VIRTUAL, - virtio_gpu_fence_poll, g); + if (VIRTIO_GPU_DATA_PLANE_OK(g->dp)) { + aio_set_fd_handler(iothread_get_aio_context(g->iothread), + virgl_renderer_get_poll_fd(), + false, render_poll_handler, NULL, g); + } else { + g->fence_poll = timer_new_ms(QEMU_CLOCK_VIRTUAL, + virtio_gpu_fence_poll, g); + } if (virtio_gpu_stats_enabled(g->conf)) { g->print_stats = timer_new_ms(QEMU_CLOCK_VIRTUAL, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 34d4a92..45fc018 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -897,7 +897,7 @@ static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) virtio_gpu_process_cmdq(g); #ifdef CONFIG_VIRGL - if (g->use_virgl_renderer) { + if (g->use_virgl_renderer && !VIRTIO_GPU_DATA_PLANE_OK(g->dp)) { virtio_gpu_virgl_fence_poll(g); } #endif