Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Add missing runtime outer protection
@ 2024-05-29 21:56 Rodrigo Vivi
  2024-05-29 23:23 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Rodrigo Vivi @ 2024-05-29 21:56 UTC (permalink / raw)
  To: intel-xe; +Cc: Rodrigo Vivi, Paulo Zanoni, Francois Dugast,
	Thomas Hellström

TTM BO destroy is called unlocked as a ref count worker when it
gets 0 users. When that happens we could be runtime suspended,
and waking up from inner locked places like ggtt_remove_node,
could potentially lead to deadlocks. Our warning system against
this case hit this case:

[ 2295.891269] xe 0000:03:00.0: Missing outer runtime PM protection
[snip]
[ 2295.891604]  ? xe_pm_runtime_get_noresume+0x5c/0x70 [xe]
[ 2295.891717]  ? report_bug+0x18d/0x1c0
[ 2295.891722]  ? handle_bug+0x3c/0x80
[ 2295.891724]  ? exc_invalid_op+0x13/0x60
[ 2295.891726]  ? asm_exc_invalid_op+0x16/0x20
[ 2295.891730]  ? xe_pm_runtime_get_noresume+0x5c/0x70 [xe]
[ 2295.891816]  xe_ggtt_remove_node+0x93/0xf0 [xe]
[ 2295.891870]  xe_ttm_bo_destroy+0xe9/0xf0 [xe]
[ 2295.891935]  process_one_work+0x225/0x730
[ 2295.891940]  worker_thread+0x1d8/0x3c0

Add this outer protection to avoid any potential deadlock.

Reported-by: Paulo Zanoni <paulo.zanoni@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/xe/xe_bo.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 2bae01ce4e5b..a902f23bec0c 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1066,6 +1066,8 @@ static void xe_ttm_bo_destroy(struct ttm_buffer_object *ttm_bo)
 	struct xe_bo *bo = ttm_to_xe_bo(ttm_bo);
 	struct xe_device *xe = ttm_to_xe_device(ttm_bo->bdev);
 
+	xe_pm_runtime_get(xe);
+
 	if (bo->ttm.base.import_attach)
 		drm_prime_gem_destroy(&bo->ttm.base, NULL);
 	drm_gem_object_release(&bo->ttm.base);
@@ -1089,6 +1091,8 @@ static void xe_ttm_bo_destroy(struct ttm_buffer_object *ttm_bo)
 	mutex_unlock(&xe->mem_access.vram_userfault.lock);
 
 	kfree(bo);
+
+	xe_pm_runtime_put(xe);
 }
 
 static void xe_gem_object_free(struct drm_gem_object *obj)
-- 
2.45.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-05-30 10:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 21:56 [PATCH] drm/xe: Add missing runtime outer protection Rodrigo Vivi
2024-05-29 23:23 ` ✓ CI.Patch_applied: success for " Patchwork
2024-05-29 23:23 ` ✗ CI.checkpatch: warning " Patchwork
2024-05-29 23:24 ` ✓ CI.KUnit: success " Patchwork
2024-05-29 23:36 ` ✓ CI.Build: " Patchwork
2024-05-29 23:36 ` ✗ CI.Hooks: failure " Patchwork
2024-05-29 23:37 ` ✓ CI.checksparse: success " Patchwork
2024-05-30  0:01 ` ✓ CI.BAT: " Patchwork
2024-05-30  2:50 ` ✗ CI.FULL: failure " Patchwork
2024-05-30  5:42 ` [PATCH] " Matthew Brost
2024-05-30 10:09   ` Thomas Hellström

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox