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.

Fixes: 1d0f5838b126 ("drm/amdgpu: Add lockdep annotations for lock ordering 
validation")
Signed-off-by: Arnd Bergmann <[email protected]>
---
 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(&notifier_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
-- 
2.39.5

Reply via email to