From: Huang Rui <ray.huang@amd.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: "Akihiko Odaki" <akihiko.odaki@daynix.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"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>,
"Gert Wollny" <gert.wollny@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>,
"ernunes@redhat.com" <ernunes@redhat.com>,
"Alyssa Ross" <hi@alyssa.is>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Stabellini, Stefano" <stefano.stabellini@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>
Subject: Re: [PATCH v6 05/11] virtio-gpu: Introduce virgl_gpu_resource structure
Date: Thu, 4 Jan 2024 15:27:38 +0800 [thread overview]
Message-ID: <ZZZd6rueZGmzSbPb@amd.com> (raw)
In-Reply-To: <CAJ+F1CKOsDk835H8j56mfS7e=8BusYjo3mJYwuPbdRPq1MmNzw@mail.gmail.com>
On Tue, Jan 02, 2024 at 07:52:04PM +0800, Marc-André Lureau wrote:
> Hi
>
> On Tue, Dec 19, 2023 at 11:55 AM Huang Rui <ray.huang@amd.com> wrote:
> >
> > Introduce a new virgl_gpu_resource data structure and helper functions
> > for virgl. It's used to add new member which is specific for virgl in
> > following patches of blob memory support.
> >
> > Signed-off-by: Huang Rui <ray.huang@amd.com>
> > ---
> >
> > New patch:
> > - Introduce new struct virgl_gpu_resource to store virgl specific members.
> > - Move resource initialization from path "virtio-gpu: Resource UUID" here.
> > - Remove error handling of g_new0, because glib will abort() on OOM.
> > - Set iov and iov_cnt in struct virtio_gpu_simple_resource for all types
> > of resources.
> >
> > hw/display/virtio-gpu-virgl.c | 84 ++++++++++++++++++++++++++---------
> > 1 file changed, 64 insertions(+), 20 deletions(-)
> >
> > diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
> > index 5bbc8071b2..faab374336 100644
> > --- a/hw/display/virtio-gpu-virgl.c
> > +++ b/hw/display/virtio-gpu-virgl.c
> > @@ -22,6 +22,23 @@
> >
> > #include <virglrenderer.h>
> >
> > +struct virgl_gpu_resource {
> > + struct virtio_gpu_simple_resource res;
> > +};
> > +
> > +static struct virgl_gpu_resource *
> > +virgl_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id)
> > +{
> > + struct virtio_gpu_simple_resource *res;
> > +
> > + res = virtio_gpu_find_resource(g, resource_id);
> > + if (!res) {
> > + return NULL;
> > + }
> > +
> > + return container_of(res, struct virgl_gpu_resource, res);
> > +}
> > +
> > #if VIRGL_RENDERER_CALLBACKS_VERSION >= 4
> > static void *
> > virgl_get_egl_display(G_GNUC_UNUSED void *cookie)
> > @@ -35,11 +52,19 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
> > {
> > struct virtio_gpu_resource_create_2d c2d;
> > struct virgl_renderer_resource_create_args args;
> > + struct virgl_gpu_resource *vres;
> >
> > VIRTIO_GPU_FILL_CMD(c2d);
> > trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format,
> > c2d.width, c2d.height);
> >
>
> It should check the resource doesn't already exist (similar to 2d code)
>
Will add the resource check here in V7.
Thanks,
Ray
> > + vres = g_new0(struct virgl_gpu_resource, 1);
> > + vres->res.width = c2d.width;
> > + vres->res.height = c2d.height;
> > + vres->res.format = c2d.format;
> > + vres->res.resource_id = c2d.resource_id;
> > + QTAILQ_INSERT_HEAD(&g->reslist, &vres->res, next);
> > +
> > args.handle = c2d.resource_id;
> > args.target = 2;
> > args.format = c2d.format;
> > @@ -59,11 +84,19 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
> > {
> > struct virtio_gpu_resource_create_3d c3d;
> > struct virgl_renderer_resource_create_args args;
> > + struct virgl_gpu_resource *vres;
> >
> > VIRTIO_GPU_FILL_CMD(c3d);
> > trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format,
> > c3d.width, c3d.height, c3d.depth);
> >
>
> same
>
> > + vres = g_new0(struct virgl_gpu_resource, 1);
> > + vres->res.width = c3d.width;
> > + vres->res.height = c3d.height;
> > + vres->res.format = c3d.format;
> > + vres->res.resource_id = c3d.resource_id;
> > + QTAILQ_INSERT_HEAD(&g->reslist, &vres->res, next);
> > +
> > args.handle = c3d.resource_id;
> > args.target = c3d.target;
> > args.format = c3d.format;
> > @@ -82,19 +115,23 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
> > struct virtio_gpu_ctrl_command *cmd)
> > {
> > struct virtio_gpu_resource_unref unref;
> > - struct iovec *res_iovs = NULL;
> > - int num_iovs = 0;
> > + struct virgl_gpu_resource *vres;
> >
> > VIRTIO_GPU_FILL_CMD(unref);
> > trace_virtio_gpu_cmd_res_unref(unref.resource_id);
> >
> > - virgl_renderer_resource_detach_iov(unref.resource_id,
> > - &res_iovs,
> > - &num_iovs);
> > - if (res_iovs != NULL && num_iovs != 0) {
> > - virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs);
> > + vres = virgl_gpu_find_resource(g, unref.resource_id);
> > + if (!vres) {
> > + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
> > + return;
> > }
> > +
> > + virgl_renderer_resource_detach_iov(unref.resource_id, NULL, NULL);
> > virgl_renderer_resource_unref(unref.resource_id);
> > +
> > + QTAILQ_REMOVE(&g->reslist, &vres->res, next);
> > + virtio_gpu_cleanup_mapping(g, &vres->res);
> > + g_free(vres);
> > }
> >
> > static void virgl_cmd_context_create(VirtIOGPU *g,
> > @@ -310,44 +347,51 @@ static void virgl_resource_attach_backing(VirtIOGPU *g,
> > struct virtio_gpu_ctrl_command *cmd)
> > {
> > struct virtio_gpu_resource_attach_backing att_rb;
> > - struct iovec *res_iovs;
> > - uint32_t res_niov;
> > + struct virgl_gpu_resource *vres;
> > int ret;
> >
> > VIRTIO_GPU_FILL_CMD(att_rb);
> > trace_virtio_gpu_cmd_res_back_attach(att_rb.resource_id);
> >
> > + vres = virgl_gpu_find_resource(g, att_rb.resource_id);
> > + if (!vres) {
> > + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
> > + return;
> > + }
> > +
> > ret = virtio_gpu_create_mapping_iov(g, att_rb.nr_entries, sizeof(att_rb),
> > - cmd, NULL, &res_iovs, &res_niov);
> > + cmd, NULL, &vres->res.iov,
> > + &vres->res.iov_cnt);
> > if (ret != 0) {
> > cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
> > return;
> > }
> >
> > ret = virgl_renderer_resource_attach_iov(att_rb.resource_id,
> > - res_iovs, res_niov);
> > + vres->res.iov, vres->res.iov_cnt);
> >
> > - if (ret != 0)
> > - virtio_gpu_cleanup_mapping_iov(g, res_iovs, res_niov);
> > + if (ret != 0) {
> > + virtio_gpu_cleanup_mapping(g, &vres->res);
> > + }
> > }
> >
> > static void virgl_resource_detach_backing(VirtIOGPU *g,
> > struct virtio_gpu_ctrl_command *cmd)
> > {
> > struct virtio_gpu_resource_detach_backing detach_rb;
> > - struct iovec *res_iovs = NULL;
> > - int num_iovs = 0;
> > + struct virgl_gpu_resource *vres;
> >
> > VIRTIO_GPU_FILL_CMD(detach_rb);
> > trace_virtio_gpu_cmd_res_back_detach(detach_rb.resource_id);
> >
> > - virgl_renderer_resource_detach_iov(detach_rb.resource_id,
> > - &res_iovs,
> > - &num_iovs);
> > - if (res_iovs == NULL || num_iovs == 0) {
> > + vres = virgl_gpu_find_resource(g, detach_rb.resource_id);
> > + if (!vres) {
> > + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
> > return;
> > }
> > - virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs);
> > +
> > + virgl_renderer_resource_detach_iov(detach_rb.resource_id, NULL, NULL);
> > + virtio_gpu_cleanup_mapping(g, &vres->res);
> > }
> >
> >
> > --
> > 2.25.1
> >
> >
>
>
> --
> Marc-André Lureau
next prev parent reply other threads:[~2024-01-04 7:28 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 7:53 [PATCH v6 00/11] Support blob memory and venus on qemu Huang Rui
2023-12-19 7:53 ` [PATCH v6 01/11] linux-headers: Update to kernel headers to add venus capset Huang Rui
2023-12-19 12:20 ` Akihiko Odaki
2023-12-19 13:47 ` Huang Rui
2023-12-19 14:14 ` Peter Maydell
2023-12-21 6:55 ` Akihiko Odaki
2024-01-02 10:42 ` Marc-André Lureau
2024-01-03 6:35 ` Huang Rui
2024-01-03 6:03 ` Huang Rui
2024-01-03 5:58 ` Huang Rui
2023-12-19 7:53 ` [PATCH v6 02/11] virtio-gpu: Configure new feature flag context_create_with_flags for virglrenderer Huang Rui
2023-12-19 9:09 ` Antonio Caggiano
2023-12-19 11:41 ` Huang Rui
2024-01-05 16:18 ` Alex Bennée
2023-12-19 7:53 ` [PATCH v6 03/11] virtio-gpu: Support context init feature with virglrenderer Huang Rui
2024-01-02 11:43 ` Marc-André Lureau
2024-01-03 8:46 ` Huang Rui
2024-01-04 12:16 ` Akihiko Odaki
2023-12-19 7:53 ` [PATCH v6 04/11] virtio-gpu: Don't require udmabuf when blobs and virgl are enabled Huang Rui
2024-01-02 11:50 ` Marc-André Lureau
2023-12-19 7:53 ` [PATCH v6 05/11] virtio-gpu: Introduce virgl_gpu_resource structure Huang Rui
2023-12-19 12:35 ` Akihiko Odaki
2023-12-19 13:27 ` Huang Rui
2023-12-21 5:43 ` Akihiko Odaki
2024-01-03 8:48 ` Huang Rui
2024-01-02 11:52 ` Marc-André Lureau
2024-01-04 7:27 ` Huang Rui [this message]
2023-12-19 7:53 ` [PATCH v6 06/11] softmmu/memory: enable automatic deallocation of memory regions Huang Rui
2023-12-21 5:45 ` Akihiko Odaki
2023-12-21 7:35 ` Xenia Ragiadakou
2023-12-21 7:50 ` Akihiko Odaki
2023-12-21 8:32 ` Xenia Ragiadakou
2023-12-19 7:53 ` [PATCH v6 07/11] virtio-gpu: Handle resource blob commands Huang Rui
2023-12-21 5:57 ` Akihiko Odaki
2023-12-21 7:39 ` Xenia Ragiadakou
2023-12-21 8:09 ` Akihiko Odaki
2024-01-10 12:59 ` Pierre-Eric Pelloux-Prayer
2024-01-02 12:38 ` Marc-André Lureau
2024-01-09 16:50 ` Pierre-Eric Pelloux-Prayer
2024-01-10 8:51 ` Pierre-Eric Pelloux-Prayer
2024-02-23 6:34 ` Huang Rui via
2024-02-23 6:34 ` Huang Rui
2023-12-19 7:53 ` [PATCH v6 08/11] virtio-gpu: Resource UUID Huang Rui
2023-12-21 6:03 ` Akihiko Odaki
2024-01-02 12:49 ` Marc-André Lureau
2024-02-23 9:04 ` Huang Rui
2023-12-19 7:53 ` [PATCH v6 09/11] virtio-gpu: Support Venus capset Huang Rui
2023-12-19 10:42 ` Pierre-Eric Pelloux-Prayer
2023-12-19 7:53 ` [PATCH v6 10/11] virtio-gpu: Initialize Venus Huang Rui
2024-01-02 13:33 ` Marc-André Lureau
2024-02-23 9:15 ` Huang Rui
2024-03-26 8:53 ` Pierre-Eric Pelloux-Prayer
2023-12-19 7:53 ` [PATCH v6 11/11] virtio-gpu: make blob scanout use dmabuf fd Huang Rui
2023-12-21 6:25 ` Akihiko Odaki
2024-01-04 11:19 ` Pierre-Eric Pelloux-Prayer
2024-01-05 13:28 ` Alex Bennée
2024-01-05 16:09 ` Alex Bennée
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=ZZZd6rueZGmzSbPb@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=akihiko.odaki@daynix.com \
--cc=alex.bennee@linaro.org \
--cc=anthony.perard@citrix.com \
--cc=bob.beckett@collabora.com \
--cc=dgilbert@redhat.com \
--cc=dmitry.osipenko@collabora.com \
--cc=ernunes@redhat.com \
--cc=gert.wollny@collabora.com \
--cc=gurchetansingh@chromium.org \
--cc=hi@alyssa.is \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@gmail.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=stefano.stabellini@amd.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.