Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: cadence: cdns-dphy: Handle TX clock enable failures
@ 2026-11-29 19:25 Jiawen Liu
  0 siblings, 0 replies; only message in thread
From: Jiawen Liu @ 2026-11-29 19:25 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Neil Armstrong, Manivannan Sadhasivam, linux-phy

On TI K3, the Cadence DSI bridge calls phy_power_on() during display
bring-up. Either D-PHY clock can fail to prepare if its TI SCI firmware
request fails.

cdns_dphy_power_on() ignores both clk_prepare_enable() return values.
This loses the original error and can lead to PHY register access
without a required clock. Cleanup may then release a clock reference
that was never acquired, triggering common clock framework warnings.

Return the original error before programming the PHY. If enabling the
PLL reference clock fails, release only the PSM clock. Later failures
after both clocks are enabled release them in reverse order.

Verification included static review
of the clock and PHY core paths, git diff --check, checkpatch.pl on the
diff, and a warning-free W=1 arm64 driver object build with the TI SCI
clock provider enabled. No runtime or hardware reproduction was performed.

Fixes: 7a343c8bf4b5 ("phy: Add Cadence D-PHY support")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
 drivers/phy/cadence/cdns-dphy.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/cadence/cdns-dphy.c b/drivers/phy/cadence/cdns-dphy.c
index 483e35c82a113..ceba1154f8f24 100644
--- a/drivers/phy/cadence/cdns-dphy.c
+++ b/drivers/phy/cadence/cdns-dphy.c
@@ -374,8 +374,13 @@ static int cdns_dphy_power_on(struct phy *phy)
 	if (!dphy->is_configured || dphy->is_powered)
 		return -EINVAL;
 
-	clk_prepare_enable(dphy->psm_clk);
-	clk_prepare_enable(dphy->pll_ref_clk);
+	ret = clk_prepare_enable(dphy->psm_clk);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(dphy->pll_ref_clk);
+	if (ret)
+		goto err_disable_psm_clk;
 
 	/*
 	 * Configure the internal PSM clk divider so that the DPHY has a
@@ -436,6 +441,7 @@ static int cdns_dphy_power_on(struct phy *phy)
 
 err_power_on:
 	clk_disable_unprepare(dphy->pll_ref_clk);
+err_disable_psm_clk:
 	clk_disable_unprepare(dphy->psm_clk);
 
 	return ret;
-- 
2.34.1

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-29 19:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:25 [PATCH] phy: cadence: cdns-dphy: Handle TX clock enable failures Jiawen Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox