Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 8/8] drm/meson: add a linear RGB overlay on G12A OSD2
Date: Mon, 30 Nov 2026 22:16:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-242095@kernel.org> (raw)
In-Reply-To: <20261130-meson-g12a-osd2-v1-8-aa982300c20e@baylibre.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/meson: stale osd[0].commit flag when OSD1 is disabled in
  meson_crtc_irq()
- [Medium] drm/meson: unlocked viu.osd state clear in
  meson_crtc_atomic_disable()
- [Medium] drm/meson: OSD2 RGB-to-YUV matrix left enabled on MIPI-DSI
  outputs
--

commit 62aaa32388dc51ac638495c67084358f3b970884
Author: Guillaume La Roque <glaroque@baylibre.com>

drm/meson: add a linear RGB overlay on G12A OSD2

This commit exposes the OSD2 plane as a linear RGB overlay above the
primary plane on G12A, G12B, and SM1 SoCs.

> diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
> index b2181151acd67..8ae03ce0308fe 100644
> --- a/drivers/gpu/drm/meson/meson_crtc.c
> +++ b/drivers/gpu/drm/meson/meson_crtc.c

[ ... ]

> @@ -179,6 +223,9 @@ static void meson_g12a_crtc_atomic_disable(struct drm_crtc *crtc,
>  	spin_lock_irqsave(&priv->drm->event_lock, flags);
>  	priv->viu.osd[0].enabled = false;
>  	priv->viu.osd[0].commit = false;
> +	priv->viu.osd[1].enabled = false;
> +	priv->viu.osd[1].commit = false;
> +	meson_crtc_flush_osd(priv, 1);
>  	spin_unlock_irqrestore(&priv->drm->event_lock, flags);
>  
>  	priv->viu.vd1_enabled = false;
> @@ -205,6 +252,8 @@ static void meson_crtc_atomic_disable(struct drm_crtc *crtc,
>  
>  	priv->viu.osd[0].enabled = false;
>  	priv->viu.osd[0].commit = false;
> +	priv->viu.osd[1].enabled = false;
> +	priv->viu.osd[1].commit = false;

[Severity: Medium]
Should meson_crtc_atomic_disable() acquire priv->drm->event_lock around the
priv->viu.osd state clear and VPP_MISC update, like
meson_g12a_crtc_atomic_disable() does?

drm_crtc_vblank_off() does not wait for an in-flight meson_irq() on another
CPU, and meson_crtc_disable_vblank() leaves the hardware vsync interrupt
enabled when meson_crtc->vsync_forced is set (such as on GXM with AFBC).
Without event_lock, meson_crtc_irq() can race with
meson_crtc_atomic_disable():

CPU0                                CPU1
meson_crtc_atomic_disable()         meson_crtc_irq()
  drm_crtc_vblank_off(crtc)           spin_lock_irqsave(&event_lock)
  priv->viu.osd[0].enabled = false    if (osd[0].enabled && osd[0].commit)
  ...                                   meson_crtc_enable_osd1()
  writel_bits_relaxed(..., VPP_MISC)      writel_bits_relaxed(..., VPP_MISC)
                                        priv->afbcd.ops->enable(priv)
                                      spin_unlock_irqrestore(&event_lock)

This can corrupt VPP_MISC or leave OSD1 postblend and AFBC enabled after
the CRTC is disabled.

> @@ -248,6 +297,7 @@ static void meson_crtc_atomic_flush(struct drm_crtc *crtc,
>  
>  	spin_lock_irqsave(&priv->drm->event_lock, flags);
>  	priv->viu.osd[0].commit = true;
> +	priv->viu.osd[1].commit = true;
>  	priv->viu.vd1_commit = true;
>  	spin_unlock_irqrestore(&priv->drm->event_lock, flags);
>  }
> @@ -303,7 +353,8 @@ static void meson_g12a_crtc_enable_osd1(struct meson_drm *priv)
>  	writel_relaxed(priv->viu.osd[0].blend_size,
>  		       priv->io_base +
>  		       _REG(VIU_OSD_BLEND_BLEND0_SIZE));
> -	writel_relaxed(priv->viu.osd[0].blend_size,
> +	writel_relaxed(priv->viu.osd[1].enabled ? priv->viu.osd[1].blend_size :
> +		       priv->viu.osd[0].blend_size,
>  		       priv->io_base +
>  		       _REG(VIU_OSD_BLEND_BLEND1_SIZE));
>  	writel_bits_relaxed(3 << 8, 3 << 8,
> @@ -343,6 +394,12 @@ void meson_crtc_irq(struct meson_drm *priv)
>  
>  	spin_lock_irqsave(&priv->drm->event_lock, flags);
>  
> +	if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) &&
> +	    priv->viu.osd[1].commit) {
> +		meson_crtc_flush_osd(priv, 1);
> +		priv->viu.osd[1].commit = false;
> +	}
> +
>  	/* Update the OSD registers */
>  	if (priv->viu.osd[0].enabled && priv->viu.osd[0].commit) {

[Severity: Medium]
Can priv->viu.osd[0].commit stay stuck at true when OSD1 is disabled while
the CRTC remains active?

meson_crtc_atomic_flush() sets both osd[0].commit and osd[1].commit to true
on every CRTC flush, including commits where OSD1 is disabled and only OSD2
or VD1 is active.  Unlike osd[1].commit, meson_crtc_irq() only clears
osd[0].commit when osd[0].enabled is true.

If a later atomic commit re-enables OSD1 and also updates or disables OSD2,
meson_plane_atomic_update() sets osd[0].enabled = true and drops event_lock
before OSD2's plane callback and meson_crtc_atomic_flush() run:

CPU0                                      <hardirq>
drm_atomic_helper_commit_planes()
  meson_plane_atomic_update(OSD1)
    spin_lock_irqsave(&event_lock)
    osd[0].enabled = true
    spin_unlock_irqrestore(&event_lock)
                                          meson_crtc_irq()
                                            /* osd[0].commit was already true */
                                            meson_crtc_flush_osd(priv, 0)
                                            meson_g12a_crtc_enable_osd1()
                                              /* uses stale osd[1] state */
  meson_plane_atomic_update(OSD2)
  meson_crtc_atomic_flush()

This flushes OSD1 before meson_crtc_atomic_flush() and programs
VIU_OSD_BLEND_BLEND1_SIZE with stale osd[1].enabled and osd[1].blend_size
for one frame.

> diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c
> index eb6a6f44cb2de..c6c0f4cc28b4b 100644
> --- a/drivers/gpu/drm/meson/meson_viu.c
> +++ b/drivers/gpu/drm/meson/meson_viu.c
> @@ -428,6 +428,7 @@ void meson_viu_init(struct meson_drm *priv)
>  		meson_viu_load_matrix(priv);
>  	else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
>  		meson_viu_set_g12a_osd_matrix(priv, 0, RGB709_to_YUV709l_coeff);
> +		meson_viu_set_g12a_osd_matrix(priv, 1, RGB709_to_YUV709l_coeff);

[Severity: Medium]
Does VPP_WRAP_OSD2_MATRIX_EN_CTRL also need to be disabled when driving a
MIPI-DSI output?

meson_viu_set_g12a_osd_matrix(priv, 1, ...) enables BIT(0) of
VPP_WRAP_OSD2_MATRIX_EN_CTRL to convert OSD2 from RGB to YUV.  However, the
G12A MIPI-DSI encoder configures ENCL for RGB input and only toggles
VPP_WRAP_OSD1_MATRIX_EN_CTRL:

drivers/gpu/drm/meson/meson_encoder_dsi.c:meson_encoder_dsi_atomic_enable() {
	...
	writel_bits_relaxed(BIT(0), 0, priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_EN_CTRL));

	writel_relaxed(1, priv->io_base + _REG(ENCL_VIDEO_EN));
}

drivers/gpu/drm/meson/meson_encoder_dsi.c:meson_encoder_dsi_atomic_disable() {
	...
	writel_bits_relaxed(BIT(0), BIT(0), priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_EN_CTRL));
}

On a MIPI-DSI panel, OSD2 will convert its RGB pixels to YUV before
blending into the RGB pipeline, causing wrong colors on the overlay plane.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-meson-g12a-osd2-v1-0-aa982300c20e@baylibre.com?part=8

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2026-11-30 22:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 21:57 [PATCH 0/8] drm/meson: add a second RGB plane on G12A Guillaume La Roque
2026-11-30 21:57 ` [PATCH 1/8] drm/meson: honor framebuffer offsets for the primary plane Guillaume La Roque
2026-11-30 21:57 ` [PATCH 2/8] drm/meson: isolate primary plane scaler setup Guillaume La Roque
2026-11-30 21:57 ` [PATCH 3/8] drm/meson: keep RGB scanout state per OSD Guillaume La Roque
2026-11-30 21:57 ` [PATCH 4/8] drm/meson: parameterize the G12A OSD color matrix setup Guillaume La Roque
2026-11-30 21:57 ` [PATCH 5/8] drm/meson: handle primary plane zpos allocation failure Guillaume La Roque
2026-11-30 21:57 ` [PATCH 6/8] drm/meson: select RGB plane registers by OSD index Guillaume La Roque
2026-11-30 21:57 ` [PATCH 7/8] drm/meson: serialize OSD state updates with the IRQ Guillaume La Roque
2026-11-30 22:14   ` sashiko-bot
2026-11-30 21:57 ` [PATCH 8/8] drm/meson: add a linear RGB overlay on G12A OSD2 Guillaume La Roque
2026-11-30 22:16   ` sashiko-bot [this message]

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-242095@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