[PATCH v2 08/11] drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY

Ronald Claveau linux-kernel-dev at aliel.fr
Sat Nov 21 11:10:13 PST 2026


On 11/20/26 20:20, sashiko-bot at kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [High] drm/meson: dw-hdmi: missing PHY init in meson_dw_hdmi_init()
>   breaks CEC/ARC
> - [Medium] drm/meson: dw-hdmi: phy_init() leak on error path in
>   dw_hdmi_phy_init()
> --
> 
> commit 9c4e52bbd305f6371ee6545c479c9a84e6845324
> Author: Ronald Claveau <linux-kernel-dev at aliel.fr>
> 
> drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY
> 
> This commit converts the Meson DW-HDMI driver from direct HHI register
> programming to the generic PHY API, with a legacy fallback when the DT
> node 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..1ca1ce6173563 100644
>> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
>> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> [ ... ]
>> @@ -364,10 +276,18 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data,
>>  	unsigned int wr_clk =
>>  		readl_relaxed(priv->io_base + _REG(VPU_HDMI_SETTING));
>>  	bool mode_is_420 = false;
>> +	unsigned int pixel_clock = mode->clock;
>> +	union phy_configure_opts opts = {};
>> +	int ret;
>>  
>>  	DRM_DEBUG_DRIVER("\"%s\" div%d\n", mode->name,
>>  			 mode->clock > 340000 ? 40 : 10);
>>  
>> +	/* Setup PHY */
>> +	ret = phy_init(dw_hdmi->phy);
>> +	if (ret)
>> +		return ret;
>> +
>>  	if (drm_mode_is_420_only(display, mode) ||
>>  	    (!is_hdmi2_sink && drm_mode_is_420_also(display, mode)) ||
>>  	    dw_hdmi_bus_fmt_is_420(hdmi))
>> @@ -392,19 +312,22 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data,
>>  	dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_TMDS_CLK_PTTN_CNTL, 0x2);
>>  
>>  	/* Setup PHY parameters */
>> -	meson_hdmi_phy_setup_mode(dw_hdmi, mode, mode_is_420);
>> -
>> -	/* Disable clock, fifo, fifo_wr */
>> -	regmap_update_bits(priv->hhi, HHI_HDMI_PHY_CNTL1, 0xf, 0);
>> +	if (mode_is_420)
>> +		pixel_clock /= 2;
>> +	opts.hdmi.tmds_char_rate = (u64)pixel_clock * 1000;
>> +	opts.hdmi.bpc = 8;
>> +	ret = phy_configure(dw_hdmi->phy, &opts);
>> +	if (ret)
>> +		return ret;
>>  
>>  	dw_hdmi_set_high_tmds_clock_ratio(hdmi, display);
>>  
>>  	msleep(100);
>>  
>>  	/* Reset PHY 3 times in a row */
>> -	meson_dw_hdmi_phy_reset(dw_hdmi);
>> -	meson_dw_hdmi_phy_reset(dw_hdmi);
>> -	meson_dw_hdmi_phy_reset(dw_hdmi);
>> +	ret = phy_power_on(dw_hdmi->phy);
>> +	if (ret)
>> +		return ret;
> 
> [Severity: Medium]
> Do the error returns from phy_configure() and phy_power_on() leak a
> dw_hdmi->phy->init_count reference?
> 
> When dw_hdmi_phy_init() fails, dw_hdmi_setup() leaves hdmi->phy.enabled
> false, so dw_hdmi_poweroff() never calls dw_hdmi_phy_disable() to balance
> phy_init() with phy_exit().  A non-VIC DMT mode with a pixel clock below
> 25.175 MHz passes meson_encoder_hdmi_mode_valid() but is rejected with
> -EINVAL by meson_hdmi_phy_configure() -> meson_hdmi_phy_find_rate(),
> permanently elevating init_count so subsequent phy_init() calls skip
> hardware initialization.
> 
> [ ... ]
> 
>> @@ -623,10 +542,6 @@ static void meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi)
>>  	/* Enable normal output to PHY */
>>  	meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_BIST_CNTL, BIT(12));
>>  
>> -	/* Setup PHY */
>> -	regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL1, meson_dw_hdmi->data->cntl1_init);
>> -	regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, meson_dw_hdmi->data->cntl0_init);
>> -
>>  	/* Enable HDMI-TX Interrupt */
>>  	meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_STAT_CLR,
>>  				       HDMITX_TOP_INTR_CORE);
> 
> [Severity: High]
> Does removing the initial PHY setup from meson_dw_hdmi_init() leave the
> HDMI TX PHY uninitialized whenever no HDMI video mode is active?
> 
> meson_dw_hdmi_init() pulses reset_control_reset(meson_dw_hdmi->hdmitx_phy)
> at bind and system resume time, while meson_venc_init() zeroes
> HHI_HDMI_PHY_CNTL0.  Commits 04703bfd7f99 ("drm/meson: dw-hdmi: power up
> phy on device init") and 08001033121d ("drm/meson: dw-hdmi: add bandgap
> setting for g12") programmed HHI_HDMI_PHY_CNTL1 and HHI_HDMI_PHY_CNTL0
> here because CEC and the G12A ARC/eARC utility pin need the PHY
> initialized even before the first HDMI modeset or when another display
> interface is used.
> 
> With phy_init() deferred to dw_hdmi_phy_init(), which dw_hdmi_setup() only
> calls when enabling an active HDMI display mode (and which
> meson_dw_hdmi_pm_resume() -> dw_hdmi_resume() does not call), the PHY
> stays in its post-reset state at boot and after resume whenever HDMI
> video is inactive.
> 

I will use v1 code and add a device link to solve suspend/resume order.

-- 
Best regards,
Ronald



More information about the linux-phy mailing list