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.
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 aafe78b7cbbd..8e3e9bb4a202 100644
--- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
@@ -2295,33 +2295,47 @@ static void drm_test_check_hdmi_color_format(struct
kunit *test)
KUNIT_ASSERT_TRUE(test, drm_mode_is_420(info, preferred));
state = drm_kunit_helper_atomic_state_alloc(test, &priv->drm, &ctx);
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);
conn_state->color_format = param->fmt;
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);
ret = drm_atomic_set_mode_for_crtc(crtc_state, preferred);
KUNIT_ASSERT_EQ(test, ret, 0);
crtc_state->enable = true;
crtc_state->active = true;
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);
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_params[] = {
{
.fmt = DRM_CONNECTOR_COLOR_FORMAT_AUTO,
--
2.56.1