drm/xe: Use a flags field instead of bools for sync parse
authorMatthew Brost <matthew.brost@intel.com>
Tue, 5 Dec 2023 18:56:17 +0000 (10:56 -0800)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:46:09 +0000 (11:46 -0500)
Use a flags field instead of severval bools for sync parse as it is
easier to read and less bug prone.

v2: Pull in header change from subsequent patch

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

index 15ab1a927613ff8c2bad05c3bd7e801df84cb9dc..3c9f801d570bff4db7a9315e685ea1e9538f8382 100644 (file)
@@ -151,8 +151,9 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 
        for (i = 0; i < args->num_syncs; i++) {
                err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs++],
-                                         &syncs_user[i], true,
-                                         xe_vm_in_lr_mode(vm));
+                                         &syncs_user[i], SYNC_PARSE_FLAG_EXEC |
+                                         (xe_vm_in_lr_mode(vm) ?
+                                          SYNC_PARSE_FLAG_LR_MODE : 0));
                if (err)
                        goto err_syncs;
        }
index 936227e794835694b3643699cc0c3ae14b6a0c1b..2a3f508722fcfec177724f2a298ff1ea4b26f69a 100644 (file)
@@ -98,10 +98,12 @@ static void user_fence_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
 int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                        struct xe_sync_entry *sync,
                        struct drm_xe_sync __user *sync_user,
-                       bool exec, bool in_lr_mode)
+                       unsigned int flags)
 {
        struct drm_xe_sync sync_in;
        int err;
+       bool exec = flags & SYNC_PARSE_FLAG_EXEC;
+       bool in_lr_mode = flags & SYNC_PARSE_FLAG_LR_MODE;
        bool signal;
 
        if (copy_from_user(&sync_in, sync_user, sizeof(*sync_user)))
index 30958ddc4cdc3d50d83a57263123b60b368c0ad6..1b748cec467816d14a37452e8a9583cc9e144cc9 100644 (file)
@@ -12,10 +12,13 @@ struct xe_device;
 struct xe_file;
 struct xe_sched_job;
 
+#define SYNC_PARSE_FLAG_EXEC                   BIT(0)
+#define SYNC_PARSE_FLAG_LR_MODE                        BIT(1)
+
 int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
                        struct xe_sync_entry *sync,
                        struct drm_xe_sync __user *sync_user,
-                       bool exec, bool compute_mode);
+                       unsigned int flags);
 int xe_sync_entry_wait(struct xe_sync_entry *sync);
 int xe_sync_entry_add_deps(struct xe_sync_entry *sync,
                           struct xe_sched_job *job);
index 7b38338ab5e21a061c01db733d8ee8066ff3df4a..d1e53905268f717c971ca9341167b1c08346562a 100644 (file)
@@ -2994,8 +2994,9 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
        syncs_user = u64_to_user_ptr(args->syncs);
        for (num_syncs = 0; num_syncs < args->num_syncs; num_syncs++) {
                err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs],
-                                         &syncs_user[num_syncs], false,
-                                         xe_vm_in_lr_mode(vm));
+                                         &syncs_user[num_syncs],
+                                         xe_vm_in_lr_mode(vm) ?
+                                         SYNC_PARSE_FLAG_LR_MODE : 0);
                if (err)
                        goto free_syncs;
        }