Skip to content

Commit

Permalink
drm/vc4: tests: mock: Use a kunit action to unregister DRM device
Browse files Browse the repository at this point in the history
The *_mock_device functions allocate a DRM device that needs to be
released using drm_dev_unregister.

Now that we have a kunit release action API, we can switch to it and
don't require any kind of garbage collection from the caller.

Reviewed-by: Javier Martinez Canillas <[email protected]>
Reviewed-by: Maíra Canal <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Maxime Ripard <[email protected]>
  • Loading branch information
mripard committed Jul 31, 2023
1 parent cf1788f commit 571f88b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 12 additions & 0 deletions drivers/gpu/drm/vc4/tests/vc4_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ static int __build_mock(struct kunit *test, struct drm_device *drm,
return 0;
}

static void kunit_action_drm_dev_unregister(void *ptr)
{
struct drm_device *drm = ptr;

drm_dev_unregister(drm);
}

static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
{
struct drm_device *drm;
Expand Down Expand Up @@ -186,6 +193,11 @@ static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
ret = drm_dev_register(drm, 0);
KUNIT_ASSERT_EQ(test, ret, 0);

ret = kunit_add_action_or_reset(test,
kunit_action_drm_dev_unregister,
drm);
KUNIT_ASSERT_EQ(test, ret, 0);

return vc4;
}

Expand Down
6 changes: 0 additions & 6 deletions drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,11 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
static void vc4_pv_muxing_test_exit(struct kunit *test)
{
struct pv_muxing_priv *priv = test->priv;
struct vc4_dev *vc4 = priv->vc4;
struct drm_device *drm = &vc4->base;
struct drm_atomic_state *state = priv->state;

drm_atomic_state_put(state);
drm_modeset_drop_locks(&priv->ctx);
drm_modeset_acquire_fini(&priv->ctx);
drm_dev_unregister(drm);
}

static struct kunit_case vc4_pv_muxing_tests[] = {
Expand Down Expand Up @@ -871,7 +868,6 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
drm_atomic_state_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
drm_dev_unregister(drm);
}

static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
Expand Down Expand Up @@ -960,7 +956,6 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
drm_atomic_state_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
drm_dev_unregister(drm);
}

static void
Expand Down Expand Up @@ -1013,7 +1008,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku
drm_atomic_state_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
drm_dev_unregister(drm);
}

static struct kunit_case vc5_pv_muxing_bugs_tests[] = {
Expand Down

0 comments on commit 571f88b

Please sign in to comment.