On 11/17/26 21:03, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [High] drm/meson: dw-hdmi: suspend/resume order breaks PHY state and
> HDMI output
> - [Medium] drm/meson: dw-hdmi: missing phy_exit() on dw_hdmi_probe()
> failure
> - [Medium] drm/meson: dw-hdmi: premature PHY teardown in
> meson_dw_hdmi_unbind()
> --
>
> commit 91e31ad4e0b36171e791e7c0487c9a4c66b12b31
> Author: Ronald Claveau <[email protected]>
>
> drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY
>
> This commit converts meson_dw_hdmi from direct HHI_HDMI_PHY_CNTL0..5
> register writes to the generic PHY API, with a legacy fallback when the
> device tree lacks a "phys" property.
>
>> diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c
>> b/drivers/gpu/drm/meson/meson_dw_hdmi.c
>> index 20a821936b3af..f28cc1e6ee1df 100644
>> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
>> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
>
>
> [Severity: Medium]
> Does meson_dw_hdmi_bind() leak a phy_init() reference if dw_hdmi_probe()
> fails later in this function (for example with -EPROBE_DEFER when the DDC
> I2C bus is not ready)?
>
> When the PHY comes from the external PHY provider, devres cleanup on a
> failed component bind only calls phy_put(), leaving phy->init_count at 1.
> On the next bind attempt, meson_dw_hdmi_init() resets hdmitx_phy and calls
> phy_init(), which sees init_count > 0 and skips phy->ops->init(), leaving
> HHI_HDMI_PHY_CNTL0 and HHI_HDMI_PHY_CNTL1 uninitialized after the hardware
> reset.
>
I will move revert this change.
> [Severity: Medium]
> Can tearing down meson_dw_hdmi->phy before devm_free_irq() and
> dw_hdmi_unbind() cause a use-after-free in dw_hdmi_top_thread_irq()?
>
> CPU0 CPU1
> meson_dw_hdmi_unbind()
> phy_exit(meson_dw_hdmi->phy)
> devm_phy_destroy(..., meson_dw_hdmi->phy)
> dw_hdmi_top_thread_irq()
> dw_hdmi_setup_rx_sense()
> ...
> dw_hdmi_phy_init()
> phy_configure(dw_hdmi->phy,
> ...)
> <-- use-after-free
> devm_free_irq(...)
> dw_hdmi_unbind(...)
>
> In the legacy PHY path, devm_phy_destroy() immediately unregisters and
> frees meson_dw_hdmi->phy while the threaded HPD interrupt handler is still
> active and can invoke dw_hdmi_phy_init() or dw_hdmi_phy_disable(). Even
> with a DT PHY, HPD handling or dw_hdmi_unbind() can access the PHY after
> phy_exit(). Should phy_exit() and devm_phy_destroy() run after
> devm_free_irq() and dw_hdmi_unbind()?
>
I will move the phy_destroy after unbind, phy_exit will be on
phy_disable only.
> [Severity: High]
> Does calling phy_exit() in meson_dw_hdmi_pm_suspend() and phy_init() in
> meson_dw_hdmi_pm_resume() break HDMI output across system suspend/resume?
>
> Because the HDMI TX platform device sits after the VPU master device on
> dpm_list (both from DT node order and because devm_phy_optional_get() adds
> a stateless device link to the PHY that reorders the consumer to the tail
> of dpm_list), system suspend runs meson_dw_hdmi_pm_suspend() before
> meson_drv_pm_suspend(), and system resume runs meson_drv_pm_resume()
> before meson_dw_hdmi_pm_resume().
>
> On suspend, meson_dw_hdmi_pm_suspend() calls phy_exit() while the PHY is
> still powered on, before meson_drv_pm_suspend() ->
> drm_mode_config_helper_suspend() -> dw_hdmi_phy_disable() calls
> phy_power_off().
>
> On resume, meson_drv_pm_resume() -> drm_mode_config_helper_resume() ->
> dw_hdmi_phy_init() calls phy_configure() and phy_power_on() while
> phy->init_count is still 0. Then meson_dw_hdmi_pm_resume() runs
> meson_dw_hdmi_init(), which resets hdmitx_phy and calls phy_init(); since
> phy->power_count > phy->init_count, phy_init() warns ("phy_power_on was
> called before phy_init") and runs meson_hdmi_phy_init(), overwriting
> HHI_HDMI_PHY_CNTL0 and HHI_HDMI_PHY_CNTL1 with cntl0_init and cntl1_init
> and clobbering the mode that meson_drv_pm_resume() just configured and
> powered on.
>
I will put phy_init in dw_hdmi_phy_init and phy_exit in
dw_hdmi_phy_disable for v2.
--
Best regards,
Ronald