drm/xe: Allow dma-fences as in-syncs for compute / faulting VM
authorMatthew Brost <matthew.brost@intel.com>
Sun, 16 Apr 2023 23:14:26 +0000 (16:14 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:33:51 +0000 (18:33 -0500)
This is allowed and encouraged by the dma-fencing rules. This along with
allowing compute VMs to export dma-fences on binds will result in a
simpler compute UMD.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_sync.c

index 99f1ed87196d6fed580dfd48d030c4e7144e542c..1e4e4acb2c4a29893a115e5454a71003d9d638e0 100644 (file)
@@ -105,6 +105,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
 {
        struct drm_xe_sync sync_in;
        int err;
+       bool signal;
 
        if (copy_from_user(&sync_in, sync_user, sizeof(*sync_user)))
                return -EFAULT;
@@ -113,9 +114,10 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                         ~(SYNC_FLAGS_TYPE_MASK | DRM_XE_SYNC_SIGNAL)))
                return -EINVAL;
 
+       signal = sync_in.flags & DRM_XE_SYNC_SIGNAL;
        switch (sync_in.flags & SYNC_FLAGS_TYPE_MASK) {
        case DRM_XE_SYNC_SYNCOBJ:
-               if (XE_IOCTL_ERR(xe, no_dma_fences))
+               if (XE_IOCTL_ERR(xe, no_dma_fences && signal))
                        return -ENOTSUPP;
 
                if (XE_IOCTL_ERR(xe, upper_32_bits(sync_in.addr)))
@@ -125,7 +127,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                if (XE_IOCTL_ERR(xe, !sync->syncobj))
                        return -ENOENT;
 
-               if (!(sync_in.flags & DRM_XE_SYNC_SIGNAL)) {
+               if (!signal) {
                        sync->fence = drm_syncobj_fence_get(sync->syncobj);
                        if (XE_IOCTL_ERR(xe, !sync->fence))
                                return -EINVAL;
@@ -133,7 +135,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                break;
 
        case DRM_XE_SYNC_TIMELINE_SYNCOBJ:
-               if (XE_IOCTL_ERR(xe, no_dma_fences))
+               if (XE_IOCTL_ERR(xe, no_dma_fences && signal))
                        return -ENOTSUPP;
 
                if (XE_IOCTL_ERR(xe, upper_32_bits(sync_in.addr)))
@@ -146,7 +148,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                if (XE_IOCTL_ERR(xe, !sync->syncobj))
                        return -ENOENT;
 
-               if (sync_in.flags & DRM_XE_SYNC_SIGNAL) {
+               if (signal) {
                        sync->chain_fence = dma_fence_chain_alloc();
                        if (!sync->chain_fence)
                                return -ENOMEM;
@@ -168,7 +170,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                break;
 
        case DRM_XE_SYNC_USER_FENCE:
-               if (XE_IOCTL_ERR(xe, !(sync_in.flags & DRM_XE_SYNC_SIGNAL)))
+               if (XE_IOCTL_ERR(xe, !signal))
                        return -ENOTSUPP;
 
                if (XE_IOCTL_ERR(xe, sync_in.addr & 0x7))