Hi Maxime,

On 03/04/25 10:33, Maxime Ripard wrote:
Some functions used by the HVS->PV muxing tests can return with EDEADLK,
meaning the entire sequence should be restarted. It's not a fatal error
and we should treat it as a recoverable error, and recover, instead of
failing the test like we currently do.

Fixes: 76ec18dc5afa ("drm/vc4: tests: Add unit test suite for the PV muxing")
Signed-off-by: Maxime Ripard <mrip...@kernel.org>

Reviewed-by: Maíra Canal <mca...@igalia.com>

Best Regards,
- Maíra

---
  drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 113 ++++++++++++++++++++++++-
  1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
index 
52c04ef33206bf4f9e21e3c8b7cea932824a67fa..d1f694029169adf6a907a72614bc66afd745017e
 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
@@ -685,20 +685,34 @@ static void drm_vc4_test_pv_muxing(struct kunit *test)
drm_modeset_acquire_init(&ctx, 0); vc4 = priv->vc4;
        drm = &vc4->base;
+
+retry:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
        for (i = 0; i < params->nencoders; i++) {
                enum vc4_encoder_type enc_type = params->encoders[i];
ret = vc4_mock_atomic_add_output(test, state, enc_type);
+               if (ret == -EDEADLK) {
+                       drm_atomic_state_clear(state);
+                       ret = drm_modeset_backoff(&ctx);
+                       if (!ret)
+                               goto retry;
+               }
                KUNIT_ASSERT_EQ(test, ret, 0);
        }
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry;
+       }
        KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_TRUE(test,
                          check_fifo_conflict(test, state));
@@ -726,21 +740,35 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test) drm_modeset_acquire_init(&ctx, 0); vc4 = priv->vc4;
        drm = &vc4->base;
+
+retry:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
for (i = 0; i < params->nencoders; i++) {
                enum vc4_encoder_type enc_type = params->encoders[i];
ret = vc4_mock_atomic_add_output(test, state, enc_type);
+               if (ret == -EDEADLK) {
+                       drm_atomic_state_clear(state);
+                       ret = drm_modeset_backoff(&ctx);
+                       if (!ret)
+                               goto retry;
+               }
                KUNIT_ASSERT_EQ(test, ret, 0);
        }
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry;
+       }
        KUNIT_EXPECT_LT(test, ret, 0);
drm_modeset_drop_locks(&ctx);
        drm_modeset_acquire_fini(&ctx);
  }
@@ -811,17 +839,30 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
drm_modeset_acquire_init(&ctx, 0); drm = &vc4->base;
+retry_first:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
new_hvs_state = vc4_hvs_get_new_global_state(state);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_hvs_state);
@@ -834,17 +875,30 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
        KUNIT_ASSERT_TRUE(test, 
new_hvs_state->fifo_state[hdmi0_channel].in_use);
ret = drm_atomic_helper_swap_state(state, false);
        KUNIT_ASSERT_EQ(test, ret, 0);
+retry_second:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_second;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_second;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
new_hvs_state = vc4_hvs_get_new_global_state(state);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_hvs_state);
@@ -885,20 +939,39 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
drm_modeset_acquire_init(&ctx, 0); drm = &vc4->base;
+retry_first:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
new_hvs_state = vc4_hvs_get_new_global_state(state);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_hvs_state);
@@ -919,17 +992,30 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
        KUNIT_ASSERT_TRUE(test, 
new_hvs_state->fifo_state[old_hdmi1_channel].in_use);
ret = drm_atomic_helper_swap_state(state, false);
        KUNIT_ASSERT_EQ(test, ret, 0);
+retry_second:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_second;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_second;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
new_hvs_state = vc4_hvs_get_new_global_state(state);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_hvs_state);
@@ -979,29 +1065,54 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
drm_modeset_acquire_init(&ctx, 0); drm = &vc4->base;
+retry_first:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_first;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
-
        ret = drm_atomic_helper_swap_state(state, false);
        KUNIT_ASSERT_EQ(test, ret, 0);
+retry_second:
        state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_second;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK) {
+               drm_atomic_state_clear(state);
+               ret = drm_modeset_backoff(&ctx);
+               if (!ret)
+                       goto retry_second;
+       }
        KUNIT_ASSERT_EQ(test, ret, 0);
new_vc4_crtc_state = get_vc4_crtc_state_for_encoder(test, state,
                                                            
VC4_ENCODER_TYPE_HDMI0);
        KUNIT_EXPECT_NULL(test, new_vc4_crtc_state);


Reply via email to