amdgpu: lockdep: move temporary mutexes off stack
Subsystems (2)
PATCH 1/1 amdgpu: lockdep: move temporary mutexes off stack
From: Arnd Bergmann <[email protected]>
In randconfig builds, the newly added function frequently exceeds the limit for stack frames, like:
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c:84:5: error: stack frame size (1312) exceeds limit (1280) in 'amdgpu_lockdep_init' [-Werror,-Wframe-larger-than]
Change this to use static allocation for the locks to reduce this at the expense of a slightly larger driver binary.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c | 24 ++++++--------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c +7 -17
@@ -85,13 +85,13 @@ int amdgpu_lockdep_init(void) {struct amdgpu_reset_domain *reset_domain =NULL ;struct amdgpu_reset_control reset_ctl; -struct mutex userq_sch_mutex; -struct mutex userq_mutex; -struct mutex notifier_lock; -struct mutex vram_lock; -struct mutex srbm_mutex; -struct mutex grbm_idx_mutex; -spinlock_t mmio_idx_lock; +static DEFINE_MUTEX (userq_sch_mutex); +static DEFINE_MUTEX (userq_mutex); +static DEFINE_MUTEX (notifier_lock); +static DEFINE_MUTEX (vram_lock); +static DEFINE_MUTEX (srbm_mutex); +static DEFINE_MUTEX (grbm_idx_mutex); +static DEFINE_SPINLOCK (mmio_idx_lock);unsigned long flags;/*
@@ -102,16 +102,6 @@ int amdgpu_lockdep_init(void)if (!reset_domain)return -ENOMEM ; -/* Initialize dummy locks */ -mutex_init (&userq_sch_mutex); -mutex_init (&userq_mutex); -mutex_init (¬ifier_lock); -mutex_init (&vram_lock); -mutex_init (&reset_ctl.reset_lock); -mutex_init (&srbm_mutex); -mutex_init (&grbm_idx_mutex); -spin_lock_init (&mmio_idx_lock); -/* * Associate dummy locks with the same class keys used for real * driver locks. This ensures lockdep connects the ordering learned
Signature · 1 line
2.39.5
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The `reset_ctl.reset_lock` mutex is left uninitialized after the removal of its `mutex_init()`…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The reset_ctl.reset_lock mutex is left uninitialized after the removal of its mutex_init() call, leading to a crash or lockdep splat when mutex_lock() is subsequently called on it. --
commit 6434ae76184d0a8413780553647c7fd53034416b
Author: Arnd Bergmann <[email protected]>
amdgpu: lockdep: move temporary mutexes off stack
This commit changes the dummy locks in amdgpu_lockdep_init() to use static allocation instead of stack allocation to reduce the stack frame size. It removes the explicit mutex_init() calls for these locks.
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c +0
-0@@ -85,13 +85,13 @@ int amdgpu_lockdep_init(void) {struct amdgpu_reset_domain *reset_domain =NULL ;struct amdgpu_reset_control reset_ctl;
[ ... ]
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c int amdgpu_lockdep_init(void) · line 110
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c +0
-6@@ -102,16 +102,6 @@ int amdgpu_lockdep_init(void)if (!reset_domain)return -ENOMEM ; -/* Initialize dummy locks */ -mutex_init (&userq_sch_mutex); -mutex_init (&userq_mutex); -mutex_init (¬ifier_lock); -mutex_init (&vram_lock); -mutex_init (&reset_ctl.reset_lock);
[Severity: High]
With this initialization removed, does reset_ctl.reset_lock remain uninitialized?
Since reset_ctl is still allocated on the stack earlier in the function, calling mutex_lock(&reset_ctl.reset_lock) later in this routine will operate on uninitialized memory. Could this trigger a crash or lockdep splat?
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c +0
-3-mutex_init (&srbm_mutex); -mutex_init (&grbm_idx_mutex); -spin_lock_init (&mmio_idx_lock);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 5 lines · On Thu, Jun 11, 2026, at 15:08, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Thereset_ctl.reset_lockmutex is left uninitialized after the removal of itsmutex_init()call, leading to a crash or lockdep splat whenmutex_lock()is subsequently called on it.
The initialization in part of 'static DEFINE_MUTEX()'.
Arnd
Christian König
maintainerQuoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
In randconfig builds, the newly added function frequently exceeds the limit for stack frames, like:
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c:84:5: error: stack frame size (1312) exceeds limit (1280) in 'amdgpu_lockdep_init' [-Werror,-Wframe-larger-than]Change this to use static allocation for the locks to reduce this at the expense of a slightly larger driver binary.
Fixes 1d0f5838b126 ("drm/amdgpu: Add lockdep annotations for lock ordering validation")Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the patch, but we already found that one internally as well.
It's just that Alex is on vacation this week and so the fix was not in some pull request yet.
Should go upstream before the end of next week.
Regards,
Christian.
Quoted 46 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c | 24 ++++++--------------- 1 file changed, 7 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c +7
-17@@ -85,13 +85,13 @@ int amdgpu_lockdep_init(void) {struct amdgpu_reset_domain *reset_domain =NULL ;struct amdgpu_reset_control reset_ctl; -struct mutex userq_sch_mutex; -struct mutex userq_mutex; -struct mutex notifier_lock; -struct mutex vram_lock; -struct mutex srbm_mutex; -struct mutex grbm_idx_mutex; -spinlock_t mmio_idx_lock; +static DEFINE_MUTEX (userq_sch_mutex); +static DEFINE_MUTEX (userq_mutex); +static DEFINE_MUTEX (notifier_lock); +static DEFINE_MUTEX (vram_lock); +static DEFINE_MUTEX (srbm_mutex); +static DEFINE_MUTEX (grbm_idx_mutex); +static DEFINE_SPINLOCK (mmio_idx_lock);unsigned long flags;/* @@ -102,16 +102,6 @@ int amdgpu_lockdep_init(void)if (!reset_domain)return -ENOMEM ; -/* Initialize dummy locks */ -mutex_init (&userq_sch_mutex); -mutex_init (&userq_mutex); -mutex_init (¬ifier_lock); -mutex_init (&vram_lock); -mutex_init (&reset_ctl.reset_lock); -mutex_init (&srbm_mutex); -mutex_init (&grbm_idx_mutex); -spin_lock_init (&mmio_idx_lock); -/* * Associate dummy locks with the same class keys used for real * driver locks. This ensures lockdep connects the ordering learned