Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/msm/dp: race in msm_dp_ctrl_link_maintenance() during
  stream disable
--

commit 92cb901a22d0365654c6eb38972e3118d6b87858
Author: Gianfranco Mariotti <[email protected]>

drm/msm/dp: reinit video_comp and guard stream state on link maintenance

This commit reinitializes ctrl->video_comp and checks ctrl->stream_clks_on
during link maintenance, turns off the pixel clock on video-ready failure
in msm_dp_ctrl_on_stream(), and takes dp->plugged_lock across display
enable and disable callbacks.

> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c 
> b/drivers/gpu/drm/msm/dp/dp_display.c
> index b8373740275bc..d522b7d254b44 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
[ ... ]
> @@ -724,6 +726,8 @@ static int msm_dp_display_disable(struct 
> msm_dp_display_private *dp,
>  {
>       struct msm_dp *msm_dp_display = &dp->msm_dp_display;
>  
> +     guard(mutex)(&dp->plugged_lock);
> +
>       if (!msm_dp_display->power_on)
>               return 0;
>  
> @@ -1504,6 +1508,8 @@ void msm_dp_display_atomic_disable(struct msm_dp *dp)
>  
>       msm_dp_display = container_of(dp, struct msm_dp_display_private, 
> msm_dp_display);
>  
> +     guard(mutex)(&msm_dp_display->plugged_lock);
> +
>       /*
>        * If .atomic_enable() bailed out - link training failure is the common
>        * case - the mainlink was never brought up and ->power_on stayed false.

[Severity: Medium]
Can an IRQ_HPD link maintenance run between msm_dp_display_atomic_disable()
and msm_dp_display_disable() and put the controller back into
DP_STATE_CTRL_SEND_VIDEO while the stream is being torn down?

CPU0                                      CPU1 (IRQ_HPD)
msm_dp_display_atomic_disable()
  mutex_lock(&dp->plugged_lock)
  msm_dp_ctrl_push_idle()
  mutex_unlock(&dp->plugged_lock)
                                          msm_dp_irq_hpd_handle()
                                            mutex_lock(&dp->plugged_lock)
                                            ...
                                            msm_dp_ctrl_link_maintenance()
                                              /* stream_clks_on is still true */
                                              msm_dp_ctrl_push_idle()
                                              ...
                                              msm_dp_write_link(...,
                                                DP_STATE_CTRL_SEND_VIDEO)
                                              msm_dp_ctrl_wait4video_ready()
                                                <-- times out, stream stopped
                                            mutex_unlock(&dp->plugged_lock)
msm_dp_display_atomic_post_disable()
  msm_dp_display_audio_notify_disable()
  msm_dp_display_disable()
    mutex_lock(&dp->plugged_lock)
    msm_dp_ctrl_off_pixel_clk()
      ctrl->stream_clks_on[...] = false

msm_dp_display_atomic_disable() pushes the link to idle and drops
dp->plugged_lock, but ctrl->stream_clks_on[panel->stream_id] is not cleared
until msm_dp_display_disable() runs in msm_dp_display_atomic_post_disable()
(after DPU encoder disable and msm_dp_display_audio_notify_disable()).

If an IRQ_HPD arrives in that window, msm_dp_ctrl_link_maintenance() sees
ctrl->stream_clks_on[panel->stream_id] == true, drives PUSH_IDLE a second
time (timing out on ctrl->idle_comp), retrains, writes
DP_STATE_CTRL_SEND_VIDEO, and times out in msm_dp_ctrl_wait4video_ready(),
leaving the controller in SEND_VIDEO when msm_dp_display_disable() turns
off the pixel clock.

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

Reply via email to