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() wasn't doing any of that, and
reported a spurious failure when drm_atomic_set_crtc_for_connector()
returned -EDEADLK, just like its 420-only counterpart fixed earlier.
Since the ticket ordering depends on the execution, this could only be
observed occasionally.

The assertion also aborted before the locking context could be
released, leaving connection_mutex held when the device was released,
which drm_modeset_lock_fini() then reported through
drm_mode_config_cleanup().

Add the usual backoff and restart pattern, and remove a stray
semicolon at the end of drm_test_check_hdmi_color_format_420_only().

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 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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 63d6f8bf1396..a4dad1f5bfc0 100644
--- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
@@ -2300,4 +2300,5 @@ static void drm_test_check_hdmi_color_format(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);
@@ -2306,7 +2307,11 @@ static void drm_test_check_hdmi_color_format(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);
 
@@ -2318,4 +2323,6 @@ static void drm_test_check_hdmi_color_format(struct kunit 
*test)
 
        ret = drm_atomic_check_only(state);
+       if (ret == -EDEADLK)
+               goto backoff;
        KUNIT_EXPECT_EQ(test, ret, param->expected_ret);
        KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, param->expected);
@@ -2323,4 +2330,11 @@ static void drm_test_check_hdmi_color_format(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;
 }
 

-- 
2.55.0

Reply via email to