Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/sti: hqvdp: sti_hqvdp_bind() exposes plane with clk off on
  init failure
- [Medium] drm/sti: hqvdp: sti_hqvdp_bind() leaks hqvdp->clk on error
  and unbind
--

commit a8cf3e26ef27767a003bfe97a37331241f497584
Author: Minseo Park <[email protected]>

drm/sti: hqvdp: start the XP70 from device init

This commit moves the sti_hqvdp_start_xp70() call out of
sti_hqvdp_atomic_check() and into sti_hqvdp_bind() so that atomic check
does not touch hardware or load firmware.

> diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> index 360d213f2094f..c6b6ed54b8995 100644
> --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> @@ -1081,10 +1081,6 @@ static int sti_hqvdp_atomic_check(struct drm_plane 
> *drm_plane,
>               return -EINVAL;
>       }
>  
> -     if (!hqvdp->xp70_initialized)
> -             /* Start HQVDP XP70 coprocessor */
> -             sti_hqvdp_start_xp70(hqvdp);
> -
>       if (!hqvdp->vtg_registered) {
>               /* Prevent VTG shutdown */
>               if (clk_prepare_enable(hqvdp->clk_pix_main)) {
> @@ -1333,6 +1329,9 @@ static int sti_hqvdp_bind(struct device *dev, struct 
> device *master, void *data)
>  
>       hqvdp->drm_dev = drm_dev;
>  
> +     /* Start HQVDP XP70 coprocessor */
> +     sti_hqvdp_start_xp70(hqvdp);

[Severity: High]
Can this expose the HQVDP plane with hqvdp->clk disabled when
sti_hqvdp_start_xp70() fails?

Commit e00fe64a5ccd ("drm/sti: load HQVDP firmware the first time HQVDP's
plane is used") moved firmware loading out of sti_hqvdp_bind() because the
root filesystem may not be mounted yet at bind time.  When
request_firmware() or the XP70 boot poll fails in sti_hqvdp_start_xp70(),
hqvdp->xp70_initialized stays false and hqvdp->clk is left disabled, yet
sti_hqvdp_bind() still registers the DRM plane and neither
sti_hqvdp_atomic_check() nor sti_hqvdp_atomic_update() checks
hqvdp->xp70_initialized.

A subsequent commit on the plane then performs unclocked MMIO reads and
writes in sti_hqvdp_atomic_update() (via sti_hqvdp_get_free_cmd() and
HQVDP_MBX_NEXT_CMD), which can trigger an external abort or bus hang, and
disabling the plane runs sti_hqvdp_disable() from vtg_irq_thread(), doing
unclocked MMIO and sleeping for 1000 ms in the VSync IRQ thread.

Could sti_hqvdp_start_xp70() be called from sti_hqvdp_atomic_update()
instead, with register accesses guarded by hqvdp->xp70_initialized?

> +
>       /* Create HQVDP plane once xp70 is initialized */
>       plane = sti_hqvdp_create(drm_dev, hqvdp->dev, STI_HQVDP_0);
>       if (!plane)

[Severity: Medium]
Does this leak the prepare and enable references on hqvdp->clk?

sti_hqvdp_start_xp70() calls clk_prepare_enable(hqvdp->clk), which is now
enabled unconditionally at bind time even if the plane is never used, and
nothing calls clk_disable_unprepare(hqvdp->clk) if sti_hqvdp_create() or a
later component bind fails, or when the component is unbound in
sti_hqvdp_unbind().

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

Reply via email to