Thank you for your contribution! Sashiko AI review found 2 potential issue(s) 
to consider:
- [High] Unmapped hardware interrupt status bits from AUX HPD corrupt the HPD 
event handler logic, misclassifying interrupts.
- [Medium] Missing `legacy_regoff` when polling `MTK_DP_AUX_P0_364C` via 
`regmap_read_poll_timeout`.
--

commit 01574255cf70f390467f27095e6af27a1759e430
Author: AngeloGioacchino Del Regno <[email protected]>
drm/mediatek: mtk_dp: Add support for HotPlug Detection in DP AUX

This patch adds support for using the DP AUX channel to perform hotplug
detection (HPD) on newer MediaTek DisplayPort IPs. It enables configuring
and performing HPD in AUX, checking the correct HPD strategy with a new
platform data variable.

> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c 
> b/drivers/gpu/drm/mediatek/mtk_dp.c
> index 5272e717bfda0..2d58eacb3d3e6 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c

> [ ... ]

> @@ -1046,7 +1047,21 @@ static u32 mtk_dp_swirq_get_clear(struct mtk_dp 
> *mtk_dp)
>       return irq_status;
>  }
>  
> -static u32 mtk_dp_hwirq_get_clear(struct mtk_dp *mtk_dp)
> +static u32 mtk_dp_aux_hwirq_get_clear(struct mtk_dp *mtk_dp)
> +{
> +     u32 irq_status = mtk_dp_read(mtk_dp, MTK_DP_AUX_TX_P0_INT_STA);
> +
> +     if (irq_status) {
> +             mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_TX_P0_INT_CLR,
> +                                irq_status, irq_status);
> +             mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_TX_P0_INT_CLR,
> +                                0, irq_status);
> +     }
> +
> +     return irq_status;
> +}

[Severity: High]
Is it safe to return the raw hardware interrupt bits here without mapping them
to the expected software constants?

In mtk_dp_hpd_event(), the returned irq_status is checked against software
constants like MTK_DP_HPD_INTERRUPT, which is defined as BIT(3):

        if (irq_status & MTK_DP_HPD_INTERRUPT)
                mtk_dp->irq_thread_handle |= MTK_DP_THREAD_HPD_EVENT;

        /* Cable state is changed. */
        if (irq_status != MTK_DP_HPD_INTERRUPT) {
                mtk_dp->irq_thread_handle |= MTK_DP_THREAD_CABLE_STATE_CHG;
                cable_sta_chg = true;
        }

However, HPD_INTERRUPT_EVENT read from MTK_DP_AUX_TX_P0_INT_STA is BIT(2).

If we return the raw BIT(2) here, won't it fail the check for
MTK_DP_HPD_INTERRUPT and incorrectly fall into the cable state change path?
Could this misclassify short HPD pulses as cable state changes, potentially
causing spurious link teardowns?

> [ ... ]

> @@ -2125,10 +2194,15 @@ static int mtk_dp_wait_hpd_asserted(struct drm_dp_aux 
> *mtk_aux, unsigned long wa
>       u32 val;
>       int ret;
>  
> -     ret = regmap_read_poll_timeout(mtk_dp->regs,
> -                                    MTK_DP_TRANS_P0_3414 + 
> mtk_dp->legacy_regoff,
> -                                    val, !!(val & HPD_DB_DP_TRANS_P0_MASK),
> -                                    wait_us / 100, wait_us);
> +     if (mtk_dp->data->aux_hpd_supported)
> +             ret = regmap_read_poll_timeout(mtk_dp->regs, MTK_DP_AUX_P0_364C,
> +                                            val, !!(val & 
> HPD_STATUS_DP_AUX_TX_P0_MASK),
> +                                            wait_us / 100, wait_us);

[Severity: Medium]
Should this regmap_read_poll_timeout() call include mtk_dp->legacy_regoff?

The trans HPD path below adds mtk_dp->legacy_regoff to the register offset,
and standard mtk_dp_read() calls also apply it.

If a platform uses the legacy DT binding but has aux_hpd_supported enabled,
could omitting the offset cause reads from the wrong hardware address?

> +     else
> +             ret = regmap_read_poll_timeout(mtk_dp->regs,
> +                                            MTK_DP_TRANS_P0_3414 + 
> mtk_dp->legacy_regoff,
> +                                            val, !!(val & 
> HPD_DB_DP_TRANS_P0_MASK),
> +                                            wait_us / 100, wait_us);
>       if (ret) {
>               mtk_dp->train_info.cable_plugged_in = false;
>               return ret;

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

Reply via email to