From nobody Wed Oct 22 13:00:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519343368802965.9239956899563; Thu, 22 Feb 2018 15:49:28 -0800 (PST) Received: from localhost ([::1]:41694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ep0cB-0001u0-G9 for importer@patchew.org; Thu, 22 Feb 2018 18:49:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ep0aY-0000uM-4O for qemu-devel@nongnu.org; Thu, 22 Feb 2018 18:48:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ep0Zu-0003t8-Hx for qemu-devel@nongnu.org; Thu, 22 Feb 2018 18:47:46 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36538 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ep0Zu-0003q2-0N for qemu-devel@nongnu.org; Thu, 22 Feb 2018 18:47:06 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 080CF40201A0 for ; Thu, 22 Feb 2018 23:47:05 +0000 (UTC) Received: from dreadlord-bne-redhat-com.bne.redhat.com (dhcp-40-179.bne.redhat.com [10.64.40.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4941B217B42F for ; Thu, 22 Feb 2018 23:47:04 +0000 (UTC) From: Dave Airlie To: qemu-devel@nongnu.org Date: Fri, 23 Feb 2018 09:47:02 +1000 Message-Id: <20180222234702.15705-1-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 22 Feb 2018 23:47:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 22 Feb 2018 23:47:05 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'airlied@gmail.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] virtio-gpu-3d: add support for second capability set (v3) 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Airlie Due to a kernel bug we can never increase the size of capability set 1, so introduce a new capability set in parallel, old userspace will continue to use the old set, new userspace will start using the new one when it detects a fixed kernel. v2: don't use a define from virglrenderer, just probe it. v3: fix compilation when virglrenderer disabled Signed-off-by: Dave Airlie --- hw/display/virtio-gpu-3d.c | 18 ++++++++++++++++++ hw/display/virtio-gpu.c | 7 ++++++- include/hw/virtio/virtio-gpu.h | 2 +- include/standard-headers/linux/virtio_gpu.h | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 7db84efe89..05e7106396 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -362,6 +362,11 @@ static void virgl_cmd_get_capset_info(VirtIOGPU *g, virgl_renderer_get_cap_set(resp.capset_id, &resp.capset_max_version, &resp.capset_max_size); + } else if (info.capset_index =3D=3D 1) { + resp.capset_id =3D VIRTIO_GPU_CAPSET_VIRGL2; + virgl_renderer_get_cap_set(resp.capset_id, + &resp.capset_max_version, + &resp.capset_max_size); } else { resp.capset_max_version =3D 0; resp.capset_max_size =3D 0; @@ -635,4 +640,17 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) return 0; } =20 +int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g) +{ + uint32_t capset2_max_ver, capset2_max_size; + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VIRGL2, + &capset2_max_ver, + &capset2_max_size); + + if (capset2_max_ver) + return 2; + else + return 1; +} + #endif /* CONFIG_VIRGL */ diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 6658f6c6a6..2dd3c3481a 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1215,7 +1215,12 @@ static void virtio_gpu_device_realize(DeviceState *q= dev, Error **errp) /* use larger control queue in 3d mode */ g->ctrl_vq =3D virtio_add_queue(vdev, 256, virtio_gpu_handle_ctr= l_cb); g->cursor_vq =3D virtio_add_queue(vdev, 16, virtio_gpu_handle_curs= or_cb); - g->virtio_config.num_capsets =3D 1; + +#if defined(CONFIG_VIRGL) + g->virtio_config.num_capsets =3D virtio_gpu_virgl_get_num_capsets(= g); +#else + g->virtio_config.num_capsets =3D 0; +#endif } else { g->ctrl_vq =3D virtio_add_queue(vdev, 64, virtio_gpu_handle_ctrl= _cb); g->cursor_vq =3D virtio_add_queue(vdev, 16, virtio_gpu_handle_curs= or_cb); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 83f474ffc3..22ac3c2d0e 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -171,5 +171,5 @@ void virtio_gpu_virgl_fence_poll(VirtIOGPU *g); void virtio_gpu_virgl_reset(VirtIOGPU *g); void virtio_gpu_gl_block(void *opaque, bool block); int virtio_gpu_virgl_init(VirtIOGPU *g); - +int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g); #endif diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard= -headers/linux/virtio_gpu.h index c1c8f0751d..52a830dcf8 100644 --- a/include/standard-headers/linux/virtio_gpu.h +++ b/include/standard-headers/linux/virtio_gpu.h @@ -260,6 +260,7 @@ struct virtio_gpu_cmd_submit { }; =20 #define VIRTIO_GPU_CAPSET_VIRGL 1 +#define VIRTIO_GPU_CAPSET_VIRGL2 2 =20 /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ struct virtio_gpu_get_capset_info { --=20 2.14.3