qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>,
	 "Michael S. Tsirkin" <mst@redhat.com>,
	Gurchetan Singh <gurchetansingh@chromium.org>,
	Alyssa Ross <hi@alyssa.is>
Subject: Re: [PATCH v1 2/3] virtio-gpu.c: add resource_destroy class method
Date: Fri, 26 Jan 2024 20:19:16 +0200	[thread overview]
Message-ID: <CAAjaMXaZco6AappQdC+8H9bnipD6A1VCd7b3rrk5h9VHO3qt_g@mail.gmail.com> (raw)
In-Reply-To: <b99352e9-efd2-42a3-b6de-a87832bb007c@linaro.org>

On Fri, 26 Jan 2024 at 17:22, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Hi Manos,
>
> On 26/1/24 15:41, Manos Pitsidianakis wrote:
> > When destroying/unrefing resources, devices such as virtio-gpu-rutabaga
> > need to do their own bookkeeping (free rutabaga resources that are
> > associated with the virtio_gpu_simple_resource).
> >
> > This commit adds a class method so that virtio-gpu-rutabaga can override
> > it in the next commit.
> >
> > Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> > ---
> >   hw/display/virtio-gpu.c        | 19 ++++++++++++++++---
> >   include/hw/virtio/virtio-gpu.h |  2 ++
> >   2 files changed, 18 insertions(+), 3 deletions(-)
>
>
> >   static void virtio_gpu_resource_unref(VirtIOGPU *g,
> > @@ -1488,11 +1491,20 @@ static void virtio_gpu_device_unrealize(DeviceState *qdev)
> >   static void virtio_gpu_reset_bh(void *opaque)
> >   {
> >       VirtIOGPU *g = VIRTIO_GPU(opaque);
> > +    VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
> >       struct virtio_gpu_simple_resource *res, *tmp;
> > +    int32_t result, resource_id;
> >       int i = 0;
> >
> >       QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) {
> > -        virtio_gpu_resource_destroy(g, res);
> > +        resource_id = res->resource_id;
> > +        result = vgc->resource_destroy(g, res);
> > +        if (result) {
> > +            error_report("%s: %s resource_destroy"
> > +                         "for resource_id = %d failed with return value = %d;",
>
> '%d' is for 'int', for 'int32_t' you need 'PRId32'.

Thanks,

> But why return that type instead of 'int'?

Because devices might use FFI, and other languages use fixed size
integers. Since rutabaga is the only one doing this right now, I used
their integer width.

> > +                         __func__, object_get_typename(OBJECT(g)), resource_id,
> > +                         result);
> > +        }
> >       }
>
>
> > diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
> > index 584ba2ed73..5683354236 100644
> > --- a/include/hw/virtio/virtio-gpu.h
> > +++ b/include/hw/virtio/virtio-gpu.h
> > @@ -219,6 +219,8 @@ struct VirtIOGPUClass {
> >       void (*update_cursor_data)(VirtIOGPU *g,
> >                                  struct virtio_gpu_scanout *s,
> >                                  uint32_t resource_id);
> > +    int32_t (*resource_destroy)(VirtIOGPU *g,
> > +                                struct virtio_gpu_simple_resource *res);
> >   };
> >
> >   struct VirtIOGPUGL {
>


  reply	other threads:[~2024-01-26 18:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 14:41 [PATCH v1 0/3] Fix resource freeing bugs in virtio-gpu-rutabaga Manos Pitsidianakis
2024-01-26 14:41 ` [PATCH v1 1/3] hw/display/virtio-gpu.c: use reset_bh class method Manos Pitsidianakis
2024-01-29  8:17   ` Marc-André Lureau
2024-01-26 14:41 ` [PATCH v1 2/3] virtio-gpu.c: add resource_destroy " Manos Pitsidianakis
2024-01-26 15:22   ` Philippe Mathieu-Daudé
2024-01-26 18:19     ` Manos Pitsidianakis [this message]
2024-01-29  8:24       ` Marc-André Lureau
2024-01-26 18:09   ` Alex Bennée
2024-01-26 18:15     ` Manos Pitsidianakis
2024-01-26 14:41 ` [PATCH v1 3/3] virtio-gpu-rutabaga.c: override resource_destroy method Manos Pitsidianakis

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=CAAjaMXaZco6AappQdC+8H9bnipD6A1VCd7b3rrk5h9VHO3qt_g@mail.gmail.com \
    --to=manos.pitsidianakis@linaro.org \
    --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 \
    /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).