Revert "phy: freescale: fsl-samsung-hdmi: initialize default rate"
PATCH 1/1 Revert "phy: freescale: fsl-samsung-hdmi: initialize default rate"
From: Francesco Dolcini <[email protected]>
This reverts commit c01ccf91b257741e9edc374a465126bae9ae4711.
Programming the 74.25 MHz configuration at probe fails on i.MX8MP boards, the PHY probe aborts and HDMI is no longer available:
fsl-samsung-hdmi-phy 32fdff00.phy: PLL failed to lock
fsl-samsung-hdmi-phy 32fdff00.phy: error -ETIMEDOUT: failed to configure default rate fsl-samsung-hdmi-phy 32fdff00.phy: probe with driver fsl-samsung-hdmi-phy failed with error -110
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 59 +++++--------------- 1 file changed, 15 insertions(+), 44 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +15 -44
@@ -44,8 +44,6 @@#define MHZ (1000UL * 1000UL)#endif -#define PHY_DEFAULT_RATE 74250000 -#define PHY_PLL_DIV_REGS_NUM 7struct phy_config {
@@ -491,6 +489,17 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,return ret; } +static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); + +if (!phy->cur_cfg) +return 74250000 ; + +return phy->cur_cfg->pixclk; +} +/* Helper function to lookup the available fractional-divider rate */ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate (unsigned long rate) {
@@ -511,14 +520,6 @@ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate(unsigned long r &phy_pll_cfg[i] : &phy_pll_cfg[i+1]); } -static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) -{ -struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); - -return phy->cur_cfg->pixclk; -} -static void fsl_samsung_hdmi_calculate_phy (struct phy_config *cal_phy,unsigned long rate,u8 p,u16 m,u8 s) {
@@ -639,7 +640,6 @@ static int phy_clk_register(struct fsl_samsung_hdmi_phy *phy)static int fsl_samsung_hdmi_phy_probe (struct platform_device *pdev) { -const struct phy_config *default_cfg;struct fsl_samsung_hdmi_phy *phy;int ret;
@@ -664,23 +664,6 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return dev_err_probe (phy->dev,PTR_ERR (phy->refclk),"failed to get ref clk\n" ); -/* -* Establish the rate reported by recalc_rate() before registering the -* clock. Otherwise CCF may skip the first set_rate() when it requests -* the assumed default rate, leaving the PHY unconfigured. -*/ - ret =clk_prepare_enable (phy->refclk); -if (ret) -return dev_err_probe (phy->dev, ret, -"failed to enable ref clk\n" ); - - default_cfg =fsl_samsung_hdmi_phy_lookup_rate (PHY_DEFAULT_RATE ); - ret =fsl_samsung_hdmi_phy_configure (phy, default_cfg); -clk_disable_unprepare (phy->refclk); -if (ret) -return dev_err_probe (phy->dev, ret, -"failed to configure default rate\n" ); -pm_runtime_get_noresume (phy->dev);pm_runtime_set_active (phy->dev);pm_runtime_enable (phy->dev);
@@ -719,7 +702,7 @@ static int __maybe_unused fsl_samsung_hdmi_phy_suspend(struct device *dev)static int __maybe_unused fsl_samsung_hdmi_phy_resume (struct device *dev) {struct fsl_samsung_hdmi_phy *phy =dev_get_drvdata (dev); -int ret; +int ret =0 ; ret =clk_prepare_enable (phy->apbclk);if (ret) {
@@ -727,23 +710,11 @@ static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev)return ret; } -if (!phy->cur_cfg) -return 0 ; - - ret =clk_prepare_enable (phy->refclk); -if (ret) { -dev_err (phy->dev,"failed to enable ref clk\n" ); - goto disable_apbclk; - } - - ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); -clk_disable_unprepare (phy->refclk); -if (!ret) -return 0 ; +if (phy->cur_cfg) + ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); -disable_apbclk: -clk_disable_unprepare (phy->apbclk);return ret; + } static DEFINE_RUNTIME_DEV_PM_OPS(fsl_samsung_hdmi_phy_pm_ops,
Signature · 1 line
2.47.3
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] phy: freescale: fsl-samsung-hdmi: apbclk leak in fsl_samsung_hdmi_phy_resume() - [Medium] phy…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] phy: freescale: fsl-samsung-hdmi: apbclk leak in fsl_samsung_hdmi_phy_resume()
- [Medium] phy: freescale: fsl-samsung-hdmi: NULL deref in fsl_samsung_hdmi_phy_find_settings()
--
commit 9481293ffcfc6d865a5df21db581bbc72e6903fc
Author: Francesco Dolcini <[email protected]>
Revert "phy: freescale: fsl-samsung-hdmi: initialize default rate"
This commit reverts commit c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi:
initialize default rate") so that the driver no longer configures the 74.25 MHz default rate during probe or toggles refclk on resume.
Quoted 4 lines
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +0
-0
[ ... ]
Quoted 14 lines
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +0
-10@@ -664,23 +664,6 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return dev_err_probe (phy->dev,PTR_ERR (phy->refclk),"failed to get ref clk\n" ); -/* -* Establish the rate reported by recalc_rate() before registering the -* clock. Otherwise CCF may skip the first set_rate() when it requests -* the assumed default rate, leaving the PHY unconfigured. -*/ - ret =clk_prepare_enable (phy->refclk); -if (ret) -return dev_err_probe (phy->dev, ret, -"failed to enable ref clk\n" ); -
drivers/phy/freescale/phy-fsl-samsung-hdmi.c static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev) · line 669
Quoted 10 lines
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +0
-7- default_cfg =fsl_samsung_hdmi_phy_lookup_rate (PHY_DEFAULT_RATE ); - ret =fsl_samsung_hdmi_phy_configure (phy, default_cfg); -clk_disable_unprepare (phy->refclk); -if (ret) -return dev_err_probe (phy->dev, ret, -"failed to configure default rate\n" ); -pm_runtime_get_noresume (phy->dev);pm_runtime_set_active (phy->dev);pm_runtime_enable (phy->dev);
[Severity: Medium]
With phy->cur_cfg left NULL until the first fsl_samsung_hdmi_phy_configure() call, can fsl_samsung_hdmi_phy_find_settings() dereference a NULL phy->cur_cfg when debug logging is enabled?
Both fsl_samsung_hdmi_phy_clk_determine_rate() and fsl_samsung_hdmi_phy_clk_set_rate() call fsl_samsung_hdmi_phy_find_settings() before fsl_samsung_hdmi_phy_configure() sets phy->cur_cfg. When the requested rate is not an exact match and is closer to fract_div_phy->pixclk than int_div_clk, fsl_samsung_hdmi_phy_find_settings() logs phy->cur_cfg->pixclk instead of fract_div_phy->pixclk:
drivers/phy/freescale/phy-fsl-samsung-hdmi.c:fsl_samsung_hdmi_phy_find_settings() {
...
/* Calculate the absolute value of the differences and return whichever is closest */
if (abs((long)rate - (long)int_div_clk) <
abs((long)rate - (long)fract_div_phy->pixclk)) {
dev_dbg(phy->dev, "integer divider = %u\n", calculated_phy_pll_cfg.pixclk);
return &calculated_phy_pll_cfg;
}
dev_dbg(phy->dev, "fractional divider = %u\n", phy->cur_cfg->pixclk);
return fract_div_phy;
}Quoted 24 lines
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +1
-12@@ -719,7 +702,7 @@ static int __maybe_unused fsl_samsung_hdmi_phy_suspend(struct device *dev)static int __maybe_unused fsl_samsung_hdmi_phy_resume (struct device *dev) {struct fsl_samsung_hdmi_phy *phy =dev_get_drvdata (dev); -int ret; +int ret =0 ; ret =clk_prepare_enable (phy->apbclk);if (ret) {@@ -727,23 +710,11 @@ static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev)return ret; } -if (!phy->cur_cfg) -return 0 ; - - ret =clk_prepare_enable (phy->refclk); -if (ret) { -dev_err (phy->dev,"failed to enable ref clk\n" ); - goto disable_apbclk; - } - - ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); -clk_disable_unprepare (phy->refclk);
drivers/phy/freescale/phy-fsl-samsung-hdmi.c static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev) · line 718
Quoted 10 lines
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +3
-4-if (!ret) -return 0 ; +if (phy->cur_cfg) + ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); -disable_apbclk: -clk_disable_unprepare (phy->apbclk);return ret; + }
[Severity: Medium]
Does fsl_samsung_hdmi_phy_resume() leak the enable count on phy->apbclk when fsl_samsung_hdmi_phy_configure() fails? If the PLL fails to lock on runtime resume, the device stays suspended in runtime PM error state without disabling and unpreparing phy->apbclk.
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Am Montag, 16. November 2026, 17:24:08 Mitteleuropäische Normalzeit schrieb Francesco Dolcini:
Quoted 7 lines
From: Francesco Dolcini <[email protected]>
This reverts commit
c01ccf91b257741e9edc374a465126bae9ae4711.Programming the 74.25 MHz configuration at probe fails on i.MX8MP boards, the PHY probe aborts and HDMI is no longer available:
Quoted 8 lines
fsl-samsung-hdmi-phy 32fdff00.phy: PLL failed to lock
fsl-samsung-hdmi-phy 32fdff00.phy: error-ETIMEDOUT: failed to configure default rate fsl-samsung-hdmi-phy 32fdff00.phy: probe with driver fsl-samsung-hdmi-phy failed with error -110Reported-by Alexander Stein <[email protected]>Fixes c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate")Signed-off-by Francesco Dolcini <[email protected]>
Revert works as expected:
Quoted 119 lines
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 59 +++++--------------- 1 file changed, 15 insertions(+), 44 deletions(-)drivers/phy/freescale/phy-fsl-samsung-hdmi.c +15
-44@@ -44,8 +44,6 @@#define MHZ (1000UL * 1000UL)#endif -#define PHY_DEFAULT_RATE 74250000 -#define PHY_PLL_DIV_REGS_NUM 7struct phy_config {@@ -491,6 +489,17 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,return ret; } +static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); + +if (!phy->cur_cfg) +return 74250000 ; + +return phy->cur_cfg->pixclk; +} +/* Helper function to lookup the available fractional-divider rate */ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate (unsigned long rate) {@@ -511,14 +520,6 @@ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate(unsigned long r &phy_pll_cfg[i] : &phy_pll_cfg[i+1]); } -static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) -{ -struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); - -return phy->cur_cfg->pixclk; -} -static void fsl_samsung_hdmi_calculate_phy (struct phy_config *cal_phy,unsigned long rate,u8 p,u16 m,u8 s) {@@ -639,7 +640,6 @@ static int phy_clk_register(struct fsl_samsung_hdmi_phy *phy)static int fsl_samsung_hdmi_phy_probe (struct platform_device *pdev) { -const struct phy_config *default_cfg;struct fsl_samsung_hdmi_phy *phy;int ret;@@ -664,23 +664,6 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return dev_err_probe (phy->dev,PTR_ERR (phy->refclk),"failed to get ref clk\n" ); -/* -* Establish the rate reported by recalc_rate() before registering the -* clock. Otherwise CCF may skip the first set_rate() when it requests -* the assumed default rate, leaving the PHY unconfigured. -*/ - ret =clk_prepare_enable (phy->refclk); -if (ret) -return dev_err_probe (phy->dev, ret, -"failed to enable ref clk\n" ); - - default_cfg =fsl_samsung_hdmi_phy_lookup_rate (PHY_DEFAULT_RATE ); - ret =fsl_samsung_hdmi_phy_configure (phy, default_cfg); -clk_disable_unprepare (phy->refclk); -if (ret) -return dev_err_probe (phy->dev, ret, -"failed to configure default rate\n" ); -pm_runtime_get_noresume (phy->dev);pm_runtime_set_active (phy->dev);pm_runtime_enable (phy->dev);@@ -719,7 +702,7 @@ static int __maybe_unused fsl_samsung_hdmi_phy_suspend(struct device *dev)static int __maybe_unused fsl_samsung_hdmi_phy_resume (struct device *dev) {struct fsl_samsung_hdmi_phy *phy =dev_get_drvdata (dev); -int ret; +int ret =0 ; ret =clk_prepare_enable (phy->apbclk);if (ret) {@@ -727,23 +710,11 @@ static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev)return ret; } -if (!phy->cur_cfg) -return 0 ; - - ret =clk_prepare_enable (phy->refclk); -if (ret) { -dev_err (phy->dev,"failed to enable ref clk\n" ); - goto disable_apbclk; - } - - ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); -clk_disable_unprepare (phy->refclk); -if (!ret) -return 0 ; +if (phy->cur_cfg) + ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); -disable_apbclk: -clk_disable_unprepare (phy->apbclk);return ret; + } static DEFINE_RUNTIME_DEV_PM_OPS(fsl_samsung_hdmi_phy_pm_ops,
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Hi Francesco,
Quoted 7 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
This reverts commit
c01ccf91b257741e9edc374a465126bae9ae4711.Programming the 74.25 MHz configuration at probe fails on i.MX8MP boards, the PHY probe aborts and HDMI is no longer available:
Quoted 8 lines
fsl-samsung-hdmi-phy 32fdff00.phy: PLL failed to lock
fsl-samsung-hdmi-phy 32fdff00.phy: error-ETIMEDOUT: failed to configure default rate fsl-samsung-hdmi-phy 32fdff00.phy: probe with driver fsl-samsung-hdmi-phy failed with error -110Reported-by Alexander Stein <[email protected]>Fixes c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate")Signed-off-by Francesco Dolcini <[email protected]>
Got the same issue on i.MX8MP after rebasing on drm-misc-next, which is based on v7.4-rc2.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 10 lines · Francesco Dolcini
This reverts commit
c01ccf91b257741e9edc374a465126bae9ae4711.Programming the 74.25 MHz configuration at probe fails on i.MX8MP boards, the PHY probe aborts and HDMI is no longer available:
fsl-samsung-hdmi-phy 32fdff00.phy: PLL failed to lock
fsl-samsung-hdmi-phy 32fdff00.phy: error-ETIMEDOUT: failed to configure default rate fsl-samsung-hdmi-phy 32fdff00.phy: probe with driver fsl-samsung-hdmi-phy failed with error -110[...]
Applied, thanks!
[1/1] Revert "phy: freescale: fsl-samsung-hdmi: initialize default rate"
commit: 11cb7e479a15b631cbe5f9038a28de0a1966853b
Best regards,
Signature · 1 line
~Vinod