From: Matthew Brost <matthew.brost@intel.com>
To: Shuicheng Lin <shuicheng.lin@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <stuart.summers@intel.com>
Subject: Re: [PATCH] drm/xe/guc: Register CT fini action before mutex init
Date: Tue, 4 Nov 2025 14:29:37 -0800 [thread overview]
Message-ID: <aQp+UTmOHkP0OB4l@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20251104221613.795865-2-shuicheng.lin@intel.com>
On Tue, Nov 04, 2025 at 10:16:14PM +0000, Shuicheng Lin wrote:
> 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.
destroy_workqueue in guc_ct_fini can flush the workqueue which does take
ct lock. So I think the correct flow here is at the top of
xe_guc_ct_init_noalloc do the drmm_mutex_init, then initialize all CT
state, then register guc_ct_fini.
Matt
>
> 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
>
next prev parent reply other threads:[~2025-11-04 22:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=aQp+UTmOHkP0OB4l@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=shuicheng.lin@intel.com \
--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