Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/msm/dp: unreachable is_edp fallback in
  msm_dp_aux_should_reset()
- [Medium] drm/msm/dp: msm_dp_aux_transfer() skips phy_calibrate() on
  DP_AUX_ERR_TOUT
--

commit c2e9bc4891741d368936607a2c4a882af3e31c41
Author: Robert Ijtsma <[email protected]>

drm/msm/dp: clear AUX_TRANS_CTRL on reset and enable HPD_REFTIMER

This commit clears REG_DP_AUX_TRANS_CTRL during AUX reset, manages
DP_DP_HPD_REFTIMER_ENABLE across msm_dp_aux_enable() and
msm_dp_aux_disable(), and resets the AUX controller on transfer errors and
DP_AUX_ERR_TOUT timeouts even when internal HPD is disabled.

> diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c
> index b52393dcc0670..9a996fe7dbddb 100644
> --- a/drivers/gpu/drm/msm/dp/dp_aux.c
> +++ b/drivers/gpu/drm/msm/dp/dp_aux.c

[ ... ]

> @@ -101,11 +108,23 @@ static void msm_dp_aux_enable(struct msm_dp_aux_private 
> *aux)
>  
>  static void msm_dp_aux_disable(struct msm_dp_aux_private *aux)
>  {
> -     u32 aux_ctrl;
> +     u32 aux_ctrl, reftimer;
>  
>       aux_ctrl = msm_dp_read_aux(aux, REG_DP_AUX_CTRL);
>       aux_ctrl &= ~DP_AUX_CTRL_ENABLE;
>       msm_dp_write_aux(aux, REG_DP_AUX_CTRL, aux_ctrl);
> +
> +     reftimer = msm_dp_read_aux(aux, REG_DP_DP_HPD_REFTIMER);
> +     reftimer &= ~DP_DP_HPD_REFTIMER_ENABLE;
> +     msm_dp_write_aux(aux, REG_DP_DP_HPD_REFTIMER, reftimer);
> +}
> +
> +static bool msm_dp_aux_should_reset(struct msm_dp_aux_private *aux)
> +{
> +     if (msm_dp_read_aux(aux, REG_DP_DP_HPD_CTRL) & DP_DP_HPD_CTRL_HPD_EN)
> +             return msm_dp_aux_is_link_connected(&aux->msm_dp_aux);
> +
> +     return aux->is_edp || aux->enable_xfers;
>  }

[Severity: Medium]
Can aux->is_edp ever be reached in msm_dp_aux_should_reset()?

For eDP instances, msm_dp_pm_runtime_resume() unconditionally calls
msm_dp_aux_hpd_enable(), which sets DP_DP_HPD_CTRL_HPD_EN in
REG_DP_DP_HPD_CTRL:

drivers/gpu/drm/msm/dp/dp_display.c:msm_dp_pm_runtime_resume() {
        ...
        msm_dp_display_host_init(dp);
        if (dp->msm_dp_display.is_edp) {
                msm_dp_aux_hpd_enable(dp->aux);
                msm_dp_display_host_phy_init(dp);
        }
        ...
}

Because DP_DP_HPD_CTRL_HPD_EN is always set while eDP is active,
msm_dp_aux_should_reset() always takes the first branch and checks
msm_dp_aux_is_link_connected().  On eDP boards where the SoC internal HPD
pin is not wired (such as panels using no-hpd or GPIO HPD),
msm_dp_aux_is_link_connected() returns 0 and skips resetting the AUX
controller on transfer failures or timeouts.  Should aux->is_edp be
checked before testing DP_DP_HPD_CTRL_HPD_EN?

> @@ -412,7 +431,7 @@ static ssize_t msm_dp_aux_transfer(struct drm_dp_aux 
> *msm_dp_aux,
>                               phy_calibrate(aux->phy);
>               }
>               /* reset aux if link is in connected state */
> -             if (msm_dp_aux_is_link_connected(msm_dp_aux))
> +             if (msm_dp_aux_should_reset(aux))
>                       msm_dp_aux_reset(aux);
>       } else {
>               aux->retry_cnt = 0;
> @@ -432,6 +451,8 @@ static ssize_t msm_dp_aux_transfer(struct drm_dp_aux 
> *msm_dp_aux,
>                       msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_NACK : 
> DP_AUX_I2C_REPLY_NACK;
>                       break;
>               case DP_AUX_ERR_TOUT:
> +                     if (msm_dp_aux_should_reset(aux))
> +                             msm_dp_aux_reset(aux);
>                       ret = -ETIMEDOUT;
>                       break;
>               }

[Severity: Medium]
Does handling DP_AUX_ERR_TOUT in the else branch bypass phy_calibrate()
across repeated AUX timeouts?

With DP_DP_HPD_REFTIMER_ENABLE now always enabled in msm_dp_aux_enable(),
wire timeouts raise DP_INTR_TIMEOUT and complete aux->comp with
aux->aux_error_num = DP_AUX_ERR_TOUT before the software timeout in
msm_dp_aux_cmd_fifo_tx(), so msm_dp_aux_cmd_fifo_tx() returns ret >= 0.
The else branch then zeroes aux->retry_cnt = 0 before entering
case DP_AUX_ERR_TOUT, and because msm_dp_aux_reset() now resets the
controller cleanly for the next attempt, subsequent timeouts also complete
via DP_AUX_ERR_TOUT without ever incrementing aux->retry_cnt or calling
phy_calibrate(aux->phy) every MAX_AUX_RETRIES native attempts.

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

Reply via email to