Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shuicheng Lin <shuicheng.lin@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: stuart.summers@intel.com, Shuicheng Lin <shuicheng.lin@intel.com>
Subject: [PATCH] drm/xe/guc: Register CT fini action before mutex init
Date: Tue,  4 Nov 2025 22:16:14 +0000	[thread overview]
Message-ID: <20251104221613.795865-2-shuicheng.lin@intel.com> (raw)

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


             reply	other threads:[~2025-11-04 22:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04 22:16 Shuicheng Lin [this message]
2025-11-04 22:29 ` [PATCH] drm/xe/guc: Register CT fini action before mutex init 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251104221613.795865-2-shuicheng.lin@intel.com \
    --to=shuicheng.lin@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=stuart.summers@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox