Skip to content

Commit 3a41506

Browse files
committed
drm/vc4: tests: Patch up the vc4 kunit tests
Commit [1] removed the dynamic allocation of drm_modeset_acquire_ctx structures, with clients expected to allocate them by other means, such as on the stack. This usage model works less well when tests are split into separate initialisation and run phases, because a ctx allocated on the stack in the init function will go out of scope and likely be overwritten by the run function(s). As kunit tests seem to be single threaded, make ctx static to avoid the issue. [1] commit 30188df ("drm/tests: Drop drm_kunit_helper_acquire_ctx_alloc()") Signed-off-by: Phil Elwell <[email protected]>
1 parent 6936a2c commit 3a41506

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/gpu/drm/vc4/tests/vc4_test_lbm_size.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static struct kunit_case vc4_lbm_size_tests[] = {
279279

280280
static int vc4_lbm_size_test_init(struct kunit *test)
281281
{
282-
struct drm_modeset_acquire_ctx *ctx;
282+
static struct drm_modeset_acquire_ctx ctx;
283283
struct vc4_lbm_size_priv *priv;
284284
struct drm_device *drm;
285285
struct vc4_dev *vc4;
@@ -295,13 +295,15 @@ static int vc4_lbm_size_test_init(struct kunit *test)
295295
priv->file = drm_file_alloc(priv->vc4->base.primary);
296296
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->file);
297297

298-
ctx = drm_kunit_helper_acquire_ctx_alloc(test);
299-
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
298+
drm_modeset_acquire_init(&ctx, 0);
300299

301300
drm = &vc4->base;
302-
priv->state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx);
301+
priv->state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
303302
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->state);
304303

304+
drm_modeset_drop_locks(&ctx);
305+
drm_modeset_acquire_fini(&ctx);
306+
305307
return 0;
306308
}
307309

drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test)
807807
static int vc4_pv_muxing_test_init(struct kunit *test)
808808
{
809809
const struct pv_muxing_param *params = test->param_value;
810-
struct drm_modeset_acquire_ctx ctx;
810+
static struct drm_modeset_acquire_ctx ctx;
811811
struct pv_muxing_priv *priv;
812812
struct drm_device *drm;
813813
struct vc4_dev *vc4;

0 commit comments

Comments
 (0)