Commit 55ab5e60 authored by Maxime Ripard's avatar Maxime Ripard

drm/vc4: tests: pv-muxing: Switch to managed locking init

The new helper to init the locking context allows to remove some
boilerplate.
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarMaíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20230728-kms-kunit-actions-rework-v3-9-952565ccccfe@kernel.orgSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
parent 571f88b0
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
struct pv_muxing_priv { struct pv_muxing_priv {
struct vc4_dev *vc4; struct vc4_dev *vc4;
struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_state *state; struct drm_atomic_state *state;
}; };
...@@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test) ...@@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test)
static int vc4_pv_muxing_test_init(struct kunit *test) static int vc4_pv_muxing_test_init(struct kunit *test)
{ {
const struct pv_muxing_param *params = test->param_value; const struct pv_muxing_param *params = test->param_value;
struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state; struct drm_atomic_state *state;
struct pv_muxing_priv *priv; struct pv_muxing_priv *priv;
struct drm_device *drm; struct drm_device *drm;
...@@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test) ...@@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
priv->vc4 = vc4; priv->vc4 = vc4;
drm_modeset_acquire_init(&priv->ctx, 0); ctx = drm_kunit_helper_acquire_ctx_alloc(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
drm = &vc4->base; drm = &vc4->base;
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &priv->ctx; state->acquire_ctx = ctx;
priv->state = state; priv->state = state;
...@@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test) ...@@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test)
struct drm_atomic_state *state = priv->state; struct drm_atomic_state *state = priv->state;
drm_atomic_state_put(state); drm_atomic_state_put(state);
drm_modeset_drop_locks(&priv->ctx);
drm_modeset_acquire_fini(&priv->ctx);
} }
static struct kunit_case vc4_pv_muxing_tests[] = { static struct kunit_case vc4_pv_muxing_tests[] = {
...@@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = { ...@@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = {
*/ */
static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *test) static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *test)
{ {
struct drm_modeset_acquire_ctx ctx; struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state; struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state; struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state; struct vc4_hvs_state *new_hvs_state;
...@@ -811,13 +810,14 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes ...@@ -811,13 +810,14 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
vc4 = vc5_mock_device(test); vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
drm_modeset_acquire_init(&ctx, 0); ctx = drm_kunit_helper_acquire_ctx_alloc(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
drm = &vc4->base; drm = &vc4->base;
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &ctx; state->acquire_ctx = ctx;
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_EQ(test, ret, 0);
...@@ -844,7 +844,7 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes ...@@ -844,7 +844,7 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &ctx; state->acquire_ctx = ctx;
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_EQ(test, ret, 0);
...@@ -866,13 +866,11 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes ...@@ -866,13 +866,11 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel); KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel);
drm_atomic_state_put(state); drm_atomic_state_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
} }
static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
{ {
struct drm_modeset_acquire_ctx ctx; struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state; struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state; struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state; struct vc4_hvs_state *new_hvs_state;
...@@ -885,13 +883,14 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) ...@@ -885,13 +883,14 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
vc4 = vc5_mock_device(test); vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
drm_modeset_acquire_init(&ctx, 0); ctx = drm_kunit_helper_acquire_ctx_alloc(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
drm = &vc4->base; drm = &vc4->base;
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &ctx; state->acquire_ctx = ctx;
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_EQ(test, ret, 0);
...@@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) ...@@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &ctx; state->acquire_ctx = ctx;
ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0); ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_EQ(test, ret, 0);
...@@ -954,14 +953,12 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) ...@@ -954,14 +953,12 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
} }
drm_atomic_state_put(state); drm_atomic_state_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
} }
static void static void
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct kunit *test) drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct kunit *test)
{ {
struct drm_modeset_acquire_ctx ctx; struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state; struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state; struct vc4_crtc_state *new_vc4_crtc_state;
struct drm_device *drm; struct drm_device *drm;
...@@ -971,13 +968,14 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku ...@@ -971,13 +968,14 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku
vc4 = vc5_mock_device(test); vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
drm_modeset_acquire_init(&ctx, 0); ctx = drm_kunit_helper_acquire_ctx_alloc(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
drm = &vc4->base; drm = &vc4->base;
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &ctx; state->acquire_ctx = ctx;
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_EQ(test, ret, 0);
...@@ -993,7 +991,7 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku ...@@ -993,7 +991,7 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku
state = drm_atomic_state_alloc(drm); state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
state->acquire_ctx = &ctx; state->acquire_ctx = ctx;
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_EQ(test, ret, 0);
...@@ -1006,8 +1004,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku ...@@ -1006,8 +1004,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku
KUNIT_EXPECT_NULL(test, new_vc4_crtc_state); KUNIT_EXPECT_NULL(test, new_vc4_crtc_state);
drm_atomic_state_put(state); drm_atomic_state_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
} }
static struct kunit_case vc5_pv_muxing_bugs_tests[] = { static struct kunit_case vc5_pv_muxing_bugs_tests[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment