Skip to contentSkip to conversation

drm/virtio: Add execbuf flag to request no fence-event

PATCH In review Rob Clark 2 participants 3 messages Apr 5, 2022 – Apr 22, 2022

Subsystems (4)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/virtio: Add execbuf flag to request no fence-event

From: Rob Clark <[email protected]>

It would have been cleaner to have a flag to *request* the fence event. But that ship has sailed. So add a flag so that userspace which doesn't care about the events can opt-out.

---
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 8 +++++---
 include/uapi/drm/virtgpu_drm.h         | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +5 -3
index 3a8078f2ee27..09f1aa263f91 100644
@@ -225,9 +225,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
 		goto out_unresv;
 	}
 
-	ret = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
-	if (ret)
-		goto out_unresv;
+	if (!(exbuf->flags & VIRTGPU_EXECBUF_NO_EVENT)) {
+		ret = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
+		if (ret)
+			goto out_unresv;
+	}
 
 	if (out_fence_fd >= 0) {
 		sync_file = sync_file_create(&out_fence->f);
include/uapi/drm/virtgpu_drm.h +2 -0
index 0512fde5e697..d06cac3407cc 100644
@@ -52,10 +52,12 @@ extern "C" {
 #define VIRTGPU_EXECBUF_FENCE_FD_IN	0x01
 #define VIRTGPU_EXECBUF_FENCE_FD_OUT	0x02
 #define VIRTGPU_EXECBUF_RING_IDX	0x04
+#define VIRTGPU_EXECBUF_NO_EVENT	0x08
 #define VIRTGPU_EXECBUF_FLAGS  (\
 		VIRTGPU_EXECBUF_FENCE_FD_IN |\
 		VIRTGPU_EXECBUF_FENCE_FD_OUT |\
 		VIRTGPU_EXECBUF_RING_IDX |\
+		VIRTGPU_EXECBUF_NO_EVENT |\
 		0)
 
 struct drm_virtgpu_map {
Signature · 1 line
2.35.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Rob Clark

From: Rob Clark <[email protected]>

It would have been cleaner to have a flag to *request* the fence event. But that ship has sailed. So add a flag so that userspace which doesn't care about the events can opt-out.

Might want to wait for Gurchetan to chime in as he added the mechanism.

Quoted 44 lines
---
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 8 +++++---
 include/uapi/drm/virtgpu_drm.h         | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +5 -3
index 3a8078f2ee27..09f1aa263f91 100644
@@ -225,9 +225,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
                goto out_unresv;
        }
 
-       ret = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
-       if (ret)
-               goto out_unresv;
+       if (!(exbuf->flags & VIRTGPU_EXECBUF_NO_EVENT)) {
+               ret = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
+               if (ret)
+                       goto out_unresv;
+       }
 
        if (out_fence_fd >= 0) {
                sync_file = sync_file_create(&out_fence->f);
include/uapi/drm/virtgpu_drm.h +2 -1
index 0512fde5e697..d06cac3407cc 100644
@@ -52,10 +52,12 @@ extern "C" {
 #define VIRTGPU_EXECBUF_FENCE_FD_IN    0x01
 #define VIRTGPU_EXECBUF_FENCE_FD_OUT   0x02
 #define VIRTGPU_EXECBUF_RING_IDX       0x04
+#define VIRTGPU_EXECBUF_NO_EVENT       0x08
 #define VIRTGPU_EXECBUF_FLAGS  (\
                VIRTGPU_EXECBUF_FENCE_FD_IN |\
                VIRTGPU_EXECBUF_FENCE_FD_OUT |\
                VIRTGPU_EXECBUF_RING_IDX |\
+               VIRTGPU_EXECBUF_NO_EVENT |\
                0)
 
 struct drm_virtgpu_map {
--

2.35.1

author
#2 lore raw
Quoted 5 lines · Chia-I Wu
Quoted 3 lines · Rob Clark

From: Rob Clark <[email protected]>

Quoted 8 lines
Quoted 5 lines

It would have been cleaner to have a flag to *request* the fence event. But that ship has sailed. So add a flag so that userspace which doesn't care about the events can opt-out.

Might want to wait for Gurchetan to chime in as he added the mechanism.

It turns out this patch is unnecessary.. I can simply not set VIRTGPU_CONTEXT_PARAM_POLL_RINGS_MASK instead

so self-nak for this patch ;-)

BR,
-R

Quoted 44 lines
Quoted 44 lines
---
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 8 +++++---
 include/uapi/drm/virtgpu_drm.h         | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +5 -3
index 3a8078f2ee27..09f1aa263f91 100644
@@ -225,9 +225,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
                goto out_unresv;
        }
 
-       ret = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
-       if (ret)
-               goto out_unresv;
+       if (!(exbuf->flags & VIRTGPU_EXECBUF_NO_EVENT)) {
+               ret = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
+               if (ret)
+                       goto out_unresv;
+       }
 
        if (out_fence_fd >= 0) {
                sync_file = sync_file_create(&out_fence->f);
include/uapi/drm/virtgpu_drm.h +2 -1
index 0512fde5e697..d06cac3407cc 100644
@@ -52,10 +52,12 @@ extern "C" {
 #define VIRTGPU_EXECBUF_FENCE_FD_IN    0x01
 #define VIRTGPU_EXECBUF_FENCE_FD_OUT   0x02
 #define VIRTGPU_EXECBUF_RING_IDX       0x04
+#define VIRTGPU_EXECBUF_NO_EVENT       0x08
 #define VIRTGPU_EXECBUF_FLAGS  (\
                VIRTGPU_EXECBUF_FENCE_FD_IN |\
                VIRTGPU_EXECBUF_FENCE_FD_OUT |\
                VIRTGPU_EXECBUF_RING_IDX |\
+               VIRTGPU_EXECBUF_NO_EVENT |\
                0)
 
 struct drm_virtgpu_map {
--

2.35.1