mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Damon Ding <damon.ding@rock-chips.com>
To: aiyengar1990@gmail.com, Vinod Koul <vkoul@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Cc: linux-phy@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] phy: rockchip: samsung-hdptx: Power down the lanes on phy_power_off()
Date: Mon, 30 Nov 2026 17:18:57 +0800	[thread overview]
Message-ID: <98be600c-2595-495f-a648-5861b418bf09@rock-chips.com> (raw)
In-Reply-To: <20261110-hdptx-lanes-pwroff-v1-1-c2f85b7e06a4@gmail.com>

Hi Arun,

On 11/10/2026 3:16 PM, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
> 
> Since the PHY became a clock provider, rk_hdptx_phy_power_off() does
> nothing but drop the shared usage count, and the PHY is only really
> disabled when that count reaches zero.  The count is also held by every
> clock consumer of the PHY PLL, so with a clock reference outstanding
> the lanes keep driving the link after the HDMI controller has asked for
> the PHY to be powered off.
> 
> On RK3588 a clock reference is almost always outstanding: the VOP lists
> the PHY clock among its clocks so it can source its DCLK from it, and
> the Rockchip power domain driver puts every clock of a device under
> pm_clk, which prepares the PHY clock (i.e. bumps the usage count)
> whenever the VOP is runtime active.  As soon as any other video port is
> in use, e.g. a DP output, switching the HDMI CRTC off therefore leaves
> the HDMI lanes enabled and the TMDS clock on the cable, so the sink
> never sees the link go away.  The lanes stay on until the whole VOP
> goes to runtime suspend.
> 
> The lanes belong to the PHY consumer alone, whereas the PLL is shared
> with the clock consumers.  Hence disable the lane output and hold the
> lanes in reset in rk_hdptx_phy_power_off() regardless of the usage
> count, and keep leaving the PLL to the count.  This is the state the
> PHY is in between PLL and lane bring-up anyway, and the next
> rk_hdptx_phy_power_on() restores the lanes through the regular
> rk_hdptx_post_enable_lane() path, so no additional PLL re-init is
> needed.  The vendor driver does the same: its power_off callback only
> clears the lane enable bits, leaving the PLL to the clock refcount.
> 
> The DP mode is left untouched: its PLL is not exposed as a clock and
> the lanes are torn down by rk_hdptx_dp_reset() from the usage count.
> 
> Fixes: c4b09c562086 ("phy: phy-rockchip-samsung-hdptx: Add clock provider support")
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
> ---
> The problem was found on an Orange Pi 5 (RK3588S): with the HDMI output
> switched off, clk_summary still showed clk_hdmiphy_pixel0 at
> prepare/enable count 1/1, held by the VOP through pm_clk, so
> phy_power_off() never reached rk_hdptx_phy_disable() and the PHY lanes
> stayed on across DPMS off. Rockchip's vendor kernel only clears the
> lane enable register (LNTOP_REG0207) in its power_off callback too.
> 
> Tested on the same board: a trace of the PHY register writes shows each
> HDMI CRTC ACTIVE=0 commit writing 0 to LNTOP_REG0207 from
> rk_hdptx_phy_power_off(), the lanes staying off for the 3 s off window,
> and power_on writing 0xf back with the picture returning. A run of 102
> off/on transitions over a range of TMDS modes, checked with a camera on
> the TV, gave a correct picture every time, no "Failed to get PHY lane
> lock" message, and three suspend-to-idle cycles resumed normally. The
> patch has been in the board's kernel since.
> 
> This patch was developed with Claude (Anthropic) as a coding assistant:
> it wrote the code and the commit message, and I reviewed and tested it
> as described above.
> ---
>   drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
> index 6879eecc5a9f..751bb503dcfe 100644
> --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
> +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
> @@ -1768,10 +1768,25 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
>   	return ret;
>   }
>   
> +static void rk_hdptx_lane_disable(struct rk_hdptx_phy *hdptx)
> +{
> +	regmap_update_bits(hdptx->regmap, LNTOP_REG(0207), LANE_EN_MASK,
> +			   FIELD_PREP(LANE_EN_MASK, 0));
> +	reset_control_assert(hdptx->rsts[RST_LANE].rstc);
> +}
> +
>   static int rk_hdptx_phy_power_off(struct phy *phy)
>   {
>   	struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
>   
> +	/*
> +	 * The lanes are owned by the PHY consumer alone, hence shut them
> +	 * down right away.  The PLL is shared with the clock consumers, so
> +	 * leave its fate to the usage count.
> +	 */
> +	if (phy_get_mode(phy) != PHY_MODE_DP)
> +		rk_hdptx_lane_disable(hdptx);
> +
>   	return rk_hdptx_phy_consumer_put(hdptx, false);
>   }
>   
> 

We recently ran into the same issue, so this approach looks good
to me:

Reviewed-by: Damon Ding <damon.ding@rock-chips.com>

TIP: The commit message seems a bit long (AI tends to describe
everything in great detail, which loses the focus). Could we
trim it down? I think the core point is that phy power_off
disables the lane output directly while keeping the PLL running
for the clock consumers.

Best regards,
Damon

      parent reply	other threads:[~2026-11-30  9:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  7:16 Arun Iyengar via B4 Relay
2026-11-27 12:23 ` Manivannan Sadhasivam
2026-11-29 17:12 ` Heiko Stuebner
2026-11-30  9:18 ` Damon Ding [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98be600c-2595-495f-a648-5861b418bf09@rock-chips.com \
    --to=damon.ding@rock-chips.com \
    --cc=aiyengar1990@gmail.com \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mani@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®