Skip to content

Commit 7090d7f

Browse files
mbrost05rodrigovivi
authored andcommitted
drm/xe: Move VM dma-resv lock from xe_exec_queue_create to __xe_exec_queue_init
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: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: Maarten Lankhorst <[email protected]> Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 549dd78) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent c621f70 commit 7090d7f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,35 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
105105

106106
static int __xe_exec_queue_init(struct xe_exec_queue *q)
107107
{
108+
struct xe_vm *vm = q->vm;
108109
int i, err;
109110

111+
if (vm) {
112+
err = xe_vm_lock(vm, true);
113+
if (err)
114+
return err;
115+
}
116+
110117
for (i = 0; i < q->width; ++i) {
111118
q->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K);
112119
if (IS_ERR(q->lrc[i])) {
113120
err = PTR_ERR(q->lrc[i]);
114-
goto err_lrc;
121+
goto err_unlock;
115122
}
116123
}
117124

125+
if (vm)
126+
xe_vm_unlock(vm);
127+
118128
err = q->ops->init(q);
119129
if (err)
120130
goto err_lrc;
121131

122132
return 0;
123133

134+
err_unlock:
135+
if (vm)
136+
xe_vm_unlock(vm);
124137
err_lrc:
125138
for (i = i - 1; i >= 0; --i)
126139
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
140153
if (IS_ERR(q))
141154
return q;
142155

143-
if (vm) {
144-
err = xe_vm_lock(vm, true);
145-
if (err)
146-
goto err_post_alloc;
147-
}
148-
149156
err = __xe_exec_queue_init(q);
150-
if (vm)
151-
xe_vm_unlock(vm);
152157
if (err)
153158
goto err_post_alloc;
154159

0 commit comments

Comments
 (0)