Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/meson: missing event_lock around osd[0] disable in
  meson_crtc_atomic_disable()
--

commit e0db1ea984d5b9d13ce988817e791f6169eef00f
Author: Guillaume La Roque <[email protected]>

drm/meson: serialize OSD state updates with the IRQ

This commit uses event_lock to serialize OSD state updates and commit
flags across atomic flush, plane/CRTC disable, and the CRTC IRQ handler.

> diff --git a/drivers/gpu/drm/meson/meson_crtc.c 
> b/drivers/gpu/drm/meson/meson_crtc.c
> index 55edb8e2e1af4..b2181151acd67 100644
> --- a/drivers/gpu/drm/meson/meson_crtc.c
> +++ b/drivers/gpu/drm/meson/meson_crtc.c
> @@ -170,13 +170,16 @@ static void meson_g12a_crtc_atomic_disable(struct 
> drm_crtc *crtc,
>  {
>       struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
>       struct meson_drm *priv = meson_crtc->priv;
> +     unsigned long flags;
>  
>       DRM_DEBUG_DRIVER("\n");
>  
>       drm_crtc_vblank_off(crtc);
>  
> +     spin_lock_irqsave(&priv->drm->event_lock, flags);
>       priv->viu.osd[0].enabled = false;
>       priv->viu.osd[0].commit = false;
> +     spin_unlock_irqrestore(&priv->drm->event_lock, flags);
>  
>       priv->viu.vd1_enabled = false;
>       priv->viu.vd1_commit = false;

[Severity: Medium]
Should meson_crtc_atomic_disable() also take priv->drm->event_lock when
clearing priv->viu.osd[0].enabled and priv->viu.osd[0].commit?

drivers/gpu/drm/meson/meson_crtc.c:meson_crtc_atomic_disable() {
    ...
        drm_crtc_vblank_off(crtc);

        priv->viu.osd[0].enabled = false;
        priv->viu.osd[0].commit = false;
    ...
        /* Disable VPP Postblend */
        writel_bits_relaxed(VPP_OSD1_POSTBLEND | VPP_VD1_POSTBLEND |
                            VPP_VD1_PREBLEND | VPP_POSTBLEND_ENABLE, 0,
                            priv->io_base + _REG(VPP_MISC));
    ...
}

drm_crtc_vblank_off() does not disable hardware vsync when vsync_forced is
set (e.g. on GXM with AFBCD active) and does not wait for an in-flight
meson_crtc_irq() to complete.  Without event_lock,
meson_crtc_atomic_disable() can run concurrently with meson_crtc_irq() on
non-G12A SoCs:

CPU0                              CPU1
meson_crtc_irq()                  meson_crtc_atomic_disable()
  spin_lock_irqsave(&event_lock)
  if (osd[0].enabled &&
      osd[0].commit)
                                    osd[0].enabled = false;
                                    osd[0].commit = false;
                                    writel_bits_relaxed(..., 0,
                                                        ... + _REG(VPP_MISC))
    meson_crtc_enable_osd1()
      writel_bits_relaxed(
        VPP_OSD1_POSTBLEND, ...,
        ... + _REG(VPP_MISC))     <-- re-enables OSD1 / races on VPP_MISC
    afbcd.ops->enable()
  spin_unlock_irqrestore(&event_lock)

This can corrupt the read-modify-write on VPP_MISC or leave OSD1 and AFBCD
enabled after CRTC disable.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=7

Reply via email to