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 v11 3/9] drm/atomic: Allow filling a commit with pristine object states
Date: Mon, 16 Nov 2026 10:41:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-216752@kernel.org> (raw)
In-Reply-To: <20261116-drm-reset-state-flag-v11-3-378b3f7bef32@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/atomic: lost driver state in
  drm_atomic_commit_fill_with_defaults()
--

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

drm/atomic: Allow filling a commit with pristine object states

This commit adds drm_atomic_commit_fill_with_defaults() to populate an
atomic commit with pristine object states created via atomic_create_state()
while preserving adjusted_mode and best_encoder.

> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 7a77051096c91..43df13aaef1eb 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1649,6 +1649,327 @@ bool drm_atomic_implements_create_state(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_atomic_implements_create_state);
>  
> +int drm_atomic_commit_fill_with_defaults(struct drm_file *file_priv,
> +					 struct drm_atomic_commit *commit)
> +{

[ ... ]

> +		crtc_state = crtc->funcs->atomic_create_state(crtc);
> +		if (IS_ERR(crtc_state))
> +			return PTR_ERR(crtc_state);

[ ... ]

> +		drm_mode_copy(&crtc_state->adjusted_mode,
> +			      &crtc->state->adjusted_mode);
> +
> +		/*
> +		 * The planes come back with the default zpos, which the
> +		 * atomic helpers only normalize when the planes bound to a
> +		 * CRTC or one of their zpos changed. Re-applying the same
> +		 * configuration on top of the reset wouldn't trigger
> +		 * either, so ask for a normalization explicitly.
> +		 */
> +		crtc_state->zpos_changed = true;
> +
> +		drm_atomic_commit_set_crtc_state(commit, crtc, crtc_state);
> +	}
> +
> +	drm_for_each_plane(plane, dev) {

[ ... ]

> +		plane_state = plane->funcs->atomic_create_state(plane);
> +		if (IS_ERR(plane_state))
> +			return PTR_ERR(plane_state);

[ ... ]

> +		connector_state = connector->funcs->atomic_create_state(connector);
> +		if (IS_ERR(connector_state)) {
> +			drm_connector_list_iter_end(&conn_iter);
> +			ret = PTR_ERR(connector_state);
> +			return ret;
> +		}
> +
> +		/*
> +		 * best_encoder is a routing information maintained by the
> +		 * atomic helpers rather than a userspace property, and it
> +		 * is only carried over to a new state when that state is a
> +		 * duplicate of the current one. Since
> +		 * update_connector_routing() uses it to detect the commits
> +		 * that keep the connector routing unchanged, carry the
> +		 * encoder currently in use over so that a reset on which
> +		 * userspace re-applies the exact same configuration doesn't
> +		 * require a modeset.
> +		 */
> +		connector_state->best_encoder = connector->state->best_encoder;

[Severity: High]
Does creating fresh states via atomic_create_state() while carrying over
adjusted_mode and best_encoder to avoid a modeset drop required
driver-private state in drivers that satisfy
drm_atomic_implements_create_state()?

In msm/mdp5, mdp5_plane_create_state() zeroes mdp5_state->hwpipe and
r_hwpipe, so mdp5_plane_atomic_check_with_state() passes NULL to
mdp5_pipe_release() and permanently leaks the previously assigned hardware
pipes in mdp5_global_state; if a CRTC stays active with no visible planes,
mdp5_crtc_atomic_check() also skips mdp5_crtc_setup_pipeline(), leaving
mdp5_cstate->pipeline.mixer NULL and causing a NULL pointer dereference in
blend_setup() during mdp5_crtc_atomic_flush().

In nouveau dispnv50, skipping a modeset when the active configuration is
re-applied across a reset causes nv50_wndw_atomic_check_acquire() to skip
populating asyw->image when the framebuffer is unchanged (making
curs507a_acquire() reject cursor commits with -EINVAL and zeroing
asyw->ntfy, sema, xlut, and csc handles on primary/overlay planes), leaves
asyh->mode, view, or, dither, procamp, and wndw.owned zeroed in
nv50_head_atomic_check(), and leaves asyc->set.mask zeroed when connector
properties are reset to their defaults.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-drm-reset-state-flag-v11-0-378b3f7bef32@kernel.org?part=3

  reply	other threads:[~2026-11-16 10:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 10:17 [PATCH v11 0/9] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-11-16 10:17 ` [PATCH v11 1/9] drm/lease: Add a helper to tell whether a lease was revoked Maxime Ripard
2026-11-16 10:30   ` sashiko-bot
2026-11-16 10:17 ` [PATCH v11 2/9] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-11-16 10:17 ` [PATCH v11 3/9] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-11-16 10:41   ` sashiko-bot [this message]
2026-11-16 10:17 ` [PATCH v11 4/9] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() Maxime Ripard
2026-11-16 10:17 ` [PATCH v11 5/9] drm/amd/display: Take over the current stream and dc_state Maxime Ripard
2026-11-16 10:17 ` [PATCH v11 6/9] drm/vc4: Carry the HVS channel over to created CRTC states Maxime Ripard
2026-11-17 19:12   ` Dave Stevenson
2026-11-16 10:17 ` [PATCH v11 7/9] drm/msm/dpu1: Carry the mixers " Maxime Ripard
2026-11-16 10:17 ` [PATCH v11 8/9] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-11-16 10:17 ` [PATCH v11 9/9] drm/vkms: Add driver-specific plane property for testing Maxime Ripard
2026-11-16 12:39   ` Louis Chauvet

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-216752@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.