* [PATCH] drm/xe/oa: Check managed mutex initialization errors
@ 2026-07-13 8:30 Linmao Li
2026-07-14 18:15 ` Umesh Nerlige Ramappa
0 siblings, 1 reply; 2+ messages in thread
From: Linmao Li @ 2026-07-13 8:30 UTC (permalink / raw)
To: Ashutosh Dixit, Matthew Brost, Thomas Hellström, Rodrigo Vivi
Cc: David Airlie, Simona Vetter, José Roberto de Souza,
Umesh Nerlige Ramappa, intel-xe, dri-devel, linux-kernel,
Linmao Li
drmm_mutex_init() can fail while registering its managed cleanup action.
On failure, the reset path destroys the mutex, so continuing OA setup
leaves an unusable lock that later paths may acquire.
Return the error from per-GT OA initialization and abort device-wide OA
initialization if the metrics lock cannot be initialized.
Fixes: a9f905ae7b6f ("drm/xe/oa/uapi: Initialize OA units")
Fixes: cdf02fe1a94a ("drm/xe/oa/uapi: Add/remove OA config perf ops")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
drivers/gpu/drm/xe/xe_oa.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index 2dce6a47202c..f3a0d5bf7894 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -2713,9 +2713,7 @@ static int xe_oa_init_gt(struct xe_gt *gt)
__xe_oa_init_oa_units(gt);
- drmm_mutex_init(>_to_xe(gt)->drm, >->oa.gt_lock);
-
- return 0;
+ return drmm_mutex_init(>_to_xe(gt)->drm, >->oa.gt_lock);
}
static void xe_oa_print_gt_oa_units(struct xe_gt *gt)
@@ -2855,7 +2853,10 @@ int xe_oa_init(struct xe_device *xe)
oa->xe = xe;
oa->oa_formats = oa_formats;
- drmm_mutex_init(&oa->xe->drm, &oa->metrics_lock);
+ ret = drmm_mutex_init(&oa->xe->drm, &oa->metrics_lock);
+ if (ret)
+ goto exit;
+
idr_init_base(&oa->metrics_idr, 1);
ret = xe_oa_init_oa_units(oa);
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/xe/oa: Check managed mutex initialization errors
2026-07-13 8:30 [PATCH] drm/xe/oa: Check managed mutex initialization errors Linmao Li
@ 2026-07-14 18:15 ` Umesh Nerlige Ramappa
0 siblings, 0 replies; 2+ messages in thread
From: Umesh Nerlige Ramappa @ 2026-07-14 18:15 UTC (permalink / raw)
To: Linmao Li
Cc: Ashutosh Dixit, Matthew Brost, Thomas Hellström,
Rodrigo Vivi, David Airlie, Simona Vetter,
José Roberto de Souza, intel-xe, dri-devel, linux-kernel
On Mon, Jul 13, 2026 at 04:30:53PM +0800, Linmao Li wrote:
>drmm_mutex_init() can fail while registering its managed cleanup action.
>On failure, the reset path destroys the mutex, so continuing OA setup
>leaves an unusable lock that later paths may acquire.
>
>Return the error from per-GT OA initialization and abort device-wide OA
>initialization if the metrics lock cannot be initialized.
>
>Fixes: a9f905ae7b6f ("drm/xe/oa/uapi: Initialize OA units")
>Fixes: cdf02fe1a94a ("drm/xe/oa/uapi: Add/remove OA config perf ops")
>Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Thanks for addressing this. LGTM,
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>---
> drivers/gpu/drm/xe/xe_oa.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
>index 2dce6a47202c..f3a0d5bf7894 100644
>--- a/drivers/gpu/drm/xe/xe_oa.c
>+++ b/drivers/gpu/drm/xe/xe_oa.c
>@@ -2713,9 +2713,7 @@ static int xe_oa_init_gt(struct xe_gt *gt)
>
> __xe_oa_init_oa_units(gt);
>
>- drmm_mutex_init(>_to_xe(gt)->drm, >->oa.gt_lock);
>-
>- return 0;
>+ return drmm_mutex_init(>_to_xe(gt)->drm, >->oa.gt_lock);
> }
>
> static void xe_oa_print_gt_oa_units(struct xe_gt *gt)
>@@ -2855,7 +2853,10 @@ int xe_oa_init(struct xe_device *xe)
> oa->xe = xe;
> oa->oa_formats = oa_formats;
>
>- drmm_mutex_init(&oa->xe->drm, &oa->metrics_lock);
>+ ret = drmm_mutex_init(&oa->xe->drm, &oa->metrics_lock);
>+ if (ret)
>+ goto exit;
>+
> idr_init_base(&oa->metrics_idr, 1);
>
> ret = xe_oa_init_oa_units(oa);
>--
>2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-14 18:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 8:30 [PATCH] drm/xe/oa: Check managed mutex initialization errors Linmao Li
2026-07-14 18:15 ` Umesh Nerlige Ramappa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®