The atomic state API is allowed to return -EDEADLK whenever the
wound/wait mutex code detects a deadlock, and the caller is then
expected to back off and restart the whole sequence.

drm_test_check_hdmi_color_format_420_only() wasn't doing any of that,
and reported a spurious failure when drm_atomic_set_crtc_for_connector()
returned -EDEADLK. Since the ticket ordering depends on the execution,
this could only be observed occasionally: the structurally identical
drm_test_check_hdmi_color_format() test hasn't been observed to fail so
far.

Add the usual backoff and restart pattern.

Fixes: f7235a4805a4 ("drm/tests: hdmi: Add tests for the color_format property")
Signed-off-by: Maxime Ripard <[email protected]>
---
 drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c 
b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
index 99a0fa479704..63d6f8bf1396 100644
--- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
@@ -2403,4 +2403,5 @@ static void 
drm_test_check_hdmi_color_format_420_only(struct kunit *test)
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
+retry:
        conn_state = drm_atomic_get_connector_state(state, &priv->connector);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
@@ -2409,7 +2410,11 @@ static void 
drm_test_check_hdmi_color_format_420_only(struct kunit *test)
 
        ret = drm_atomic_set_crtc_for_connector(conn_state, priv->crtc);
+       if (ret == -EDEADLK)
+               goto backoff;
        KUNIT_ASSERT_EQ(test, ret, 0);
 
        crtc_state = drm_atomic_get_crtc_state(state, priv->crtc);
+       if (IS_ERR(crtc_state) && PTR_ERR(crtc_state) == -EDEADLK)
+               goto backoff;
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
 
@@ -2421,4 +2426,6 @@ static void 
drm_test_check_hdmi_color_format_420_only(struct kunit *test)
 
        ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK)
+               goto backoff;
        KUNIT_EXPECT_EQ(test, ret, param->expected_ret);
        if (!param->expected_ret)
@@ -2427,5 +2434,12 @@ static void 
drm_test_check_hdmi_color_format_420_only(struct kunit *test)
        drm_modeset_drop_locks(&ctx);
        drm_modeset_acquire_fini(&ctx);
-};
+
+       return;
+
+backoff:
+       drm_atomic_commit_clear(state);
+       drm_modeset_backoff(&ctx);
+       goto retry;
+}
 
 static const struct color_format_test_param 
hdmi_color_format_420_only_params[] = {

-- 
2.55.0

Reply via email to