Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/guc: Register CT fini action before mutex init
@ 2025-11-04 22:16 Shuicheng Lin
  2025-11-04 22:29 ` Matthew Brost
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Shuicheng Lin @ 2025-11-04 22:16 UTC (permalink / raw)
  To: intel-xe; +Cc: stuart.summers, Shuicheng Lin

xe_guc_ct_init_noalloc() allocates the CT workqueue and other helpers
before it tries to initialize ct->lock. If drmm_mutex_init() fails
we currently bail out without releasing those resources because the
guc_ct_fini() hasn’t been registered yet. Move the drmm_add_action_or_reset()
call ahead of the mutex setup so that the devres unwinder tears everything
down on the error path. This is safe because guc_ct_fini() never
touches ct->lock.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_ct.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
index 671d69958ce7..2680e9096c15 100644
--- a/drivers/gpu/drm/xe/xe_guc_ct.c
+++ b/drivers/gpu/drm/xe/xe_guc_ct.c
@@ -240,16 +240,16 @@ int xe_guc_ct_init_noalloc(struct xe_guc_ct *ct)
 	init_waitqueue_head(&ct->wq);
 	init_waitqueue_head(&ct->g2h_fence_wq);
 
-	err = drmm_mutex_init(&xe->drm, &ct->lock);
+	err = drmm_add_action_or_reset(&xe->drm, guc_ct_fini, ct);
 	if (err)
 		return err;
 
-	primelockdep(ct);
-
-	err = drmm_add_action_or_reset(&xe->drm, guc_ct_fini, ct);
+	err = drmm_mutex_init(&xe->drm, &ct->lock);
 	if (err)
 		return err;
 
+	primelockdep(ct);
+
 	xe_gt_assert(gt, ct->state == XE_GUC_CT_STATE_NOT_INITIALIZED);
 	ct->state = XE_GUC_CT_STATE_DISABLED;
 	return 0;
-- 
2.49.0


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

end of thread, other threads:[~2025-11-21 16:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 22:16 [PATCH] drm/xe/guc: Register CT fini action before mutex init Shuicheng Lin
2025-11-04 22:29 ` Matthew Brost
2025-11-05 20:14   ` Lucas De Marchi
2025-11-04 23:37 ` [PATCH v2] drm/xe/guc: Fix resource leak in xe_guc_ct_init_noalloc() Shuicheng Lin
2025-11-05  5:02 ` ✓ CI.KUnit: success for drm/xe/guc: Register CT fini action before mutex init (rev2) Patchwork
2025-11-05  6:24 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-05 12:12 ` ✓ Xe.CI.Full: " Patchwork
2025-11-10 18:45 ` [PATCH v3] drm/xe/guc: Fix resource leak in xe_guc_ct_init_noalloc() Shuicheng Lin
2025-11-10 19:45   ` Lucas De Marchi
2025-11-20 17:03     ` Lin, Shuicheng
2025-11-21 16:47   ` Lucas De Marchi
2025-11-10 19:01 ` ✓ CI.KUnit: success for drm/xe/guc: Register CT fini action before mutex init (rev3) Patchwork
2025-11-10 19:56 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-11  1:29 ` ✗ Xe.CI.Full: failure " Patchwork

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