qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Antonio Caggiano" <quic_acaggian@quicinc.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	"Robert Beckett" <bob.beckett@collabora.com>,
	"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Gurchetan Singh" <gurchetansingh@chromium.org>,
	"Albert Esteve" <aesteve@redhat.com>,
	"ernunes@redhat.com" <ernunes@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Alyssa Ross" <hi@alyssa.is>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Koenig, Christian" <Christian.Koenig@amd.com>,
	"Ragiadakou, Xenia" <Xenia.Ragiadakou@amd.com>,
	"Pelloux-Prayer,
	Pierre-Eric" <Pierre-eric.Pelloux-prayer@amd.com>,
	"Huang, Honglei1" <Honglei1.Huang@amd.com>,
	"Zhang, Julia" <Julia.Zhang@amd.com>,
	"Chen, Jiqian" <Jiqian.Chen@amd.com>,
	"Antonio Caggiano" <antonio.caggiano@collabora.com>
Subject: Re: [QEMU PATCH v5 10/13] virtio-gpu: Resource UUID
Date: Wed, 20 Sep 2023 15:55:01 +0800	[thread overview]
Message-ID: <ZQqlVb2PkRMjMaKF@amd.com> (raw)
In-Reply-To: <a3a46b78-9feb-47f3-bd3e-519ebe899737@daynix.com>

On Sat, Sep 16, 2023 at 12:48:14AM +0800, Akihiko Odaki wrote:
> On 2023/09/15 20:11, Huang Rui wrote:
> > From: Antonio Caggiano <antonio.caggiano@collabora.com>
> > 
> > Enable resource UUID feature and implement command resource assign UUID.
> > This is done by introducing a hash table to map resource IDs to their
> > UUIDs.
> > 
> > Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
> > Signed-off-by: Huang Rui <ray.huang@amd.com>
> > ---
> > 
> > V4 -> V5:
> >      - Add virtio migration handling for uuid (Akihiko)
> >      - Adjust sequence to allocate gpu resource before virglrender resource
> >        creation (Akihiko)
> >      - Clean up (Akihiko)
> > 
> >   hw/display/trace-events        |  1 +
> >   hw/display/virtio-gpu-base.c   |  2 ++
> >   hw/display/virtio-gpu-virgl.c  | 21 ++++++++++++
> >   hw/display/virtio-gpu.c        | 58 ++++++++++++++++++++++++++++++++++
> >   include/hw/virtio/virtio-gpu.h |  6 ++++
> >   5 files changed, 88 insertions(+)
> > 
> > diff --git a/hw/display/trace-events b/hw/display/trace-events
> > index 2336a0ca15..54d6894c59 100644
> > --- a/hw/display/trace-events
> > +++ b/hw/display/trace-events
> > @@ -41,6 +41,7 @@ virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t size) "res 0x%x, size %" P
> >   virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x"
> >   virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x"
> >   virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x"
> > +virtio_gpu_cmd_res_assign_uuid(uint32_t res) "res 0x%x"
> >   virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
> >   virtio_gpu_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x"
> >   virtio_gpu_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x"
> > diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
> > index 4f2b0ba1f3..f44388715c 100644
> > --- a/hw/display/virtio-gpu-base.c
> > +++ b/hw/display/virtio-gpu-base.c
> > @@ -236,6 +236,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features,
> >           features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT);
> >       }
> >   
> > +    features |= (1 << VIRTIO_GPU_F_RESOURCE_UUID);
> > +
> >       return features;
> >   }
> >   
> > diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
> > index 563a6f2f58..8a017dbeb4 100644
> > --- a/hw/display/virtio-gpu-virgl.c
> > +++ b/hw/display/virtio-gpu-virgl.c
> > @@ -36,11 +36,20 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
> >   {
> >       struct virtio_gpu_resource_create_2d c2d;
> >       struct virgl_renderer_resource_create_args args;
> > +    struct virtio_gpu_simple_resource *res;
> >   
> >       VIRTIO_GPU_FILL_CMD(c2d);
> >       trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format,
> >                                          c2d.width, c2d.height);
> >   
> > +    res = g_new0(struct virtio_gpu_simple_resource, 1);
> > +    if (!res) {
> > +        cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
> > +        return;
> > +    }
> > +    res->resource_id = c2d.resource_id;
> > +    QTAILQ_INSERT_HEAD(&g->reslist, res, next);
> > +
> 
> The struct virtio_gpu_simple_resource for a resource created with 
> virgl_cmd_create_resource_2d() and virgl_resource_attach_backing() will 
> not have iov and iov_cnt set, which is inconsistent with 
> virgl_cmd_resource_create_blob().
> 

OK, so we should find out the resource in virgl_resource_attach_backing(),
and set the related iov and iov_cnt for this resource to align with blob
memory.

> >       args.handle = c2d.resource_id;
> >       args.target = 2;
> >       args.format = c2d.format;
> > @@ -60,11 +69,20 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
> >   {
> >       struct virtio_gpu_resource_create_3d c3d;
> >       struct virgl_renderer_resource_create_args args;
> > +    struct virtio_gpu_simple_resource *res;
> >   
> >       VIRTIO_GPU_FILL_CMD(c3d);
> >       trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format,
> >                                          c3d.width, c3d.height, c3d.depth);
> >   
> > +    res = g_new0(struct virtio_gpu_simple_resource, 1);
> > +    if (!res) {
> > +        cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
> > +        return;
> > +    }
> > +    res->resource_id = c3d.resource_id;
> > +    QTAILQ_INSERT_HEAD(&g->reslist, res, next);
> > +
> >       args.handle = c3d.resource_id;
> >       args.target = c3d.target;
> >       args.format = c3d.format;
> > @@ -682,6 +700,9 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
> >           /* TODO add security */
> >           virgl_cmd_ctx_detach_resource(g, cmd);
> >           break;
> > +    case VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID:
> > +        virtio_gpu_resource_assign_uuid(g, cmd);
> > +        break;
> >       case VIRTIO_GPU_CMD_GET_CAPSET_INFO:
> >           virgl_cmd_get_capset_info(g, cmd);
> >           break;
> > diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> > index cc4c1f81bb..44414c1c5e 100644
> > --- a/hw/display/virtio-gpu.c
> > +++ b/hw/display/virtio-gpu.c
> > @@ -966,6 +966,38 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g,
> >       virtio_gpu_cleanup_mapping(g, res);
> >   }
> >   
> > +void virtio_gpu_resource_assign_uuid(VirtIOGPU *g,
> > +                                     struct virtio_gpu_ctrl_command *cmd)
> > +{
> > +    struct virtio_gpu_simple_resource *res;
> > +    struct virtio_gpu_resource_assign_uuid assign;
> > +    struct virtio_gpu_resp_resource_uuid resp;
> > +    QemuUUID *uuid;
> > +
> > +    VIRTIO_GPU_FILL_CMD(assign);
> > +    virtio_gpu_bswap_32(&assign, sizeof(assign));
> > +    trace_virtio_gpu_cmd_res_assign_uuid(assign.resource_id);
> > +
> > +    res = virtio_gpu_find_check_resource(g, assign.resource_id, false, __func__, &cmd->error);
> > +    if (!res) {
> > +        return;
> > +    }
> > +
> > +    memset(&resp, 0, sizeof(resp));
> > +    resp.hdr.type = VIRTIO_GPU_RESP_OK_RESOURCE_UUID;
> > +
> > +    uuid = g_hash_table_lookup(g->resource_uuids, GUINT_TO_POINTER(assign.resource_id));
> > +    if (!uuid) {
> > +        uuid = g_new(QemuUUID, 1);
> > +        qemu_uuid_generate(uuid);
> > +        g_hash_table_insert(g->resource_uuids, GUINT_TO_POINTER(assign.resource_id), uuid);
> > +        res->has_uuid = true;
> > +    }
> 
> What about embedding uuid into struct virtio_gpu_simple_resource? You 
> will not need to maintain another table in this way.

Yes, agree. Will update it in V6.

Thanks,
Ray


  reply	other threads:[~2023-09-20  7:56 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 11:11 [QEMU PATCH v5 00/13] Support blob memory and venus on qemu Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 01/13] virtio: Add shared memory capability Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 02/13] virtio-gpu: CONTEXT_INIT feature Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 03/13] virtio-gpu: hostmem Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 04/13] virtio-gpu: blob prep Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 05/13] virtio-gpu: Configure context init for virglrenderer Huang Rui
2023-09-19  8:17   ` Marc-André Lureau
2023-09-20  8:04     ` Huang Rui
2023-10-10 11:41   ` Dmitry Osipenko
2023-10-10 11:51     ` Daniel P. Berrangé
2023-10-17 17:46       ` Dmitry Osipenko
2023-09-15 11:11 ` [QEMU PATCH v5 06/13] virtio-gpu: Support context init feature with virglrenderer Huang Rui
2023-09-15 15:20   ` Akihiko Odaki
2023-09-16 10:32     ` Huang Rui
2023-09-16 10:42       ` Akihiko Odaki
2023-09-17  5:45         ` Huang Rui
2023-09-17  5:49           ` Akihiko Odaki
2023-09-18  5:43             ` Huang Rui
2023-09-18  6:07               ` Akihiko Odaki
2023-09-18  6:20                 ` Huang Rui
2023-09-18  6:22                   ` Akihiko Odaki
2023-09-15 16:58   ` Akihiko Odaki
2023-09-16 10:36     ` Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 07/13] softmmu/memory: enable automatic deallocation of memory regions Huang Rui
2023-09-15 15:11   ` Akihiko Odaki
2023-09-19 10:28     ` Xenia Ragiadakou
2023-09-19 10:44       ` Akihiko Odaki
2023-09-19 14:21         ` Xenia Ragiadakou
2023-09-19 22:18           ` Akihiko Odaki
2023-09-20  8:57             ` Xenia Ragiadakou
2023-09-20 10:18               ` Akihiko Odaki
2023-09-15 11:11 ` [QEMU PATCH v5 08/13] virtio-gpu: Don't require udmabuf when blobs and virgl are enabled Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 09/13] virtio-gpu: Handle resource blob commands Huang Rui
2023-09-15 16:04   ` Akihiko Odaki
2023-09-15 16:37     ` Akihiko Odaki
2023-09-20  5:50       ` Huang Rui via
2023-09-20  5:54         ` Akihiko Odaki
2023-09-20  6:11           ` Huang Rui via
2023-09-18  8:36     ` Huang Rui
2023-09-18  8:39       ` Akihiko Odaki
2023-09-19  8:44   ` Marc-André Lureau
2023-09-20  8:41     ` Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 10/13] virtio-gpu: Resource UUID Huang Rui
2023-09-15 16:48   ` Akihiko Odaki
2023-09-20  7:55     ` Huang Rui [this message]
2023-09-19  9:00   ` Marc-André Lureau
2023-09-20 10:00     ` Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 11/13] virtio-gpu: Support Venus capset Huang Rui
2023-09-19  9:02   ` Marc-André Lureau
2023-09-20 10:06     ` Huang Rui
2023-09-15 11:11 ` [QEMU PATCH v5 12/13] virtio-gpu: Initialize Venus Huang Rui
2023-10-10 12:10   ` Dmitry Osipenko
2023-09-15 11:11 ` [QEMU PATCH v5 13/13] virtio-gpu: Enable virglrenderer render server flag for venus Huang Rui
2023-10-10 11:48   ` Dmitry Osipenko
2023-10-10 11:57 ` [QEMU PATCH v5 00/13] Support blob memory and venus on qemu Dmitry Osipenko

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=ZQqlVb2PkRMjMaKF@amd.com \
    --to=ray.huang@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Honglei1.Huang@amd.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Julia.Zhang@amd.com \
    --cc=Pierre-eric.Pelloux-prayer@amd.com \
    --cc=Xenia.Ragiadakou@amd.com \
    --cc=aesteve@redhat.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=alex.bennee@linaro.org \
    --cc=anthony.perard@citrix.com \
    --cc=antonio.caggiano@collabora.com \
    --cc=bob.beckett@collabora.com \
    --cc=dgilbert@redhat.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=ernunes@redhat.com \
    --cc=gurchetansingh@chromium.org \
    --cc=hi@alyssa.is \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quic_acaggian@quicinc.com \
    --cc=roger.pau@citrix.com \
    --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).