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 RFC 7/8] drm/atomic: Allow filling a commit with pristine object states
Date: Wed, 08 Jul 2026 16:24:09 +0000	[thread overview]
Message-ID: <20260708162410.1800D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708-drm-reset-state-flag-v1-7-c37dc985485d@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] Unchecked calls to the `atomic_create_state` hook on CRTCs, planes, and connectors will cause a kernel panic on drivers that do not implement them.
- [High] The function fails to reset private objects (`drm_private_obj`), resulting in an incomplete and inconsistent baseline state.
- [Medium] The locking order for `connection_mutex` in `drm_atomic_commit_fill_with_defaults` is inverted relative to the established DRM locking order.
--

--- Patch [7]: [PATCH RFC 7/8] drm/atomic: Allow filling a commit with pristine object states ---
commit e9e433a7ce1a444bdbe24747a11cf419bea31b2b
Author: Maxime Ripard <mripard@kernel.org>

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

This patch creates drm_atomic_commit_fill_with_defaults() to iterate over
all CRTCs, planes, connectors, and color operations in the device and insert
a fresh default state for each one. This brings the device back to a known
baseline before applying userspace property changes.

> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 79971d4b56a49..0c1a02d0e871d 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c

[ ... ]

> @@ -1610,6 +1610,118 @@ drm_atomic_get_new_bridge_state(const struct drm_atomic_commit *state,
>  }
>  EXPORT_SYMBOL(drm_atomic_get_new_bridge_state);
>  
> +/**
> + * drm_atomic_commit_fill_with_defaults - populate a commit with pristine states

[ ... ]

> +int drm_atomic_commit_fill_with_defaults(struct drm_atomic_commit *commit)
> +{
> +	struct drm_device *dev = commit->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_crtc *crtc;
> +	struct drm_plane *plane;
> +	struct drm_connector *connector;
> +	struct drm_connector_list_iter conn_iter;
> +	struct drm_colorop *colorop;
> +	int ret;
> +
> +	WARN_ON(!commit->acquire_ctx);
> +
> +	drm_for_each_crtc(crtc, dev) {
> +		struct drm_crtc_state *crtc_state;
> +
> +		ret = drm_modeset_lock(&crtc->mutex, commit->acquire_ctx);
> +		if (ret)
> +			return ret;
> +
> +		crtc_state = crtc->funcs->atomic_create_state(crtc);

[Severity: Critical]
Is it safe to call atomic_create_state without checking if the function pointer
exists?

Some drivers (like i915) might rely on the reset callback instead and leave
atomic_create_state unimplemented. Could this unconditional call lead to a NULL
pointer dereference here, as well as in the plane and connector loops below?

> +		if (IS_ERR(crtc_state))
> +			return PTR_ERR(crtc_state);
> +
> +		ret = drm_atomic_commit_set_crtc_state(commit, crtc, crtc_state);
> +		if (ret) {
> +			crtc->funcs->atomic_destroy_state(crtc, crtc_state);
> +			return ret;
> +		}
> +	}

[ ... ]

> +	drm_connector_list_iter_begin(dev, &conn_iter);
> +	drm_for_each_connector_iter(connector, &conn_iter) {
> +		struct drm_connector_state *connector_state;
> +
> +		ret = drm_modeset_lock(&config->connection_mutex, commit->acquire_ctx);

[Severity: Medium]
Does acquiring connection_mutex here invert the standard DRM locking order?

The established canonical sequence (such as in drm_modeset_lock_all_ctx)
typically acquires connection_mutex before the CRTC and plane locks. Since the
CRTC and plane locks were already acquired in the loops above, could acquiring
connection_mutex now result in unnecessary transaction backoffs and retries?

> +		if (ret) {
> +			drm_connector_list_iter_end(&conn_iter);
> +			return ret;
> +		}
> +
> +		connector_state = connector->funcs->atomic_create_state(connector);
> +		if (IS_ERR(connector_state)) {

[ ... ]

> +	drm_for_each_colorop(colorop, dev) {
> +		struct drm_colorop_state *colorop_state;
> +
> +		colorop_state = drm_atomic_helper_colorop_create_state(colorop);
> +		if (IS_ERR(colorop_state))
> +			return PTR_ERR(colorop_state);
> +
> +		drm_modeset_lock_assert_held(&colorop->plane->mutex);
> +
> +		ret = drm_atomic_commit_set_colorop_state(commit, colorop, colorop_state);
> +		if (ret) {
> +			drm_colorop_atomic_destroy_state(colorop, colorop_state);
> +			return ret;
> +		}
> +	}
> +

[Severity: High]
Should this function also iterate over and reset private objects
(drm_private_obj) before returning?

Modern DRM features like DP MST topologies, DisplayPort tunnels, and global
bandwidth allocators maintain their state in private objects. If these are
omitted from the reset, could it leave the topology or bandwidth state
inconsistent with the newly reset hardware baseline?

> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_atomic_commit_fill_with_defaults);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-drm-reset-state-flag-v1-0-c37dc985485d@kernel.org?part=7

  reply	other threads:[~2026-07-08 16:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 16:08 [PATCH RFC 0/8] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-07-08 16:08 ` [PATCH RFC 1/8] drm/atomic: colorop: Rename state to state_to_destroy Maxime Ripard
2026-07-08 16:16   ` sashiko-bot
2026-07-08 16:08 ` [PATCH RFC 2/8] drm/atomic: Create function to insert CRTC state into a commit Maxime Ripard
2026-07-08 16:08 ` [PATCH RFC 3/8] drm/atomic: Create function to insert plane " Maxime Ripard
2026-07-08 16:08 ` [PATCH RFC 4/8] drm/atomic: Create function to insert colorop " Maxime Ripard
2026-07-08 16:08 ` [PATCH RFC 5/8] drm/atomic: Create function to insert private obj " Maxime Ripard
2026-07-08 16:08 ` [PATCH RFC 6/8] drm/atomic: Create function to insert connector " Maxime Ripard
2026-07-08 16:08 ` [PATCH RFC 7/8] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-07-08 16:24   ` sashiko-bot [this message]
2026-07-08 16:08 ` [PATCH RFC 8/8] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-07-08 16:26   ` sashiko-bot
2026-07-08 18:25 ` [PATCH RFC 0/8] drm: " Xaver Hugl
2026-07-10 17:01 ` Michel Dänzer
2026-07-13  7:11   ` Maxime Ripard

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=20260708162410.1800D1F000E9@smtp.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.