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 v7 20/34] drm/atomic_helper: Compare actual and readout states once the commit is done
Date: Thu, 29 Oct 2026 08:05:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-188945@kernel.org> (raw)
In-Reply-To: <20261029-drm-state-readout-v7-20-25e5163d75c3@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/atomic_sro: partial commit readout triggers WARN_ON(!conn_state) in bridge readout
--

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

drm/atomic_helper: Compare actual and readout states once the commit is done

This commit adds the atomic_sro_compare_state hook across KMS objects and
introduces drm_atomic_sro_readout_and_compare(), which is called from
commit_tail() after blocking commits to read out hardware state and compare
it against the committed state.

> diff --git a/drivers/gpu/drm/drm_atomic_state_readout.c b/drivers/gpu/drm/drm_atomic_state_readout.c
> index 2c17fa09c5f08..f29d127f99f81 100644
> --- a/drivers/gpu/drm/drm_atomic_state_readout.c
> +++ b/drivers/gpu/drm/drm_atomic_state_readout.c

[ ... ]

> +bool drm_atomic_sro_readout_and_compare(struct drm_atomic_commit *commit)
> +{
> +	struct drm_device *dev = commit->dev;
> +	const struct drm_mode_config_helper_funcs *funcs =
> +		dev->mode_config.helper_private;
> +	struct drm_printer p = drm_err_printer(dev, NULL);
> +	struct drm_private_state *new_obj_state;
> +	struct drm_private_obj *obj;
> +	struct drm_plane_state *new_plane_state;
> +	struct drm_plane *plane;
> +	struct drm_crtc_state *new_crtc_state;
> +	struct drm_crtc *crtc;
> +	struct drm_connector_state *new_conn_state;
> +	struct drm_connector *conn;
> +	struct drm_atomic_sro_state *readout_state;
> +	unsigned int i;
> +	bool identical = true;
> +
> +	might_alloc(GFP_KERNEL);
> +
> +	if (!drm_atomic_sro_device_can_readout(dev))
> +		return true;
> +
> +	readout_state = funcs->atomic_sro_build_state(dev, commit);
> +	if (WARN_ON(IS_ERR(readout_state)))
> +		return false;

[Severity: Medium]
When commit_tail() calls drm_atomic_sro_readout_and_compare() for a blocking
commit that only includes a subset of connectors on a multi-connector device
with bridges, won't funcs->atomic_sro_build_state(dev, commit) trigger a
WARN_ON(!conn_state) in find_connector_state_for_encoder()?

When commit is non-NULL, drm_atomic_helper_sro_readout_connectors_state()
calls drm_atomic_helper_sro_readout_commit_connectors_state() in
drivers/gpu/drm/drm_atomic_state_readout_helper.c, which only populates
readout_state for connectors present in commit:

	for_each_new_connector_in_state(commit, connector, new_connector_state, i) {
		ret = drm_atomic_helper_sro_readout_connector_state(dev, state, connector);
		if (ret)
			return ret;
	}

Any other connector on dev has NULL state in readout_state.

Then drm_atomic_helper_sro_readout_bridges_state() calls
drm_atomic_helper_sro_readout_commit_bridges_state(), which walks the bridge
chains of old_conn_state->best_encoder and new_conn_state->best_encoder and
invokes drm_bridge_atomic_readout_priv_state() ->
find_connector_state_for_encoder() in drivers/gpu/drm/drm_bridge.c:

	drm_for_each_connector_iter(connector, &conn_iter) {
		struct drm_connector_state *conn_state =
			drm_atomic_sro_get_connector_state(state, connector);

		if (WARN_ON(!conn_state))
			continue;

		if (encoder == conn_state->best_encoder) {
			drm_connector_list_iter_end(&conn_iter);
			return conn_state;
		}
	}

Because find_connector_state_for_encoder() iterates over all connectors on
the device, visiting any connector not included in commit (either an
uncommitted connector preceding the active connector in the connector list,
or any uncommitted connector when disabling a connector so old_encoder is no
longer routed to any connector) hits WARN_ON(!conn_state).

Also, when a commit disables a connector, drm_atomic_helper_check_modeset()
adds old_conn_state->best_encoder's bridges to commit by duplicating their
previous active bridge state, whereas drm_bridge_atomic_readout_priv_state()
leaves the readout bridge state as a pristine default state when
find_connector_state_for_encoder(state, old_encoder) returns NULL. Won't
that cause drm_atomic_sro_readout_and_compare() to report a false mismatch
on the bridge private object state when a connector is disabled?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261029-drm-state-readout-v7-0-25e5163d75c3@kernel.org?part=20

  reply	other threads:[~2026-10-29  8:05 UTC|newest]

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