From patchwork Fri Jan 22 12:23:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8089711 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 011A5BEEE5 for ; Fri, 22 Jan 2016 12:29:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FB54203AA for ; Fri, 22 Jan 2016 12:29:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA6E620272 for ; Fri, 22 Jan 2016 12:29:42 +0000 (UTC) Received: from localhost ([::1]:53046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMaqU-0001Xl-0a for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Jan 2016 07:29:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMakx-00018l-9M for qemu-devel@nongnu.org; Fri, 22 Jan 2016 07:24:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMakv-0001gS-AB for qemu-devel@nongnu.org; Fri, 22 Jan 2016 07:23:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMakv-0001g9-46 for qemu-devel@nongnu.org; Fri, 22 Jan 2016 07:23:57 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CC702C6587; Fri, 22 Jan 2016 12:23:56 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-19.ams2.redhat.com [10.36.116.19]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0MCNtMA022173; Fri, 22 Jan 2016 07:23:56 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A6BF280AF3; Fri, 22 Jan 2016 13:23:50 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 22 Jan 2016 13:23:46 +0100 Message-Id: <1453465427-6961-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1453465427-6961-1-git-send-email-kraxel@redhat.com> References: <1453465427-6961-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v2 5/6] virtio-gpu: add support to enable/disable command processing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP So we can stop rendering for a while in case we have to. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau --- hw/display/virtio-gpu-3d.c | 3 ++- hw/display/virtio-gpu.c | 5 ++++- include/hw/virtio/virtio-gpu.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index d2af327..d6487f7 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -553,7 +553,8 @@ static void virtio_gpu_fence_poll(void *opaque) VirtIOGPU *g = opaque; virgl_renderer_poll(); - if (g->inflight) { + 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) + 10); } } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index d4ee34d..e341d6e 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -754,7 +754,7 @@ static void virtio_gpu_handle_cursor_cb(VirtIODevice *vdev, VirtQueue *vq) qemu_bh_schedule(g->cursor_bh); } -static void virtio_gpu_process_cmdq(VirtIOGPU *g) +void virtio_gpu_process_cmdq(VirtIOGPU *g) { struct virtio_gpu_ctrl_command *cmd; @@ -764,6 +764,9 @@ static void virtio_gpu_process_cmdq(VirtIOGPU *g) /* process command */ VIRGL(g, virtio_gpu_virgl_process_cmd, virtio_gpu_simple_process_cmd, g, cmd); + if (cmd->waiting) { + break; + } QTAILQ_REMOVE(&g->cmdq, cmd, next); if (virtio_gpu_stats_enabled(g->conf)) { g->stats.requests++; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index f7e7a52..f6cae0b 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -76,6 +76,7 @@ struct virtio_gpu_ctrl_command { VirtQueue *vq; struct virtio_gpu_ctrl_hdr cmd_hdr; uint32_t error; + bool waiting; bool finished; QTAILQ_ENTRY(virtio_gpu_ctrl_command) next; }; @@ -152,6 +153,7 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab, struct virtio_gpu_ctrl_command *cmd, struct iovec **iov); void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count); +void virtio_gpu_process_cmdq(VirtIOGPU *g); /* virtio-gpu-3d.c */ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,