From: sashiko-bot@kernel.org
To: "Guillaume La Roque" <glaroque@baylibre.com>
Cc: dri-devel@lists.freedesktop.org,
linux-amlogic@lists.infradead.org, neil.armstrong@linaro.org
Subject: Re: [PATCH v4 8/9] drm/meson: publish pending OSD updates with the flip event
Date: Fri, 04 Dec 2026 08:41:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-249418@kernel.org> (raw)
In-Reply-To: <20261204-meson-g12a-osd2-v4-8-ad356340dbd6@baylibre.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/meson: meson_crtc_irq() drops event_lock and event before
VD1 flush
- [Medium] drm/meson: TOCTOU check on vsync_disabled in meson_crtc_irq()
drops event
--
commit 65ec299b4ffcf639c6c3baf341647b074e7a0c1f
Author: Guillaume La Roque <glaroque@baylibre.com>
drm/meson: publish pending OSD updates with the flip event
This commit moves flip event capture from atomic_begin into atomic_flush
so pending OSD1 updates and the flip event are published together under
event_lock, and snapshots the event in meson_crtc_irq() while consuming
the OSD1 register cache.
> diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
> index 70acb034b8125..6fefae5387668 100644
> --- a/drivers/gpu/drm/meson/meson_crtc.c
> +++ b/drivers/gpu/drm/meson/meson_crtc.c
[ ... ]
> @@ -400,8 +390,13 @@ void meson_crtc_irq(struct meson_drm *priv)
> priv->afbcd.ops->enable(priv);
> meson_crtc->vsync_forced = true;
> }
> + }
> + priv->viu.osd[0].commit = false;
>
> - priv->viu.osd[0].commit = false;
> + /* Complete only the event associated with the updates just applied. */
> + if (!meson_crtc->vsync_disabled) {
> + event = meson_crtc->event;
> + meson_crtc->event = NULL;
> }
>
> spin_unlock_irqrestore(&priv->drm->event_lock, flags);
[Severity: Medium]
Can dropping event_lock here split an atomic commit across two vblanks
when VD1 is active?
CPU0 (meson_crtc_irq) CPU1 (meson_crtc_atomic_flush)
lock(event_lock)
osd[0].commit == false
event = NULL
unlock(event_lock)
lock(event_lock)
osd[0].commit = true
vd1_commit = true
meson_crtc->event = E1
unlock(event_lock)
if (vd1_enabled && vd1_commit)
program VD1 registers <-- VD1 applied on vblank N without OSD1 or E1
vd1_commit = false
Because meson_crtc_irq() now snapshots meson_crtc->event and drops
event_lock before checking priv->viu.vd1_commit, a concurrent atomic
commit can have its VD1 update programmed on vblank N while its OSD1
update and flip event wait for vblank N+1. For a VD1-only commit, the
flip completion event and vblank timestamp are reported one frame late.
[ ... ]
> @@ -681,10 +676,9 @@ void meson_crtc_irq(struct meson_drm *priv)
> drm_crtc_handle_vblank(priv->crtc);
>
> spin_lock_irqsave(&priv->drm->event_lock, flags);
> - if (meson_crtc->event) {
> - drm_crtc_send_vblank_event(priv->crtc, meson_crtc->event);
> + if (event) {
> + drm_crtc_send_vblank_event(priv->crtc, event);
> drm_crtc_vblank_put(priv->crtc);
> - meson_crtc->event = NULL;
> }
> spin_unlock_irqrestore(&priv->drm->event_lock, flags);
> }
[Severity: Medium]
Can the second meson_crtc->vsync_disabled check right above
drm_crtc_handle_vblank() drop a detached event and leak the vblank
refcount?
CPU0 (meson_crtc_irq) CPU1 (meson_crtc_atomic_disable)
lock(event_lock)
if (!vsync_disabled)
event = meson_crtc->event
meson_crtc->event = NULL
unlock(event_lock)
drm_crtc_vblank_off()
meson_crtc_disable_vblank()
vsync_disabled = true
if (vsync_disabled)
return; <-- event and vblank refcount leaked
After a drm_crtc_commit_wait() timeout,
drm_atomic_helper_wait_for_dependencies() proceeds into atomic_disable
without synchronizing against priv->vsync_irq, so drm_crtc_vblank_off()
can set vsync_disabled concurrently with meson_crtc_irq(). Returning
early after detaching event leaks the drm_pending_vblank_event, leaves
commit->flip_done unsignaled, and skips drm_crtc_vblank_put().
Separately, meson_crtc->vsync_disabled is read under event_lock and
unlocked in meson_crtc_irq(), while meson_crtc_enable_vblank() and
meson_crtc_disable_vblank() write it under vbl_lock and
vblank_time_lock without event_lock, creating a data race during idle
vblank disable.
Sampling vsync_disabled once with READ_ONCE()/WRITE_ONCE(), or
completing a non-NULL detached event before returning, would avoid both
issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-meson-g12a-osd2-v4-0-ad356340dbd6@baylibre.com?part=8
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-12-04 8:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:08 [PATCH v4 0/9] drm/meson: add a second RGB plane on G12A Guillaume La Roque
2026-12-04 8:08 ` [PATCH v4 1/9] drm/meson: honor framebuffer offsets for the primary plane Guillaume La Roque
2026-12-04 8:30 ` sashiko-bot
2026-12-04 8:08 ` [PATCH v4 2/9] drm/meson: isolate primary plane scaler setup Guillaume La Roque
2026-12-04 8:08 ` [PATCH v4 3/9] drm/meson: keep RGB scanout state per OSD Guillaume La Roque
2026-12-04 8:08 ` [PATCH v4 4/9] drm/meson: parameterize the G12A OSD color matrix setup Guillaume La Roque
2026-12-04 8:08 ` [PATCH v4 5/9] drm/meson: handle primary plane zpos allocation failure Guillaume La Roque
2026-12-04 8:08 ` [PATCH v4 6/9] drm/meson: select RGB plane registers by OSD index Guillaume La Roque
2026-12-04 8:08 ` [PATCH v4 7/9] drm/meson: serialize OSD state updates with the IRQ Guillaume La Roque
2026-12-04 8:30 ` sashiko-bot
2026-12-04 8:08 ` [PATCH v4 8/9] drm/meson: publish pending OSD updates with the flip event Guillaume La Roque
2026-12-04 8:41 ` sashiko-bot [this message]
2026-12-04 8:08 ` [PATCH v4 9/9] drm/meson: add a linear RGB overlay on G12A OSD2 Guillaume La Roque
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-249418@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=glaroque@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.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