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 7/9] drm/msm/dpu1: Carry the mixers over to created CRTC states
Date: Thu, 03 Dec 2026 16:36:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-248205@kernel.org> (raw)
In-Reply-To: <20261203-drm-reset-state-flag-v13-7-b09f19f64e64@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/msm/dpu1: created CRTC states drop crc_source and leak
  vblank refcount
- [Medium] drm/msm/dpu1: created plane states drop active bus bw vote to
  zero
- [Low] drm/msm/dpu1: data race on mixer_op_mode in
  dpu_crtc_atomic_check() memcpy()
--

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

drm/msm/dpu1: Carry the mixers over to created CRTC states

This commit copies num_mixers and mixers from the old CRTC state into
newly created CRTC states in dpu_crtc_atomic_check() when the CRTC stays
enabled and does not reallocate resources.

> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 77a2d1f6700d0..a99f6761035f8 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -1540,6 +1540,29 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
>  		rc = dpu_crtc_assign_resources(crtc, crtc_state);
>  		if (rc < 0)
>  			return rc;
> +	} else if (crtc_state->enable && !cstate->num_mixers) {
> +		struct dpu_crtc_state *old_cstate =
> +			to_dpu_crtc_state(drm_atomic_get_old_crtc_state(state,
> +									crtc));
> +
> +		/*
> +		 * A CRTC that keeps its configuration keeps its mixers.
> +		 * A duplicated state carries them over, but a state
> +		 * created through atomic_create_state() comes with
> +		 * none, so copy them from the current state like a
> +		 * duplicated state would, to make sure the checks and
> +		 * the commit see the mixers in use.
> +		 *
> +		 * Only do so for a CRTC that stays enabled:
> +		 * dpu_crtc_assign_resources() returns right after
> +		 * dpu_rm_release() for a disabled one, leaving the mixers
> +		 * it just released behind in the state it was given.
> +		 */
> +		if (old_cstate->num_mixers) {
> +			cstate->num_mixers = old_cstate->num_mixers;
> +			memcpy(cstate->mixers, old_cstate->mixers,
> +			       sizeof(cstate->mixers));

[Severity: Low]
Can this memcpy() race with _dpu_crtc_blend_setup() on
old_cstate->mixers[i].mixer_op_mode?

After a nonblocking commit swaps crtc->state and drops crtc->mutex, its
commit_work runs msm_atomic_commit_tail() under kms->commit_lock[] while a
subsequent reset commit can enter dpu_crtc_atomic_check() before waiting
for hw_done:

CPU0 (reset commit)                   CPU1 (nonblock commit_work)
drm_mode_atomic_ioctl()
  lock(crtc->mutex)                   msm_atomic_commit_tail()
                                        lock(kms->commit_lock[idx])
  dpu_crtc_atomic_check()               ...
                                          _dpu_crtc_blend_setup()
    memcpy(cstate->mixers,                  mixer[i].mixer_op_mode = 0
           old_cstate->mixers, ...)         _dpu_crtc_blend_setup_mixer()
      <-- data race                           mixer[i].mixer_op_mode |= ...

Because _dpu_crtc_blend_setup() zeroes mixer_op_mode before using it on the
new state, hardware programming is not corrupted, but KCSAN will flag the
data race.  Copying only hw_lm, lm_ctl, and hw_dspp for
i < old_cstate->num_mixers avoids reading mixer_op_mode altogether.

> +		}
>  	}

[Severity: Medium]
Does this drop crc_source and crc_frame_skip_count on created CRTC states
and leak a CRTC vblank reference?

dpu_crtc_create_state() zero-initializes crc_source to
DPU_CRTC_CRC_SOURCE_NONE, whereas dpu_crtc_duplicate_state() preserves it
across commits.  Because dpu_crtc_atomic_check() only carries over
num_mixers and mixers (and only on the non-reallocation branch), a commit
built via drm_atomic_commit_fill_with_defaults() while debugfs CRC capture
is open resets crtc->state->crc_source to DPU_CRTC_CRC_SOURCE_NONE.

Once the new state is swapped in, dpu_crtc_get_crc() returns -EINVAL and
CRC capture silently stalls.  When userspace later closes the CRC debugfs
file, crtc_crc_release() calls dpu_crtc_set_crc_source(crtc, NULL), which
sees current_source == DPU_CRTC_CRC_SOURCE_NONE and skips
drm_crtc_vblank_put(crtc), permanently leaking the vblank refcount.
Carrying crc_source and crc_frame_skip_count over from old_cstate across
all paths for created states (or storing them on struct dpu_crtc instead)
would avoid this.

[Severity: Medium]
Does dpu_core_perf_crtc_check() drop the active interconnect avg_bw vote
to zero when a commit uses created plane states?

dpu_plane_create_state() leaves plane_fetch_bw at zero, and it is only
computed later during commit in dpu_plane_sspp_atomic_update().  When
dpu_crtc_atomic_check() calls dpu_core_perf_crtc_check() ->
_dpu_core_perf_calc_bw(), it sums plane_fetch_bw over the newly created
plane states and stores cstate->new_perf.bw_ctl = 0, which is never
updated after dpu_plane_sspp_atomic_update() runs.

At the end of the commit, dpu_crtc_complete_commit() calls
dpu_core_perf_crtc_update(crtc, 0).  Seeing new->bw_ctl < old->bw_ctl, it
lowers the bus avg_bw vote via icc_set_bw() to zero while the CRTC and
planes remain actively scanning out, risking display underruns on a static
screen and under-counting this CRTC in the next commit's aggregate
bandwidth check.

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

  reply	other threads:[~2026-12-03 16:36 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
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 [this message]
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-248205@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.