From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 10/13] drm/atomic: Allow filling a commit with pristine object states
Date: Fri, 18 Sep 2026 14:47:15 +0000 [thread overview]
Message-ID: <20260918144715.E74FC1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918-drm-reset-state-flag-v4-10-5ad106370f05@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm/atomic: deadlock on NULL acquire_ctx in drm_atomic_commit_fill_with_defaults
- [Medium] drm/atomic: lock inversion in drm_atomic_commit_fill_with_defaults
--
commit 955de6594c45c6a520389d6b2f5a51cb5ce03d61
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 iterate over all
CRTCs, planes, connectors, and color operations in the device. It inserts a
fresh default state for each one into the atomic commit. This is intended to
be used with the upcoming DRM_MODE_ATOMIC_RESET flag to bring the device
back to a known baseline.
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 7a77051096c91..b039edaa3271f 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
[ ... ]
> +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;
> +
> + drm_WARN_ON(dev, !commit->acquire_ctx);
> +
> + /*
> + * Private objects are ignored because none have userspace
> + * properties we might want to reset. atomic_check
[ ... ]
> + drm_for_each_plane(plane, dev) {
> + struct drm_plane_state *plane_state;
> +
> + ret = drm_modeset_lock(&plane->mutex, commit->acquire_ctx);
[Severity: Medium]
Does the locking order starting here create a lock inversion against standard
paths?
The standard DRM top-down locking hierarchy typically locks the
connection_mutex first, then CRTCs, and finally planes (as seen in
drm_modeset_lock_all_ctx).
However, drm_atomic_commit_fill_with_defaults() iterates and locks objects
in the reverse order (planes -> CRTCs -> connection_mutex). If userspace
invokes the DRM_MODE_ATOMIC_RESET flag while concurrent atomic operations
are running, could this inefficient locking cause ww_mutex to abort
transactions with -EDEADLK and retry, leading to unnecessary contention and
performance penalties?
[ ... ]
> + 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: High]
Can this loop cause a hard deadlock if commit->acquire_ctx is NULL?
Earlier in the function, drm_WARN_ON(dev, !commit->acquire_ctx) detects a
missing acquire context, but execution is allowed to continue. When we reach
this loop, drm_modeset_lock() is called for every connector.
If commit->acquire_ctx is NULL, the first iteration will successfully acquire
the underlying mutex, but the second iteration will attempt to recursively
lock the same connection_mutex without a ww_mutex context and block
indefinitely. Should the drm_WARN_ON() above be accompanied by an early
return to prevent this unrecoverable multi-connector deadlock?
> + if (ret) {
> + drm_connector_list_iter_end(&conn_iter);
> + return ret;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260918-drm-reset-state-flag-v4-0-5ad106370f05@kernel.org?part=10
next prev parent reply other threads:[~2026-09-18 14:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 14:17 [PATCH v4 00/13] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 01/13] drm/atomic: Switch to krealloc_array() in drm_atomic_get_private_obj_state() Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 02/13] drm/atomic: Use __GFP_ZERO instead of explicit memset " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 03/13] drm/atomic: Use __GFP_ZERO instead of explicit memset in drm_atomic_get_connector_state() Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 04/13] drm/atomic: Create function to insert CRTC state into a commit Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 05/13] drm/atomic: Create function to insert plane " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 06/13] drm/atomic: Create function to insert colorop " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 07/13] drm/atomic: Create function to insert private obj " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 08/13] drm/atomic: Create function to insert connector " Maxime Ripard
2026-09-18 14:17 ` [PATCH v4 09/13] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-09-23 9:19 ` Daniel Stone
2026-09-18 14:17 ` [PATCH v4 10/13] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-09-18 14:47 ` sashiko-bot [this message]
2026-09-18 14:18 ` [PATCH v4 11/13] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-09-18 14:48 ` sashiko-bot
2026-09-18 14:18 ` [PATCH v4 12/13] drm/vkms: Switch container_of helpers to container_of_const Maxime Ripard
2026-09-18 14:18 ` [PATCH v4 13/13] drm/vkms: Add driver-specific plane property for testing Maxime Ripard
2026-09-23 9:48 ` [PATCH v4 00/13] drm: Add DRM_MODE_ATOMIC_RESET flag Daniel Stone
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=20260918144715.E74FC1F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox