Skip to content

Commit cc565d3

Browse files
Danilo Krummrichjannau
authored andcommitted
drm/test: drm_exec: use kzalloc() to allocate GEM objects
Since commit e7fa80e ("drm_gem: add mutex to drm_gem_object.gpuva") it is possible for test_prepare_array() to exceed a stack frame size of 2048 bytes depending on the exact configuration of the kernel. drivers/gpu/drm/tests/drm_exec_test.c: In function ‘test_prepare_array’: drivers/gpu/drm/tests/drm_exec_test.c:171:1: error: the frame size of 2128 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] 171 | } | ^ cc1: all warnings being treated as errors make[6]: *** [scripts/Makefile.build:287: drivers/gpu/drm/tests/drm_exec_test.o] Error 1 make[6]: *** Waiting for unfinished jobs.... In order to fix this, allocate the GEM objects in test_prepare_array() with kzalloc(), rather than placing them on the stack. Cc: Alice Ryhl <aliceryhl@google.com> Cc: Christian König <christian.koenig@amd.com> Fixes: e7fa80e ("drm_gem: add mutex to drm_gem_object.gpuva") Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Nirmoy Das <nirmoyd@nvidia.com> Link: https://lore.kernel.org/r/20250829075633.2306-1-dakr@kernel.org [ Use kunit_kzalloc() instead of kzalloc(). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent 5473790 commit cc565d3

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

drivers/gpu/drm/tests/drm_exec_test.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,22 @@ static void test_prepare(struct kunit *test)
150150
static void test_prepare_array(struct kunit *test)
151151
{
152152
struct drm_exec_priv *priv = test->priv;
153-
struct drm_gem_object gobj1 = { };
154-
struct drm_gem_object gobj2 = { };
155-
struct drm_gem_object *array[] = { &gobj1, &gobj2 };
153+
struct drm_gem_object *gobj1;
154+
struct drm_gem_object *gobj2;
155+
struct drm_gem_object *array[] = {
156+
(gobj1 = kunit_kzalloc(test, sizeof(*gobj1), GFP_KERNEL)),
157+
(gobj2 = kunit_kzalloc(test, sizeof(*gobj2), GFP_KERNEL)),
158+
};
156159
struct drm_exec exec;
157160
int ret;
158161

159-
drm_gem_private_object_init(priv->drm, &gobj1, PAGE_SIZE);
160-
drm_gem_private_object_init(priv->drm, &gobj2, PAGE_SIZE);
162+
if (!gobj1 || !gobj2) {
163+
KUNIT_FAIL(test, "Failed to allocate GEM objects.\n");
164+
return;
165+
}
166+
167+
drm_gem_private_object_init(priv->drm, gobj1, PAGE_SIZE);
168+
drm_gem_private_object_init(priv->drm, gobj2, PAGE_SIZE);
161169

162170
drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0);
163171
drm_exec_until_all_locked(&exec)
@@ -166,8 +174,8 @@ static void test_prepare_array(struct kunit *test)
166174
KUNIT_EXPECT_EQ(test, ret, 0);
167175
drm_exec_fini(&exec);
168176

169-
drm_gem_private_object_fini(&gobj1);
170-
drm_gem_private_object_fini(&gobj2);
177+
drm_gem_private_object_fini(gobj1);
178+
drm_gem_private_object_fini(gobj2);
171179
}
172180

173181
static void test_multiple_loops(struct kunit *test)

0 commit comments

Comments
 (0)