Skip to contentSkip to conversation

drm/virtio: fix command submission with objects but without fence.

PATCH In review Gerd Hoffmann 2 participants 7 messages Sep 4, 2019 – Sep 5, 2019

Subsystems (4)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

PATCH 1/1 drm/virtio: fix command submission with objects but without fence.

Only call virtio_gpu_array_add_fence if we actually have a fence.

Fixes da758d51968a ("drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -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);
Signature · 6 lines
2.18.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
reviewer
#1 lore raw
Quoted 17 lines · 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")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -0
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
                goto again;
        }
 

drivers/gpu/drm/virtio/virtgpu_vq.c static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, · line 347

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
-       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).

Quoted 6 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -1
        }
        notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
        spin_unlock(&vgdev->ctrlq.qlock);
--

2.18.1

author maintainer
#2 lore raw
Quoted 18 lines · Chia-I Wu
Quoted 17 lines · 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")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -0
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
                goto again;
        }
 
Quoted 12 lines

drivers/gpu/drm/virtio/virtgpu_vq.c static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, · line 347

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
-       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

reviewer Reviewed-by
#3 lore raw
Quoted 33 lines · Gerd Hoffmann
Quoted 18 lines · Chia-I Wu
Quoted 17 lines · 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")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -0
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
                goto again;
        }
 
Quoted 12 lines

drivers/gpu/drm/virtio/virtgpu_vq.c static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, · line 347

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
-       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).

Quoted 6 lines

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 :(

Quoted 4 lines

cheers,
Gerd

reviewer Reviewed-by
#4 lore raw
In reply to Gerd Hoffmann
Quoted 33 lines · Gerd Hoffmann
Quoted 18 lines · Chia-I Wu
Quoted 17 lines · 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")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -0
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
                goto again;
        }
 
Quoted 12 lines

drivers/gpu/drm/virtio/virtgpu_vq.c static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, · line 347

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
-       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).

Quoted 6 lines

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 :(

Quoted 4 lines

cheers,
Gerd

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#5 lore raw
In reply to Chia-I Wu
Quoted 18 lines · Chia-I Wu
Quoted 17 lines · 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")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -0
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
                goto again;
        }
 
Quoted 12 lines

drivers/gpu/drm/virtio/virtgpu_vq.c static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, · line 347

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
-       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

reviewer
#6 lore raw
In reply to Gerd Hoffmann
Quoted 17 lines · 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")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -0
index 595fa6ec2d58..7fd2851f7b97 100644
@@ -339,11 +339,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
                goto again;
        }
 

drivers/gpu/drm/virtio/virtgpu_vq.c static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, · line 347

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5 -4
-       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).

Quoted 6 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +0 -1
        }
        notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
        spin_unlock(&vgdev->ctrlq.qlock);
--

2.18.1