Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/i915: reduce stack usage in igt_vma_pin1()

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>

authored by

Arnd Bergmann and committed by
Rodrigo Vivi
c3711610 ef69f9dd

+22 -20
+20
drivers/gpu/drm/i915/i915_vma.c
··· 1607 1607 return err; 1608 1608 } 1609 1609 1610 + int i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) 1611 + { 1612 + struct i915_gem_ww_ctx ww; 1613 + int err; 1614 + 1615 + i915_gem_ww_ctx_init(&ww, true); 1616 + retry: 1617 + err = i915_gem_object_lock(vma->obj, &ww); 1618 + if (!err) 1619 + err = i915_vma_pin_ww(vma, &ww, size, alignment, flags); 1620 + if (err == -EDEADLK) { 1621 + err = i915_gem_ww_ctx_backoff(&ww); 1622 + if (!err) 1623 + goto retry; 1624 + } 1625 + i915_gem_ww_ctx_fini(&ww); 1626 + 1627 + return err; 1628 + } 1629 + 1610 1630 static void flush_idle_contexts(struct intel_gt *gt) 1611 1631 { 1612 1632 struct intel_engine_cs *engine;
+2 -20
drivers/gpu/drm/i915/i915_vma.h
··· 289 289 i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww, 290 290 u64 size, u64 alignment, u64 flags); 291 291 292 - static inline int __must_check 293 - i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) 294 - { 295 - struct i915_gem_ww_ctx ww; 296 - int err; 297 - 298 - i915_gem_ww_ctx_init(&ww, true); 299 - retry: 300 - err = i915_gem_object_lock(vma->obj, &ww); 301 - if (!err) 302 - err = i915_vma_pin_ww(vma, &ww, size, alignment, flags); 303 - if (err == -EDEADLK) { 304 - err = i915_gem_ww_ctx_backoff(&ww); 305 - if (!err) 306 - goto retry; 307 - } 308 - i915_gem_ww_ctx_fini(&ww); 309 - 310 - return err; 311 - } 292 + int __must_check 293 + i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags); 312 294 313 295 int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww, 314 296 u32 align, unsigned int flags);