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 336bb644cb7c..aafe78b7cbbd 100644
--- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
@@ -2398,35 +2398,49 @@ static void
drm_test_check_hdmi_color_format_420_only(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, dank);
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, dank);
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);
if (!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_420_only_params[] = {
{
.fmt = DRM_CONNECTOR_COLOR_FORMAT_RGB444,
.expected = DRM_OUTPUT_COLOR_FORMAT_RGB444,
--
2.56.1