Skip to content

Commit c371161

Browse files
arndbrodrigovivi
authored andcommitted
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 7d1c261 ("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 <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent ef69f9d commit c371161

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

drivers/gpu/drm/i915/i915_vma.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,26 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
16071607
return err;
16081608
}
16091609

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+
16101630
static void flush_idle_contexts(struct intel_gt *gt)
16111631
{
16121632
struct intel_engine_cs *engine;

drivers/gpu/drm/i915/i915_vma.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -289,26 +289,8 @@ int __must_check
289289
i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
290290
u64 size, u64 alignment, u64 flags);
291291

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);
312294

313295
int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
314296
u32 align, unsigned int flags);

0 commit comments

Comments
 (0)