[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] virgl: Modify resource_query_layout


  • To: Gerd Hoffmann <kraxel@xxxxxxxxxx>, "Michael S . Tsirkin" <mst@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Antonio Caggiano <antonio.caggiano@xxxxxxxxxxxxx>, "Dr . David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Robert Beckett <bob.beckett@xxxxxxxxxxxxx>, <qemu-devel@xxxxxxxxxx>
  • From: Julia Zhang <julia.zhang@xxxxxxx>
  • Date: Fri, 10 Nov 2023 15:40:27 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9aX1RsF3gCTbk9wZR0KoZwRve7pKpevRbJ1zXxYsX70=; b=cGczpLNV1Qcqa90qgqg977zcfxwfZGUHblRpkJzDDUYjVG94D/vgP8RkmopzCCkrSjo41wjsgdIdqS/de3BnKskJU4gXscrd1HZPtyVQd2wPrnXx3zUh/P3EdEB8zo+kd2s+BU0sW9PEkbTH+wZF9ZTsagFos7lLwqXr0KLxxCE6OP8UdU7aUTyKNfWlKMJ8TLTmNfYBZkU5Hfhy+M7jRcwryuS00p/RfG52qohWxf7PrYmCiamf8E1iBlfXkSy8jGjFd2ED/V0goRX0lh62DfbQiG+xl5hoeacdMokn5vT4qzc2YOjFxTr+9+XsqsyWZOe2wCGkoN06KImCJLZX8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+yTwAW6x8fv/FurfWs5mTjkrLYLn+eV28rQNK8TWXvLtYCvNsjDmV9DNpVipFVOomnTjQ8TkWPvskgM3FJSYL3PPb2NSYNoyYcktpEYa5jG1Qgb1dxOy8is2+fTDqggctE5VU14YBquLRMUY7woiKBGnPE0F276u3YEuQoaEIWX1sXtU5XKLrp6bYof2JOlRh42CosggOKD1iBKbsT0ardjlz5db/uAteP/NXmUH85V/KT2MDqY3iXZw+aP8ms5Gpnmk/BgGfZSsgev9UGSxAJN2Hiy6qmB9tAJ2iQYvNNLMml5vt7aVmnqb+hdUNEihW3WciX+8ZPJ55qET0w2EA==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, "Honglei Huang" <honglei1.huang@xxxxxxx>, Julia Zhang <julia.zhang@xxxxxxx>, "Chen Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Fri, 10 Nov 2023 07:42:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Modify resource_query_layout to handle the use case that need to query
correct stride for guest linear resource before it is created.

Signed-off-by: Julia Zhang <julia.zhang@xxxxxxx>
---
 hw/display/virtio-gpu-virgl.c               | 20 +++-----------------
 include/standard-headers/linux/virtio_gpu.h |  8 ++++----
 2 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 9c5a07cef1..ae146a68cb 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -728,22 +728,9 @@ static void virgl_cmd_resource_query_layout(VirtIOGPU *g,
     VIRTIO_GPU_FILL_CMD(qlayout);
     virtio_gpu_resource_query_layout_bswap(&qlayout);
 
-    if (qlayout.resource_id == 0) {
-        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",
-                      __func__);
-        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
-        return;
-    }
-
-    res = virtio_gpu_find_resource(g, qlayout.resource_id);
-    if (!res) {
-        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n",
-                      __func__, qlayout.resource_id);
-        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
-        return;
-    }
-
-    ret = virgl_renderer_resource_query_layout(qlayout.resource_id, &rlayout);
+    ret = virgl_renderer_resource_query_layout(qlayout.resource_id, &rlayout,
+                                              qlayout.width, qlayout.height,
+                                              qlayout.format, qlayout.bind);
     if (ret != 0) {
         qemu_log_mask(LOG_GUEST_ERROR, "%s: resource %d is not 
externally-allocated\n",
                       __func__, qlayout.resource_id);
@@ -758,7 +745,6 @@ static void virgl_cmd_resource_query_layout(VirtIOGPU *g,
     for (i = 0; i < resp.num_planes; i++) {
         resp.planes[i].offset = rlayout.planes[i].offset;
         resp.planes[i].stride = rlayout.planes[i].stride;
-       resp.planes[i].size = rlayout.planes[i].size;
     }
     virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp));
 }
diff --git a/include/standard-headers/linux/virtio_gpu.h 
b/include/standard-headers/linux/virtio_gpu.h
index 734fdb6beb..6fb0f711c8 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -506,7 +506,10 @@ struct virtio_gpu_status_freezing {
 struct virtio_gpu_resource_query_layout {
        struct virtio_gpu_ctrl_hdr hdr;
        uint32_t resource_id;
-       uint32_t padding;
+       uint32_t width;
+       uint32_t height;
+       uint32_t format;
+       uint32_t bind;
 };
 
 /* VIRTIO_GPU_RESP_OK_RESOURCE_LAYOUT */
@@ -515,12 +518,9 @@ struct virtio_gpu_resp_resource_layout {
        struct virtio_gpu_ctrl_hdr hdr;
        uint64_t modifier;
        uint32_t num_planes;
-       uint32_t padding;
        struct virtio_gpu_resource_plane {
                uint64_t offset;
-               uint64_t size;
                uint32_t stride;
-               uint32_t padding;
        } planes[VIRTIO_GPU_RES_MAX_PLANES];
 };
 
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.