]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/xe: Move VM dma-resv lock from xe_exec_queue_create to __xe_exec_queue_init
authorMatthew Brost <matthew.brost@intel.com>
Wed, 24 Jul 2024 15:28:31 +0000 (08:28 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Mon, 19 Aug 2024 14:39:04 +0000 (10:39 -0400)
The critical section which requires the VM dma-resv is the call
xe_lrc_create in __xe_exec_queue_init. Move this lock to
__xe_exec_queue_init holding it just around xe_lrc_create. Not only is
good practice, this also fixes a locking double of the VM dma-resv in
the error paths of __xe_exec_queue_init as xe_lrc_put tries to acquire
this too resulting in a deadlock.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240724152831.1848325-1-matthew.brost@intel.com
(cherry picked from commit 549dd786b61cd3db903f5d94d07fc5a89ccdbeb9)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_exec_queue.c

index a39384bb9553ffbc2e4e9fb2c31b1b7c7df89c14..16f24f4a7062d8cc51fb1bc8c850e9d2f386b958 100644 (file)
@@ -105,22 +105,35 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
 
 static int __xe_exec_queue_init(struct xe_exec_queue *q)
 {
+       struct xe_vm *vm = q->vm;
        int i, err;
 
+       if (vm) {
+               err = xe_vm_lock(vm, true);
+               if (err)
+                       return err;
+       }
+
        for (i = 0; i < q->width; ++i) {
                q->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K);
                if (IS_ERR(q->lrc[i])) {
                        err = PTR_ERR(q->lrc[i]);
-                       goto err_lrc;
+                       goto err_unlock;
                }
        }
 
+       if (vm)
+               xe_vm_unlock(vm);
+
        err = q->ops->init(q);
        if (err)
                goto err_lrc;
 
        return 0;
 
+err_unlock:
+       if (vm)
+               xe_vm_unlock(vm);
 err_lrc:
        for (i = i - 1; i >= 0; --i)
                xe_lrc_put(q->lrc[i]);
@@ -140,15 +153,7 @@ struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *v
        if (IS_ERR(q))
                return q;
 
-       if (vm) {
-               err = xe_vm_lock(vm, true);
-               if (err)
-                       goto err_post_alloc;
-       }
-
        err = __xe_exec_queue_init(q);
-       if (vm)
-               xe_vm_unlock(vm);
        if (err)
                goto err_post_alloc;