]> www.infradead.org Git - nvme.git/commitdiff
drm/xe/exec: Fix minor bug related to xe_sync_entry_cleanup
authorAshutosh Dixit <ashutosh.dixit@intel.com>
Thu, 11 Jul 2024 21:12:03 +0000 (14:12 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 18 Jul 2024 14:25:17 +0000 (10:25 -0400)
Increment num_syncs after xe_sync_entry_parse() is successful to ensure
the xe_sync_entry_cleanup() logic under "err_syncs" label works correctly.

v2: Use the same pattern as that in xe_vm.c (Matt Brost)

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240711211203.3728180-1-ashutosh.dixit@intel.com
(cherry picked from commit 43a6faa6d9b5e9139758200a79fe9c8f4aaa0c8d)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_exec.c

index 2d72cdec3a0b394f3b65dabf1c818fe6dd2857cc..f36980aa26e69a8bf439f4b69f3b5b98b78ff40f 100644 (file)
@@ -118,7 +118,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
        u64 addresses[XE_HW_ENGINE_MAX_INSTANCE];
        struct drm_gpuvm_exec vm_exec = {.extra.fn = xe_exec_fn};
        struct drm_exec *exec = &vm_exec.exec;
-       u32 i, num_syncs = 0, num_ufence = 0;
+       u32 i, num_syncs, num_ufence = 0;
        struct xe_sched_job *job;
        struct xe_vm *vm;
        bool write_locked, skip_retry = false;
@@ -156,15 +156,15 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 
        vm = q->vm;
 
-       for (i = 0; i < args->num_syncs; i++) {
-               err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs++],
-                                         &syncs_user[i], SYNC_PARSE_FLAG_EXEC |
+       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], SYNC_PARSE_FLAG_EXEC |
                                          (xe_vm_in_lr_mode(vm) ?
                                           SYNC_PARSE_FLAG_LR_MODE : 0));
                if (err)
                        goto err_syncs;
 
-               if (xe_sync_is_ufence(&syncs[i]))
+               if (xe_sync_is_ufence(&syncs[num_syncs]))
                        num_ufence++;
        }
 
@@ -325,8 +325,8 @@ err_unlock_list:
        if (err == -EAGAIN && !skip_retry)
                goto retry;
 err_syncs:
-       for (i = 0; i < num_syncs; i++)
-               xe_sync_entry_cleanup(&syncs[i]);
+       while (num_syncs--)
+               xe_sync_entry_cleanup(&syncs[num_syncs]);
        kfree(syncs);
 err_exec_queue:
        xe_exec_queue_put(q);