]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915: reduce stack usage in igt_vma_pin1()
authorArnd Bergmann <arnd@arndb.de>
Fri, 20 Jun 2025 11:36:38 +0000 (13:36 +0200)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 24 Jun 2025 21:23:02 +0000 (17:23 -0400)
The igt_vma_pin1() function has a rather high stack usage, which gets
in the way of reducing the default warning limit:

In file included from drivers/gpu/drm/i915/i915_vma.c:2285:
drivers/gpu/drm/i915/selftests/i915_vma.c:257:12: error: stack frame size (1288) exceeds limit (1280) in 'igt_vma_pin1' [-Werror,-Wframe-larger-than]

There are two things going on here:

 - The on-stack modes[] array is really large itself and gets constructed
   for every call, using around 1000 bytes itself depending on the configuration.

 - The call to i915_vma_pin() gets inlined and adds another 200 bytes for
   the i915_gem_ww_ctx structure since commit 7d1c2618eac5 ("drm/i915: Take
   reservation lock around i915_vma_pin.")

The second one is easy enough to change, by moving the function into the
appropriate .c file. Since it is already large enough to not always be
inlined, this seems like a good idea regardless, reducing both the code size
and the internal stack usage of each of its 67 callers.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250620113644.3844552-1-arnd@kernel.org
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/i915_vma.h

index 632e316f8b0522243a32f7e80924806a6ffe6227..25e97031d76e46c94c3c0da316a6894e772762eb 100644 (file)
@@ -1607,6 +1607,26 @@ err_rpm:
        return err;
 }
 
+int i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
+{
+       struct i915_gem_ww_ctx ww;
+       int err;
+
+       i915_gem_ww_ctx_init(&ww, true);
+retry:
+       err = i915_gem_object_lock(vma->obj, &ww);
+       if (!err)
+               err = i915_vma_pin_ww(vma, &ww, size, alignment, flags);
+       if (err == -EDEADLK) {
+               err = i915_gem_ww_ctx_backoff(&ww);
+               if (!err)
+                       goto retry;
+       }
+       i915_gem_ww_ctx_fini(&ww);
+
+       return err;
+}
+
 static void flush_idle_contexts(struct intel_gt *gt)
 {
        struct intel_engine_cs *engine;
index 6a6be8048aa83f8d1fcd4b43855f1b24bdc790f5..14ccbd0636bba662c5b614d39afa7d465b366e67 100644 (file)
@@ -289,26 +289,8 @@ int __must_check
 i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
                u64 size, u64 alignment, u64 flags);
 
-static inline int __must_check
-i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
-{
-       struct i915_gem_ww_ctx ww;
-       int err;
-
-       i915_gem_ww_ctx_init(&ww, true);
-retry:
-       err = i915_gem_object_lock(vma->obj, &ww);
-       if (!err)
-               err = i915_vma_pin_ww(vma, &ww, size, alignment, flags);
-       if (err == -EDEADLK) {
-               err = i915_gem_ww_ctx_backoff(&ww);
-               if (!err)
-                       goto retry;
-       }
-       i915_gem_ww_ctx_fini(&ww);
-
-       return err;
-}
+int __must_check
+i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags);
 
 int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
                  u32 align, unsigned int flags);