Skip to content

Commit 9e3c85d

Browse files
mbrost05lucasdemarchi
authored andcommitted
drm/xe: Clean up VM / exec queue file lock usage.
Both the VM / exec queue file lock protect the lookup and reference to the object, nothing more. These locks are not intended anything else underneath them. XA have their own locking too, so no need to take the VM / exec queue file lock aside from when doing a lookup and reference get. Add some kernel doc to make this clear and cleanup a few typos too. Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit fe4f5d4) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 1b30f87 commit 9e3c85d

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

drivers/gpu/drm/xe/xe_device.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,8 @@ static void xe_file_close(struct drm_device *dev, struct drm_file *file)
171171
xe_exec_queue_kill(q);
172172
xe_exec_queue_put(q);
173173
}
174-
mutex_lock(&xef->vm.lock);
175174
xa_for_each(&xef->vm.xa, idx, vm)
176175
xe_vm_close_and_put(vm);
177-
mutex_unlock(&xef->vm.lock);
178176

179177
xe_file_put(xef);
180178

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,15 +570,23 @@ struct xe_file {
570570
struct {
571571
/** @vm.xe: xarray to store VMs */
572572
struct xarray xa;
573-
/** @vm.lock: protects file VM state */
573+
/**
574+
* @vm.lock: Protects VM lookup + reference and removal a from
575+
* file xarray. Not an intended to be an outer lock which does
576+
* thing while being held.
577+
*/
574578
struct mutex lock;
575579
} vm;
576580

577581
/** @exec_queue: Submission exec queue state for file */
578582
struct {
579-
/** @exec_queue.xe: xarray to store engines */
583+
/** @exec_queue.xa: xarray to store exece queues */
580584
struct xarray xa;
581-
/** @exec_queue.lock: protects file engine state */
585+
/**
586+
* @exec_queue.lock: Protects exec queue lookup + reference and
587+
* removal a frommfile xarray. Not an intended to be an outer
588+
* lock which does thing while being held.
589+
*/
582590
struct mutex lock;
583591
} exec_queue;
584592

drivers/gpu/drm/xe/xe_drm_client.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,15 @@ static void show_run_ticks(struct drm_printer *p, struct drm_file *file)
283283

284284
/* Accumulate all the exec queues from this client */
285285
mutex_lock(&xef->exec_queue.lock);
286-
xa_for_each(&xef->exec_queue.xa, i, q)
286+
xa_for_each(&xef->exec_queue.xa, i, q) {
287+
xe_exec_queue_get(q);
288+
mutex_unlock(&xef->exec_queue.lock);
289+
287290
xe_exec_queue_update_run_ticks(q);
291+
292+
mutex_lock(&xef->exec_queue.lock);
293+
xe_exec_queue_put(q);
294+
}
288295
mutex_unlock(&xef->exec_queue.lock);
289296

290297
/* Get the total GPU cycles */

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,7 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
635635
}
636636
}
637637

638-
mutex_lock(&xef->exec_queue.lock);
639638
err = xa_alloc(&xef->exec_queue.xa, &id, q, xa_limit_32b, GFP_KERNEL);
640-
mutex_unlock(&xef->exec_queue.lock);
641639
if (err)
642640
goto kill_exec_queue;
643641

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,9 +1765,7 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
17651765
if (IS_ERR(vm))
17661766
return PTR_ERR(vm);
17671767

1768-
mutex_lock(&xef->vm.lock);
17691768
err = xa_alloc(&xef->vm.xa, &id, vm, xa_limit_32b, GFP_KERNEL);
1770-
mutex_unlock(&xef->vm.lock);
17711769
if (err)
17721770
goto err_close_and_put;
17731771

@@ -1799,9 +1797,7 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
17991797
return 0;
18001798

18011799
err_free_id:
1802-
mutex_lock(&xef->vm.lock);
18031800
xa_erase(&xef->vm.xa, id);
1804-
mutex_unlock(&xef->vm.lock);
18051801
err_close_and_put:
18061802
xe_vm_close_and_put(vm);
18071803

0 commit comments

Comments
 (0)