Re: [PATCH] amdgpu: lockdep: move temporary mutexes off stack
From: Christian König
Date: Thu Jun 11 2026 - 11:17:31 EST
On 6/11/26 15:02, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> 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.
>
> Fixes: 1d0f5838b126 ("drm/amdgpu: Add lockdep annotations for lock ordering validation")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
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.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c | 24 ++++++---------------
> 1 file changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
> index d5d71fd7c70d..cf723c9f9216 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
> @@ -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