qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Julia Zhang <julia.zhang@amd.com>
To: Gerd Hoffmann <kraxel@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	 Stefano Stabellini <sstabellini@kernel.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Antonio Caggiano <antonio.caggiano@collabora.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	Robert Beckett <bob.beckett@collabora.com>,
	<qemu-devel@nongnu.org>
Cc: xen-devel@lists.xenproject.org,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Xenia Ragiadakou" <burzalodowa@gmail.com>,
	"Honglei Huang" <honglei1.huang@amd.com>,
	"Julia Zhang" <julia.zhang@amd.com>,
	"Chen Jiqian" <Jiqian.Chen@amd.com>
Subject: [PATCH 2/2] virgl: Modify resource_query_layout
Date: Fri, 10 Nov 2023 15:40:27 +0800	[thread overview]
Message-ID: <20231110074027.24862-3-julia.zhang@amd.com> (raw)
In-Reply-To: <20231110074027.24862-1-julia.zhang@amd.com>

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@amd.com>
---
 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



      parent reply	other threads:[~2023-11-10 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10  7:40 [PATCH 0/2] Implementation of resource_query_layout Julia Zhang
2023-11-10  7:40 ` [PATCH 1/2] virgl: Implement resource_query_layout Julia Zhang
2023-11-10  7:40 ` Julia Zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231110074027.24862-3-julia.zhang@amd.com \
    --to=julia.zhang@amd.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=anthony.perard@citrix.com \
    --cc=antonio.caggiano@collabora.com \
    --cc=bob.beckett@collabora.com \
    --cc=burzalodowa@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dgilbert@redhat.com \
    --cc=honglei1.huang@amd.com \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).