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 v13 3/9] drm/atomic: Allow filling a commit with pristine object states
Date: Thu, 03 Dec 2026 15:02:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-248051@kernel.org> (raw)
In-Reply-To: <20261203-drm-reset-state-flag-v13-3-b09f19f64e64@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/atomic: lost driver state in
  drm_atomic_commit_fill_with_defaults()
- [Low] drm/atomic: commit message says -ENOENT instead of -EACCES for
  split leases
- [Low] drm/atomic: incomplete kernel-doc contract for
  drm_atomic_commit_fill_with_defaults()
--

commit e865390bfad964b059339362263f954229009ccf
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 freshly created default states for CRTCs, planes,
connectors, and color operations, scoped to the caller's lease.

> A lessee only gets the objects of its lease reset, the other ones
> keeping their current state. Partial pipelines aren't supported
> though: detaching a plane or a connector from its CRTC, and disabling
> a CRTC driving them, both need the two sides in the commit, so a lease
> that splits a pipeline is rejected with -ENOENT.

[Severity: Low]
As reported by Thomas Zimmermann on v12 [1], the code and kernel-doc now
return -EACCES for split leases rather than -ENOENT.  Should the commit
message be updated to match?

> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 5036beb2762ad..84af0b6e9bb07 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1708,6 +1708,327 @@ bool drm_atomic_implements_create_state(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_atomic_implements_create_state);
>  
> +/**
> + * drm_atomic_commit_fill_with_defaults - populate a commit with pristine states
> + * @file_priv: DRM file the reset was requested from, or NULL
> + * @commit: atomic commit to fill

[ ... ]

> + * Returns:
> + * 0 on success, -EACCES if a leased plane or connector is bound to a
> + * CRTC that isn't leased or if the lease was revoked, or a negative
> + * error code on failure.
> + */
> +int drm_atomic_commit_fill_with_defaults(struct drm_file *file_priv,
> +					 struct drm_atomic_commit *commit)

[Severity: Low]
Since drm_atomic_commit_fill_with_defaults() is exported, should its
kernel-doc spell out the caller contract and return values?

Callers must pass an empty commit with an initialized acquire_ctx and
verify drm_atomic_implements_create_state() beforehand, as the CRTC and
plane atomic_create_state hooks are called without NULL checks and
existing slots would be overwritten without cleanup.

The function also acquires modeset locks that stay held on both success
and failure, so callers need to clear partial state on error and handle
-EDEADLK backoff.  The Returns section omits -EDEADLK, -EOPNOTSUPP (for
a hotplugged connector without atomic_create_state), and the -EACCES
cases where a leased CRTC drives an unleased plane or connector.

[ ... ]

> +		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);

[ ... ]

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

[ ... ]

> +		connector_state->best_encoder = connector->state->best_encoder;

[Severity: High]
Can populating a live commit with atomic_create_state() while carrying
over adjusted_mode and best_encoder leave driver-private state zeroed in
drivers that satisfy drm_atomic_implements_create_state()?

Drivers assume a live atomic commit starts from duplicated state, so
skipping a modeset on a reset commit leaves subclass fields unpopulated
even after the amdgpu_dm, vc4, and msm/dpu1 adjustments later in the
series:

- msm/mdp5: keeping a CRTC active with no visible planes sets
  mdp5_cstate->ctl in mdp5_encoder_atomic_check(), while
  mdp5_crtc_atomic_check() returns early before setting up
  pipeline.mixer, causing a NULL pointer dereference on mixer->lm in
  blend_setup().  mdp5_plane_atomic_check_with_state() also releases
  hwpipe and r_hwpipe from the new plane state, which are NULL after
  mdp5_plane_create_state(), leaking the previously assigned pipes.

- nouveau dispnv50: on a no-modeset reset keeping the same framebuffer,
  nv50_wndw_atomic_check_acquire() skips populating asyw->image, causing
  curs507a_acquire() to fail with -EINVAL and leaving window handles
  zeroed.  nv50_head_atomic_check() similarly leaves head fields zeroed,
  and resetting connector properties to defaults leaves asyc->set.mask
  clear so hardware reprogramming is skipped.

- arm/komeda: komeda_crtc_create_state() zeroes affected_pipes,
  clock_ratio, and max_slave_zorder instead of copying them from the old
  state, so a no-modeset reset leaves clock_ratio zero and passes a
  zeroed affected_pipes to komeda_release_unclaimed_resources().

[1] https://lore.kernel.org/r/4653f381-cee3-4407-b393-5fc3352b3a39@suse.de

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-drm-reset-state-flag-v13-0-b09f19f64e64@kernel.org?part=3

  reply	other threads:[~2026-12-03 15:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:07 [PATCH v13 0/9] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-12-03 14:07 ` [PATCH v13 1/9] drm/lease: Add a helper to tell whether a lease was revoked Maxime Ripard
2026-12-03 14:23   ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 2/9] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-12-03 14:07 ` [PATCH v13 3/9] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-12-03 15:02   ` sashiko-bot [this message]
2026-12-03 14:07 ` [PATCH v13 4/9] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() Maxime Ripard
2026-12-03 15:21   ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 5/9] drm/amd/display: Take over the current stream and dc_state Maxime Ripard
2026-12-03 15:40   ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 6/9] drm/vc4: Carry the HVS channel over to created CRTC states Maxime Ripard
2026-12-03 16:06   ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 7/9] drm/msm/dpu1: Carry the mixers " Maxime Ripard
2026-12-03 16:36   ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 8/9] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-12-03 14:07 ` [PATCH v13 9/9] drm/vkms: Add driver-specific plane property for testing 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=sashiko-outbox-248051@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.