[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220828182543.155415-1-mairacanal@riseup.net>
Date: Sun, 28 Aug 2022 15:25:43 -0300
From: Maíra Canal <mairacanal@...eup.net>
To: Isabella Basso <isabbasso@...eup.net>, magalilemes00@...il.com,
tales.aparecida@...il.com, mwen@...lia.com, andrealmeid@...eup.net,
siqueirajordao@...eup.net, Trevor Woerner <twoerner@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...ux.ie>,
Javier Martinez Canillas <javierm@...hat.com>,
David Gow <davidgow@...gle.com>, brendanhiggins@...gle.com,
Arthur Grillo <arthur.grillo@....br>
Cc: kunit-dev@...glegroups.com, linux-kselftest@...r.kernel.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Maíra Canal <mairacanal@...eup.net>,
kernel test robot <lkp@...el.com>
Subject: [PATCH] drm/mm: Reduce stack frame usage in __igt_reserve
The struct drm_mm is being allocated on the stack, which is causing the
following -Wframe-larger-than warning on ARM:
../drivers/gpu/drm/tests/drm_mm_test.c:344:12: error: stack frame size
(1064) exceeds limit (1024) in '__igt_reserve' [-Werror,-Wframe-larger-than]
static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
^
1 error generated.
So, fix this warning by dynamically allocating the struct drm_mm.
Fixes: fc8d29e298cf ("drm: selftest: convert drm_mm selftest to KUnit")
Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: Maíra Canal <mairacanal@...eup.net>
---
drivers/gpu/drm/tests/drm_mm_test.c | 33 ++++++++++++++++-------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/tests/drm_mm_test.c b/drivers/gpu/drm/tests/drm_mm_test.c
index 1e2c1aa524bd..fbd8dcbc12ee 100644
--- a/drivers/gpu/drm/tests/drm_mm_test.c
+++ b/drivers/gpu/drm/tests/drm_mm_test.c
@@ -344,7 +344,7 @@ static bool check_reserve_boundaries(struct kunit *test, struct drm_mm *mm,
static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
{
DRM_RND_STATE(prng, random_seed);
- struct drm_mm mm;
+ struct drm_mm *mm;
struct drm_mm_node tmp, *nodes, *node, *next;
unsigned int *order, n, m, o = 0;
int ret, err;
@@ -366,17 +366,20 @@ static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
nodes = vzalloc(array_size(count, sizeof(*nodes)));
KUNIT_ASSERT_TRUE(test, nodes);
+ mm = kunit_kzalloc(test, sizeof(struct drm_mm), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, mm);
+
ret = -EINVAL;
- drm_mm_init(&mm, 0, count * size);
+ drm_mm_init(mm, 0, count * size);
- if (!check_reserve_boundaries(test, &mm, count, size))
+ if (!check_reserve_boundaries(test, mm, count, size))
goto out;
for (n = 0; n < count; n++) {
nodes[n].start = order[n] * size;
nodes[n].size = size;
- err = drm_mm_reserve_node(&mm, &nodes[n]);
+ err = drm_mm_reserve_node(mm, &nodes[n]);
if (err) {
KUNIT_FAIL(test, "reserve failed, step %d, start %llu\n",
n, nodes[n].start);
@@ -390,23 +393,23 @@ static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
goto out;
}
- if (!expect_reserve_fail(test, &mm, &nodes[n]))
+ if (!expect_reserve_fail(test, mm, &nodes[n]))
goto out;
}
/* After random insertion the nodes should be in order */
- if (!assert_continuous(test, &mm, size))
+ if (!assert_continuous(test, mm, size))
goto out;
/* Repeated use should then fail */
drm_random_reorder(order, count, &prng);
for (n = 0; n < count; n++) {
- if (!expect_reserve_fail(test, &mm, set_node(&tmp, order[n] * size, 1)))
+ if (!expect_reserve_fail(test, mm, set_node(&tmp, order[n] * size, 1)))
goto out;
/* Remove and reinsert should work */
drm_mm_remove_node(&nodes[order[n]]);
- err = drm_mm_reserve_node(&mm, &nodes[order[n]]);
+ err = drm_mm_reserve_node(mm, &nodes[order[n]]);
if (err) {
KUNIT_FAIL(test, "reserve failed, step %d, start %llu\n",
n, nodes[n].start);
@@ -415,16 +418,16 @@ static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
}
}
- if (!assert_continuous(test, &mm, size))
+ if (!assert_continuous(test, mm, size))
goto out;
/* Overlapping use should then fail */
for (n = 0; n < count; n++) {
- if (!expect_reserve_fail(test, &mm, set_node(&tmp, 0, size * count)))
+ if (!expect_reserve_fail(test, mm, set_node(&tmp, 0, size * count)))
goto out;
}
for (n = 0; n < count; n++) {
- if (!expect_reserve_fail(test, &mm, set_node(&tmp, size * n, size * (count - n))))
+ if (!expect_reserve_fail(test, mm, set_node(&tmp, size * n, size * (count - n))))
goto out;
}
@@ -437,7 +440,7 @@ static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
for (m = 0; m < n; m++) {
node = &nodes[order[(o + m) % count]];
- err = drm_mm_reserve_node(&mm, node);
+ err = drm_mm_reserve_node(mm, node);
if (err) {
KUNIT_FAIL(test, "reserve failed, step %d/%d, start %llu\n",
m, n, node->start);
@@ -448,15 +451,15 @@ static int __igt_reserve(struct kunit *test, unsigned int count, u64 size)
o += n;
- if (!assert_continuous(test, &mm, size))
+ if (!assert_continuous(test, mm, size))
goto out;
}
ret = 0;
out:
- drm_mm_for_each_node_safe(node, next, &mm)
+ drm_mm_for_each_node_safe(node, next, mm)
drm_mm_remove_node(node);
- drm_mm_takedown(&mm);
+ drm_mm_takedown(mm);
vfree(nodes);
kfree(order);
err:
--
2.37.2
Powered by blists - more mailing lists