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 <[email protected]> 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/[email protected]?part=8
