All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 28/39] drm/tests: Add tests for the atomic state readout
Date: Fri, 06 Nov 2026 13:44:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-201489@kernel.org> (raw)
In-Reply-To: <20261106-drm-state-readout-v8-28-cbe78624e1bc@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/tests: missing -EDEADLK backoff in atomic readout KUnit
  tests
- [Low] drm/tests: unchecked init calls in mock_device_create()
--

commit 012e80f1472ac3f4ff4d9e75c5b23df0a05d93bd
Author: Maxime Ripard <mripard@kernel.org>

drm/tests: Add tests for the atomic state readout

This commit adds KUnit test suites for the DRM atomic state readout
infrastructure, covering state containers, readout and state comparison
helpers, readout modes, and initial state creation.

> diff --git a/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c b/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c
> new file mode 100644
> index 0000000000000..f2bc6d52c5b22
> --- /dev/null
> +++ b/drivers/gpu/drm/tests/drm_atomic_state_readout_test.c

[ ... ]

> +static struct sro_test_priv *
> +mock_device_create(struct kunit *test,
> +		   const struct drm_mode_config_funcs *mode_config_funcs,
> +		   const struct drm_mode_config_helper_funcs *helper_funcs,
> +		   const struct drm_plane_funcs *plane_funcs,
> +		   const struct drm_crtc_funcs *crtc_funcs,
> +		   const struct drm_connector_funcs *connector_funcs)
> +{

[ ... ]

> +	drm_atomic_private_obj_init(drm, &priv->private_obj,
> +				    "test private obj",
> +				    &mock_private_obj_with_sro_funcs);
> +	kunit_add_action_or_reset(test, mock_private_obj_fini,
> +				  &priv->private_obj);
> +
> +	return priv;
> +}

[Severity: Low]
Should mock_device_create() assert the return values of
drm_atomic_private_obj_init() and kunit_add_action_or_reset() with
KUNIT_ASSERT_EQ(test, ret, 0)?  If either fails, priv->private_obj is left
off drm->mode_config.privobj_list (or torn down with a dangling state
pointer), so drm_atomic_sro_state_alloc() allocates state->private_objs as
ZERO_SIZE_PTR and drm_atomic_sro_set_private_obj_state() dereferences it.

[ ... ]

> +static void drm_test_sro_readout_no_modeset(struct kunit *test)
> +{

[ ... ]

> +	/* A commit with a different configuration needs a modeset. */
> +	drm_modeset_acquire_init(&ctx, 0);
> +
> +retry:
> +	commit = drm_kunit_helper_atomic_state_alloc(test, &priv->drm, &ctx);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, commit);
> +
> +	crtc_state = drm_atomic_get_crtc_state(commit, priv->crtc);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
> +
> +	mode = drm_kunit_display_mode_from_cea_vic(test, &priv->drm,
> +						   SRO_TEST_OTHER_MODE_VIC);
> +	KUNIT_ASSERT_NOT_NULL(test, mode);
> +
> +	ret = drm_atomic_set_mode_for_crtc(crtc_state, mode);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	commit->allow_modeset = true;
> +
> +	ret = drm_atomic_check_only(commit);
> +	if (ret == -EDEADLK)
> +		goto backoff;
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +	KUNIT_EXPECT_TRUE(test, crtc_state->mode_changed);
> +
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +
> +	return;
> +
> +backoff:
> +	drm_atomic_commit_clear(commit);
> +	drm_modeset_backoff(&ctx);
> +	goto retry;
> +}
> +
> +/*
> + * Test that blanking a pipeline isn't reported as a mismatch. A DPMS
> + * off commit only clears drm_crtc_state.active and leaves the
> + * connector bound to its CRTC, while the hardware readout of a
> + * disabled pipeline reports an unbound connector: the two states
> + * differ, but there is nothing to compare for a pipeline that doesn't
> + * drive a picture anymore.
> + */
> +static void drm_test_sro_readout_and_compare_blanked(struct kunit *test)
> +{
> +	struct drm_modeset_acquire_ctx ctx;
> +	struct drm_connector_state *conn_state;
> +	struct drm_atomic_commit *commit;
> +	struct sro_test_priv *priv;
> +	struct drm_crtc_state *crtc_state;
> +	bool identical;
> +	int ret;
> +
> +	priv = mock_device_with_sro_create(test);
> +
> +	/* Install the mock hardware state, with the pipeline enabled */
> +	ret = drm_atomic_helper_sro_readout_state(&priv->drm);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	drm_modeset_acquire_init(&ctx, 0);
> +
> +	commit = drm_kunit_helper_atomic_state_alloc(test, &priv->drm, &ctx);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, commit);
> +
> +	crtc_state = drm_atomic_get_crtc_state(commit, priv->crtc);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
> +
> +	conn_state = drm_atomic_get_connector_state(commit, &priv->connector);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);

[Severity: Medium]
Can drm_atomic_get_connector_state() return ERR_PTR(-EDEADLK) here when
CONFIG_DEBUG_WW_MUTEX_SLOWPATH is enabled?

drm_atomic_get_crtc_state() acquires priv->crtc->mutex as the first lock in
ctx, and drm_atomic_get_connector_state() then acquires connection_mutex as
the second lock, where ww_mutex_deadlock_injection() can inject -EDEADLK.
Without a backoff retry loop, KUNIT_ASSERT_NOT_ERR_OR_NULL(test,
conn_state) aborts the test before drm_modeset_drop_locks() and
drm_modeset_acquire_fini() run, leaving priv->crtc->mutex locked during
device teardown.

In drm_test_sro_readout_no_modeset() above, after drm_modeset_backoff(&ctx)
locks the contended lock, drm_atomic_get_crtc_state() becomes the second
lock acquisition in ctx and can likewise return ERR_PTR(-EDEADLK), and the
retry label also reallocates commit and mode on each backoff iteration even
though backoff clears commit with drm_atomic_commit_clear().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-drm-state-readout-v8-0-cbe78624e1bc@kernel.org?part=28

  reply	other threads:[~2026-11-06 13:44 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 13:14 [PATCH v8 00/39] drm: Implement state readout support Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 01/39] drm/ingenic: Convert to devm_drm_bridge_alloc() Maxime Ripard
2026-11-06 13:33   ` sashiko-bot
2026-11-06 13:55   ` Luca Ceresoli
2026-11-06 13:59     ` Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 02/39] drm/bridge-helper: Don't unlock the connection mutex after a backoff Maxime Ripard
2026-11-06 13:39   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 03/39] drm/tests: hdmi-state-helper: Handle EDEADLK in the 420-only test Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 04/39] drm/tests: hdmi-state-helper: Handle EDEADLK in the color format test Maxime Ripard
2026-11-06 13:32   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 05/39] drm/colorop: Export drm_atomic_helper_colorop_create_state() Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 06/39] drm/atomic: Fix private obj error handling Maxime Ripard
2026-11-06 13:29   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 07/39] drm/atomic: Add drm_private_obj name Maxime Ripard
2026-11-06 13:35   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 08/39] drm/bridge: Switch print_state to use bridge name Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 09/39] drm/bridge: Add drm_private_obj_is_bridge() Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 10/39] drm/fb-dma-helper: Handle framebuffers without a GEM object Maxime Ripard
2026-11-06 13:32   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 11/39] drm/gem-atomic-helper: " Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 12/39] drm/atomic: Export drm_atomic_*_print_state Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 13/39] drm/atomic_sro: Create drm_atomic_sro_state container Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 14/39] drm/atomic_sro: Create kernel parameter to force or disable readout Maxime Ripard
2026-11-06 13:31   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 15/39] drm/atomic_sro: Add atomic state readout infrastructure Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 16/39] drm/atomic_sro: Add function to install state into drm objects Maxime Ripard
2026-11-06 13:33   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 17/39] drm/atomic_sro: Create documentation Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 18/39] drm/bridge: Handle bridges with hardware state readout Maxime Ripard
2026-11-06 13:33   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 19/39] drm/mode-config: Read out hardware state in drm_mode_config_create_state Maxime Ripard
2026-11-06 13:33   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 20/39] drm/atomic_sro: Provide helpers to implement hardware state readout Maxime Ripard
2026-11-06 13:44   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 21/39] drm/mode-config: Introduce hw_reset hook Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 22/39] drm/modeset-helper: Add drm_mode_config_helper_hw_reset() Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 23/39] drm/atomic_helper: Compare actual and readout states once the commit is done Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 24/39] drm/atomic-state-helper: Provide comparison macros Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 25/39] drm/atomic-state-helper: Provide atomic_compare_state helpers Maxime Ripard
2026-11-06 13:44   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 26/39] drm/atomic-helper: Document State Read-Out as a state initialization approach Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 27/39] drm/tests: kunit: Add a drm_printer helper Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 28/39] drm/tests: Add tests for the atomic state readout Maxime Ripard
2026-11-06 13:44   ` sashiko-bot [this message]
2026-11-06 13:14 ` [PATCH v8 29/39] drm/encoder: Create atomic_sro_get_current_crtc hook Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 30/39] drm/bridge: display-connector: Implement readout support Maxime Ripard
2026-11-06 13:50   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 31/39] drm/bridge_connector: Implement hw readout for connector Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 32/39] drm/tidss: crtc: Add atomic_print_state implementation Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 33/39] drm/tidss: dispc: Improve mode checking logs Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 34/39] drm/tidss: Implement hw_reset Maxime Ripard
2026-11-06 13:50   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 35/39] drm/tidss: Implement readout support Maxime Ripard
2026-11-06 14:06   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 36/39] drm/tidss: encoder: Implement atomic_sro_get_current_crtc Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 37/39] drm/bridge: sii902x: Implement hw state readout Maxime Ripard
2026-11-06 13:14 ` [PATCH v8 38/39] drm/panel: Implement state readout support Maxime Ripard
2026-11-06 13:45   ` sashiko-bot
2026-11-06 13:14 ` [PATCH v8 39/39] fixup! drm/tidss: Implement " Maxime Ripard
2026-11-06 13:57   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-201489@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.