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 09/13] virtio-gpu: Handle resource blob commands
Date: Wed, 20 Sep 2023 13:50:14 +0800 [thread overview]
Message-ID: <ZQqIFvasHD+Y8TSa@amd.com> (raw)
In-Reply-To: <9700c2ed-93c5-4bf6-bc6b-d5d33359d9a7@daynix.com>
On Sat, Sep 16, 2023 at 12:37:29AM +0800, Akihiko Odaki wrote:
> On 2023/09/16 1:04, Akihiko Odaki wrote:
> > On 2023/09/15 20:11, Huang Rui wrote:
> >> From: Antonio Caggiano <antonio.caggiano@collabora.com>
> >>
> >> Support BLOB resources creation, mapping and unmapping by calling the
> >> new stable virglrenderer 0.10 interface. Only enabled when available and
> >> via the blob config. E.g. -device virtio-vga-gl,blob=true
> >>
> >> Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
> >> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> >> Signed-off-by: Xenia Ragiadakou <xenia.ragiadakou@amd.com>
> >> Signed-off-by: Huang Rui <ray.huang@amd.com>
> >> ---
> >>
> >> V4 -> V5:
> >> - Use memory_region_init_ram_ptr() instead of
> >> memory_region_init_ram_device_ptr() (Akihiko)
> >>
> >> hw/display/virtio-gpu-virgl.c | 213 +++++++++++++++++++++++++++++++++
> >> hw/display/virtio-gpu.c | 4 +-
> >> include/hw/virtio/virtio-gpu.h | 5 +
> >> meson.build | 4 +
> >> 4 files changed, 225 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/hw/display/virtio-gpu-virgl.c
> >> b/hw/display/virtio-gpu-virgl.c
> >> index 312953ec16..563a6f2f58 100644
> >> --- a/hw/display/virtio-gpu-virgl.c
> >> +++ b/hw/display/virtio-gpu-virgl.c
> >> @@ -17,6 +17,7 @@
> >> #include "trace.h"
> >> #include "hw/virtio/virtio.h"
> >> #include "hw/virtio/virtio-gpu.h"
> >> +#include "hw/virtio/virtio-gpu-bswap.h"
> >> #include "ui/egl-helpers.h"
> >> @@ -78,9 +79,24 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
> >> virgl_renderer_resource_create(&args, NULL, 0);
> >> }
> >> +static void virgl_resource_destroy(VirtIOGPU *g,
> >> + struct virtio_gpu_simple_resource
> >> *res)
> >> +{
> >> + if (!res)
> >> + return;
> >> +
> >> + QTAILQ_REMOVE(&g->reslist, res, next);
> >> +
> >> + virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt);
> >> + g_free(res->addrs);
> >> +
> >> + g_free(res);
> >> +}
> >> +
> >> static void virgl_cmd_resource_unref(VirtIOGPU *g,
> >> struct virtio_gpu_ctrl_command
> >> *cmd)
> >> {
> >> + struct virtio_gpu_simple_resource *res;
> >> struct virtio_gpu_resource_unref unref;
> >> struct iovec *res_iovs = NULL;
> >> int num_iovs = 0;
> >> @@ -88,13 +104,22 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
> >> VIRTIO_GPU_FILL_CMD(unref);
> >> trace_virtio_gpu_cmd_res_unref(unref.resource_id);
> >> + res = virtio_gpu_find_resource(g, 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);
> >> + if (res) {
> >> + res->iov = NULL;
> >> + res->iov_cnt = 0;
> >> + }
> >> }
> >> +
> >> virgl_renderer_resource_unref(unref.resource_id);
> >> +
> >> + virgl_resource_destroy(g, res);
>
> This may leak memory region.
The memory region should be freed under virgl_cmd_resource_unmap_blob()
which is calling memory_region_del_subregion(&b->hostmem, res->region).
Because this region is created by map_blob(). Do we have the case to call
virgl_cmd_resource_unref() without calling virgl_cmd_resource_unmap_blob()
for blob memory?
Thanks,
Ray
WARNING: multiple messages have this Message-ID (diff)
From: Huang Rui via <qemu-devel@nongnu.org>
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 09/13] virtio-gpu: Handle resource blob commands
Date: Wed, 20 Sep 2023 13:50:14 +0800 [thread overview]
Message-ID: <ZQqIFvasHD+Y8TSa@amd.com> (raw)
In-Reply-To: <9700c2ed-93c5-4bf6-bc6b-d5d33359d9a7@daynix.com>
On Sat, Sep 16, 2023 at 12:37:29AM +0800, Akihiko Odaki wrote:
> On 2023/09/16 1:04, Akihiko Odaki wrote:
> > On 2023/09/15 20:11, Huang Rui wrote:
> >> From: Antonio Caggiano <antonio.caggiano@collabora.com>
> >>
> >> Support BLOB resources creation, mapping and unmapping by calling the
> >> new stable virglrenderer 0.10 interface. Only enabled when available and
> >> via the blob config. E.g. -device virtio-vga-gl,blob=true
> >>
> >> Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
> >> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> >> Signed-off-by: Xenia Ragiadakou <xenia.ragiadakou@amd.com>
> >> Signed-off-by: Huang Rui <ray.huang@amd.com>
> >> ---
> >>
> >> V4 -> V5:
> >> - Use memory_region_init_ram_ptr() instead of
> >> memory_region_init_ram_device_ptr() (Akihiko)
> >>
> >> hw/display/virtio-gpu-virgl.c | 213 +++++++++++++++++++++++++++++++++
> >> hw/display/virtio-gpu.c | 4 +-
> >> include/hw/virtio/virtio-gpu.h | 5 +
> >> meson.build | 4 +
> >> 4 files changed, 225 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/hw/display/virtio-gpu-virgl.c
> >> b/hw/display/virtio-gpu-virgl.c
> >> index 312953ec16..563a6f2f58 100644
> >> --- a/hw/display/virtio-gpu-virgl.c
> >> +++ b/hw/display/virtio-gpu-virgl.c
> >> @@ -17,6 +17,7 @@
> >> #include "trace.h"
> >> #include "hw/virtio/virtio.h"
> >> #include "hw/virtio/virtio-gpu.h"
> >> +#include "hw/virtio/virtio-gpu-bswap.h"
> >> #include "ui/egl-helpers.h"
> >> @@ -78,9 +79,24 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
> >> virgl_renderer_resource_create(&args, NULL, 0);
> >> }
> >> +static void virgl_resource_destroy(VirtIOGPU *g,
> >> + struct virtio_gpu_simple_resource
> >> *res)
> >> +{
> >> + if (!res)
> >> + return;
> >> +
> >> + QTAILQ_REMOVE(&g->reslist, res, next);
> >> +
> >> + virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt);
> >> + g_free(res->addrs);
> >> +
> >> + g_free(res);
> >> +}
> >> +
> >> static void virgl_cmd_resource_unref(VirtIOGPU *g,
> >> struct virtio_gpu_ctrl_command
> >> *cmd)
> >> {
> >> + struct virtio_gpu_simple_resource *res;
> >> struct virtio_gpu_resource_unref unref;
> >> struct iovec *res_iovs = NULL;
> >> int num_iovs = 0;
> >> @@ -88,13 +104,22 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
> >> VIRTIO_GPU_FILL_CMD(unref);
> >> trace_virtio_gpu_cmd_res_unref(unref.resource_id);
> >> + res = virtio_gpu_find_resource(g, 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);
> >> + if (res) {
> >> + res->iov = NULL;
> >> + res->iov_cnt = 0;
> >> + }
> >> }
> >> +
> >> virgl_renderer_resource_unref(unref.resource_id);
> >> +
> >> + virgl_resource_destroy(g, res);
>
> This may leak memory region.
The memory region should be freed under virgl_cmd_resource_unmap_blob()
which is calling memory_region_del_subregion(&b->hostmem, res->region).
Because this region is created by map_blob(). Do we have the case to call
virgl_cmd_resource_unref() without calling virgl_cmd_resource_unmap_blob()
for blob memory?
Thanks,
Ray
next prev parent reply other threads:[~2023-09-20 5:51 UTC|newest]
Thread overview: 57+ 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 [this message]
2023-09-20 5:50 ` Huang Rui via
2023-09-20 5:54 ` Akihiko Odaki
2023-09-20 6:11 ` Huang Rui
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
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=ZQqIFvasHD+Y8TSa@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 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.