drm/xe/bo: Fix async BO free teardown deadlock
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | drm/xe/bo: Fix self-flush deadlock in async BO freedrivers/ | +19 | 0 replies | |
| 2/2 | drm/xe/bo: Queue async BO free on the module-lifetime destroy wqdrivers/ drivers/ drivers/ | +6 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] drm/xe/bo: Fix async BO free teardown deadlock
The async BO free worker can drop the last drm_device reference when freeing a page-table BO (BO -> VM -> drm_gpuvm_free() -> drm_dev_put()). Device teardown then runs from the worker and xe_bo_dev_fini() flushes the work it is running on, deadlocking.
WARNING: possible recursive locking detected
kworker/7:0/50249 is trying to acquire lock:
((work_completion)(&bo_dev->async_free)), at: __flush_work+0x25d/0x640 but task is already holding lock:
((work_completion)(&bo_dev->async_free)), at: process_one_work+0x26d/0x890
...
Workqueue: events xe_bo_dev_work_func [xe] Call Trace: flush_work+0x2d/0x40 xe_bo_dev_fini+0xe/0x20 [xe] xe_device_destroy+0x19/0xa0 [xe] drm_managed_release+0x8b/0x170 drm_dev_put+0x69/0x90 drm_gpuvm_free+0xc2/0x2e0 [drm_gpuvm] drm_gpuvm_put+0x48/0x80 [drm_gpuvm] xe_ttm_bo_destroy+0xfa/0x320 [xe] ttm_bo_release+0x70/0x310 [ttm] ttm_bo_fini+0x3c/0x70 [ttm] xe_gem_object_free+0x1a/0x30 [xe] drm_gem_object_free+0x1d/0x40 xe_bo_dev_work_func+0x3a/0x60 [xe] process_one_work+0x2ad/0x890 worker_thread+0x200/0x3f0
Patch 1 fixes the deadlock by holding a device reference in the worker and not self-flushing from xe_bo_dev_fini().
Patch 2 moves the work to the module-lifetime xe_destroy_wq, so module unload cannot free the xe text while the worker is still finishing a teardown it triggered.
Sanjay Yadav (2):
drm/xe/bo: Fix self-flush deadlock in async BO free drm/xe/bo: Queue async BO free on the module-lifetime destroy wq
drivers/gpu/drm/xe/xe_bo.c | 20 +++++++++++++++++++- drivers/gpu/drm/xe/xe_bo.h | 3 ++- drivers/gpu/drm/xe/xe_module.c | 5 +++-- drivers/gpu/drm/xe/xe_pt.c | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-)
Signature · 1 line
2.52.0