All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/virtio: fix command submission with objects but without fence.
@ 2019-09-04  7:48 ` Gerd Hoffmann
  0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2019-09-04  7:48 UTC (permalink / raw)
  To: dri-devel
  Cc: olvaffe, Gerd Hoffmann, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

Only call virtio_gpu_array_add_fence if we actually have a fence.

Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 595fa6ec2d58..7fd2851f7b97 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
 		goto again;
 	}
 
-	if (fence)
+	if (fence) {
 		virtio_gpu_fence_emit(vgdev, hdr, fence);
-	if (vbuf->objs) {
-		virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
-		virtio_gpu_array_unlock_resv(vbuf->objs);
+		if (vbuf->objs) {
+			virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
+			virtio_gpu_array_unlock_resv(vbuf->objs);
+		}
 	}
 	notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
 	spin_unlock(&vgdev->ctrlq.qlock);
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] drm/virtio: fix command submission with objects but without fence.
@ 2019-09-04  7:48 ` Gerd Hoffmann
  0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2019-09-04  7:48 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, open list, open list:VIRTIO GPU DRIVER, Gerd Hoffmann

Only call virtio_gpu_array_add_fence if we actually have a fence.

Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 595fa6ec2d58..7fd2851f7b97 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
 		goto again;
 	}
 
-	if (fence)
+	if (fence) {
 		virtio_gpu_fence_emit(vgdev, hdr, fence);
-	if (vbuf->objs) {
-		virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
-		virtio_gpu_array_unlock_resv(vbuf->objs);
+		if (vbuf->objs) {
+			virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
+			virtio_gpu_array_unlock_resv(vbuf->objs);
+		}
 	}
 	notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
 	spin_unlock(&vgdev->ctrlq.qlock);
-- 
2.18.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
  2019-09-04  7:48 ` Gerd Hoffmann
@ 2019-09-04 23:10   ` Chia-I Wu
  -1 siblings, 0 replies; 12+ messages in thread
From: Chia-I Wu @ 2019-09-04 23:10 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: ML dri-devel, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Only call virtio_gpu_array_add_fence if we actually have a fence.
>
> Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index 595fa6ec2d58..7fd2851f7b97 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
>                 goto again;
>         }
>
> -       if (fence)
> +       if (fence) {
>                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> -       if (vbuf->objs) {
> -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> -               virtio_gpu_array_unlock_resv(vbuf->objs);
> +               if (vbuf->objs) {
> +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> +               }
This leaks when fence == NULL and vbuf->objs != NULL (which can really
happen IIRC... not at my desk to check).


>         }
>         notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
>         spin_unlock(&vgdev->ctrlq.qlock);
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
  2019-09-04  7:48 ` Gerd Hoffmann
  (?)
@ 2019-09-04 23:10 ` Chia-I Wu
  -1 siblings, 0 replies; 12+ messages in thread
From: Chia-I Wu @ 2019-09-04 23:10 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: David Airlie, open list, Daniel Vetter, ML dri-devel,
	open list:VIRTIO GPU DRIVER

On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Only call virtio_gpu_array_add_fence if we actually have a fence.
>
> Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index 595fa6ec2d58..7fd2851f7b97 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
>                 goto again;
>         }
>
> -       if (fence)
> +       if (fence) {
>                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> -       if (vbuf->objs) {
> -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> -               virtio_gpu_array_unlock_resv(vbuf->objs);
> +               if (vbuf->objs) {
> +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> +               }
This leaks when fence == NULL and vbuf->objs != NULL (which can really
happen IIRC... not at my desk to check).


>         }
>         notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
>         spin_unlock(&vgdev->ctrlq.qlock);
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
@ 2019-09-04 23:10   ` Chia-I Wu
  0 siblings, 0 replies; 12+ messages in thread
From: Chia-I Wu @ 2019-09-04 23:10 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: ML dri-devel, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Only call virtio_gpu_array_add_fence if we actually have a fence.
>
> Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index 595fa6ec2d58..7fd2851f7b97 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
>                 goto again;
>         }
>
> -       if (fence)
> +       if (fence) {
>                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> -       if (vbuf->objs) {
> -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> -               virtio_gpu_array_unlock_resv(vbuf->objs);
> +               if (vbuf->objs) {
> +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> +               }
This leaks when fence == NULL and vbuf->objs != NULL (which can really
happen IIRC... not at my desk to check).


>         }
>         notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
>         spin_unlock(&vgdev->ctrlq.qlock);
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
  2019-09-04 23:10   ` Chia-I Wu
@ 2019-09-05  5:23     ` Gerd Hoffmann
  -1 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2019-09-05  5:23 UTC (permalink / raw)
  To: Chia-I Wu
  Cc: ML dri-devel, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote:
> On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > Only call virtio_gpu_array_add_fence if we actually have a fence.
> >
> > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > index 595fa6ec2d58..7fd2851f7b97 100644
> > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
> >                 goto again;
> >         }
> >
> > -       if (fence)
> > +       if (fence) {
> >                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> > -       if (vbuf->objs) {
> > -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > -               virtio_gpu_array_unlock_resv(vbuf->objs);
> > +               if (vbuf->objs) {
> > +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> > +               }
> This leaks when fence == NULL and vbuf->objs != NULL (which can really
> happen IIRC... not at my desk to check).

Yes, it can happen, for example when flushing dumb buffers.

But I don't think we leak in this case.  The code paths which don't need
a fence also do not call virtio_gpu_array_lock_resv(), so things are
balanced.  The actual release of the objs happens in
virtio_gpu_dequeue_ctrl_func() via virtio_gpu_array_put_free_delayed().

cheers,
  Gerd


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
  2019-09-04 23:10   ` Chia-I Wu
  (?)
  (?)
@ 2019-09-05  5:23   ` Gerd Hoffmann
  -1 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2019-09-05  5:23 UTC (permalink / raw)
  To: Chia-I Wu
  Cc: David Airlie, open list, Daniel Vetter, ML dri-devel,
	open list:VIRTIO GPU DRIVER

On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote:
> On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > Only call virtio_gpu_array_add_fence if we actually have a fence.
> >
> > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > index 595fa6ec2d58..7fd2851f7b97 100644
> > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
> >                 goto again;
> >         }
> >
> > -       if (fence)
> > +       if (fence) {
> >                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> > -       if (vbuf->objs) {
> > -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > -               virtio_gpu_array_unlock_resv(vbuf->objs);
> > +               if (vbuf->objs) {
> > +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> > +               }
> This leaks when fence == NULL and vbuf->objs != NULL (which can really
> happen IIRC... not at my desk to check).

Yes, it can happen, for example when flushing dumb buffers.

But I don't think we leak in this case.  The code paths which don't need
a fence also do not call virtio_gpu_array_lock_resv(), so things are
balanced.  The actual release of the objs happens in
virtio_gpu_dequeue_ctrl_func() via virtio_gpu_array_put_free_delayed().

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
@ 2019-09-05  5:23     ` Gerd Hoffmann
  0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2019-09-05  5:23 UTC (permalink / raw)
  To: Chia-I Wu
  Cc: ML dri-devel, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote:
> On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > Only call virtio_gpu_array_add_fence if we actually have a fence.
> >
> > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > index 595fa6ec2d58..7fd2851f7b97 100644
> > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
> >                 goto again;
> >         }
> >
> > -       if (fence)
> > +       if (fence) {
> >                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> > -       if (vbuf->objs) {
> > -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > -               virtio_gpu_array_unlock_resv(vbuf->objs);
> > +               if (vbuf->objs) {
> > +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> > +               }
> This leaks when fence == NULL and vbuf->objs != NULL (which can really
> happen IIRC... not at my desk to check).

Yes, it can happen, for example when flushing dumb buffers.

But I don't think we leak in this case.  The code paths which don't need
a fence also do not call virtio_gpu_array_lock_resv(), so things are
balanced.  The actual release of the objs happens in
virtio_gpu_dequeue_ctrl_func() via virtio_gpu_array_put_free_delayed().

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
  2019-09-05  5:23     ` Gerd Hoffmann
@ 2019-09-05 17:14       ` Chia-I Wu
  -1 siblings, 0 replies; 12+ messages in thread
From: Chia-I Wu @ 2019-09-05 17:14 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: ML dri-devel, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

On Wed, Sep 4, 2019 at 10:23 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote:
> > On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > >
> > > Only call virtio_gpu_array_add_fence if we actually have a fence.
> > >
> > > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > >  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > index 595fa6ec2d58..7fd2851f7b97 100644
> > > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
> > >                 goto again;
> > >         }
> > >
> > > -       if (fence)
> > > +       if (fence) {
> > >                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> > > -       if (vbuf->objs) {
> > > -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > > -               virtio_gpu_array_unlock_resv(vbuf->objs);
> > > +               if (vbuf->objs) {
> > > +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > > +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> > > +               }
> > This leaks when fence == NULL and vbuf->objs != NULL (which can really
> > happen IIRC... not at my desk to check).
>
> Yes, it can happen, for example when flushing dumb buffers.
>
> But I don't think we leak in this case.  The code paths which don't need
> a fence also do not call virtio_gpu_array_lock_resv(), so things are
> balanced.  The actual release of the objs happens in
> virtio_gpu_dequeue_ctrl_func() via virtio_gpu_array_put_free_delayed().
I misread and thought this was in virtio_gpu_dequeue_ctrl_func.  Sorry :(

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>



>
> cheers,
>   Gerd
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
  2019-09-05  5:23     ` Gerd Hoffmann
  (?)
  (?)
@ 2019-09-05 17:14     ` Chia-I Wu
  -1 siblings, 0 replies; 12+ messages in thread
From: Chia-I Wu @ 2019-09-05 17:14 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: David Airlie, open list, Daniel Vetter, ML dri-devel,
	open list:VIRTIO GPU DRIVER

On Wed, Sep 4, 2019 at 10:23 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote:
> > On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > >
> > > Only call virtio_gpu_array_add_fence if we actually have a fence.
> > >
> > > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > >  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > index 595fa6ec2d58..7fd2851f7b97 100644
> > > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
> > >                 goto again;
> > >         }
> > >
> > > -       if (fence)
> > > +       if (fence) {
> > >                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> > > -       if (vbuf->objs) {
> > > -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > > -               virtio_gpu_array_unlock_resv(vbuf->objs);
> > > +               if (vbuf->objs) {
> > > +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > > +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> > > +               }
> > This leaks when fence == NULL and vbuf->objs != NULL (which can really
> > happen IIRC... not at my desk to check).
>
> Yes, it can happen, for example when flushing dumb buffers.
>
> But I don't think we leak in this case.  The code paths which don't need
> a fence also do not call virtio_gpu_array_lock_resv(), so things are
> balanced.  The actual release of the objs happens in
> virtio_gpu_dequeue_ctrl_func() via virtio_gpu_array_put_free_delayed().
I misread and thought this was in virtio_gpu_dequeue_ctrl_func.  Sorry :(

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>



>
> cheers,
>   Gerd
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/virtio: fix command submission with objects but without fence.
@ 2019-09-05 17:14       ` Chia-I Wu
  0 siblings, 0 replies; 12+ messages in thread
From: Chia-I Wu @ 2019-09-05 17:14 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: David Airlie, open list, ML dri-devel, open list:VIRTIO GPU DRIVER

On Wed, Sep 4, 2019 at 10:23 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Wed, Sep 04, 2019 at 04:10:30PM -0700, Chia-I Wu wrote:
> > On Wed, Sep 4, 2019 at 12:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > >
> > > Only call virtio_gpu_array_add_fence if we actually have a fence.
> > >
> > > Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > >  drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > index 595fa6ec2d58..7fd2851f7b97 100644
> > > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> > > @@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
> > >                 goto again;
> > >         }
> > >
> > > -       if (fence)
> > > +       if (fence) {
> > >                 virtio_gpu_fence_emit(vgdev, hdr, fence);
> > > -       if (vbuf->objs) {
> > > -               virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > > -               virtio_gpu_array_unlock_resv(vbuf->objs);
> > > +               if (vbuf->objs) {
> > > +                       virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
> > > +                       virtio_gpu_array_unlock_resv(vbuf->objs);
> > > +               }
> > This leaks when fence == NULL and vbuf->objs != NULL (which can really
> > happen IIRC... not at my desk to check).
>
> Yes, it can happen, for example when flushing dumb buffers.
>
> But I don't think we leak in this case.  The code paths which don't need
> a fence also do not call virtio_gpu_array_lock_resv(), so things are
> balanced.  The actual release of the objs happens in
> virtio_gpu_dequeue_ctrl_func() via virtio_gpu_array_put_free_delayed().
I misread and thought this was in virtio_gpu_dequeue_ctrl_func.  Sorry :(

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>



>
> cheers,
>   Gerd
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] drm/virtio: fix command submission with objects but without fence.
@ 2019-09-04  7:48 Gerd Hoffmann
  0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2019-09-04  7:48 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, open list, open list:VIRTIO GPU DRIVER,
	Daniel Vetter, olvaffe

Only call virtio_gpu_array_add_fence if we actually have a fence.

Fixes: da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 595fa6ec2d58..7fd2851f7b97 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
 		goto again;
 	}
 
-	if (fence)
+	if (fence) {
 		virtio_gpu_fence_emit(vgdev, hdr, fence);
-	if (vbuf->objs) {
-		virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
-		virtio_gpu_array_unlock_resv(vbuf->objs);
+		if (vbuf->objs) {
+			virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
+			virtio_gpu_array_unlock_resv(vbuf->objs);
+		}
 	}
 	notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
 	spin_unlock(&vgdev->ctrlq.qlock);
-- 
2.18.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-09-05 17:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  7:48 [PATCH] drm/virtio: fix command submission with objects but without fence Gerd Hoffmann
2019-09-04  7:48 ` Gerd Hoffmann
2019-09-04 23:10 ` Chia-I Wu
2019-09-04 23:10 ` Chia-I Wu
2019-09-04 23:10   ` Chia-I Wu
2019-09-05  5:23   ` Gerd Hoffmann
2019-09-05  5:23     ` Gerd Hoffmann
2019-09-05 17:14     ` Chia-I Wu
2019-09-05 17:14       ` Chia-I Wu
2019-09-05 17:14     ` Chia-I Wu
2019-09-05  5:23   ` Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2019-09-04  7:48 Gerd Hoffmann

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.