* [PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe
@ 2026-11-29 19:25 Jiawen Liu
2026-11-30 2:41 ` Peng Fan (OSS)
2026-12-01 13:56 ` Srinivas Kandagatla
0 siblings, 2 replies; 3+ messages in thread
From: Jiawen Liu @ 2026-11-29 19:25 UTC (permalink / raw)
To: Srinivas Kandagatla, Frank Li, Sascha Hauer
Cc: Pengutronix Kernel Team, Fabio Estevam, imx, linux-arm-kernel
imx_ocotp_probe() ignores the return value of clk_prepare_enable().
On i.MX6SL, preparing the OCOTP clock can propagate a PLL2 lock timeout
if PLL2 is selected and the shared clock chain is unprepared. The clock
provider can still publish the OCOTP gate if registration of the critical
MMDC IPG gate fails to prepare that chain.
Probe then accesses the OCOTP registers without acquiring the clock,
attempts an unmatched clk_disable_unprepare(), and can report success
if NVMEM registration succeeds.
Return the original clock error before clearing the OCOTP status or
registering NVMEM. On success, release the clock after clearing the
status, before registering NVMEM.
Verified the probe and devres paths
by source inspection, ran git diff --check and checkpatch.pl, and built
imx-ocotp.o with Clang 19 using the ARM imx_v6_v7_defconfig.
Runtime and hardware reproduction were not performed.
Fixes: c33c585f1b3a ("nvmem: imx-ocotp: reset error status on probe")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
drivers/nvmem/imx-ocotp.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index 55e07fd919a21..ecc085bb39e31 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -598,6 +598,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct ocotp_priv *priv;
struct nvmem_device *nvmem;
+ int ret;
priv = devm_kzalloc_obj(dev, *priv);
if (!priv)
@@ -622,7 +623,10 @@ static int imx_ocotp_probe(struct platform_device *pdev)
priv->config = &imx_ocotp_nvmem_config;
- clk_prepare_enable(priv->clk);
+ ret = clk_prepare_enable(priv->clk);
+ if (ret)
+ return ret;
+
imx_ocotp_clr_err_if_set(priv);
clk_disable_unprepare(priv->clk);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe
2026-11-29 19:25 [PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe Jiawen Liu
@ 2026-11-30 2:41 ` Peng Fan (OSS)
2026-12-01 13:56 ` Srinivas Kandagatla
1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan (OSS) @ 2026-11-30 2:41 UTC (permalink / raw)
To: Jiawen Liu
Cc: Peng Fan, Srinivas Kandagatla, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, imx, linux-arm-kernel,
Peng Fan
On Sun, 29 Nov 2026 19:25:33 +0000 Jiawen Liu <liu1298662399@gmail.com> wrote:
> imx_ocotp_probe() ignores the return value of clk_prepare_enable().
> On i.MX6SL, preparing the OCOTP clock can propagate a PLL2 lock timeout
> if PLL2 is selected and the shared clock chain is unprepared. The clock
> provider can still publish the OCOTP gate if registration of the critical
> MMDC IPG gate fails to prepare that chain.
>
> Probe then accesses the OCOTP registers without acquiring the clock,
> attempts an unmatched clk_disable_unprepare(), and can report success
> if NVMEM registration succeeds.
>
> Return the original clock error before clearing the OCOTP status or
> registering NVMEM. On success, release the clock after clearing the
> status, before registering NVMEM.
>
> Verified the probe and devres paths
> by source inspection, ran git diff --check and checkpatch.pl, and built
> imx-ocotp.o with Clang 19 using the ARM imx_v6_v7_defconfig.
> Runtime and hardware reproduction were not performed.
>
> Fixes: c33c585f1b3a ("nvmem: imx-ocotp: reset error status on probe")
> Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
> ---
> drivers/nvmem/imx-ocotp.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
> index 55e07fd919a21..ecc085bb39e31 100644
> --- a/drivers/nvmem/imx-ocotp.c
> +++ b/drivers/nvmem/imx-ocotp.c
> @@ -598,6 +598,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct ocotp_priv *priv;
> struct nvmem_device *nvmem;
> + int ret;
>
> priv = devm_kzalloc_obj(dev, *priv);
> if (!priv)
> @@ -622,7 +623,10 @@ static int imx_ocotp_probe(struct platform_device *pdev)
>
> priv->config = &imx_ocotp_nvmem_config;
>
> - clk_prepare_enable(priv->clk);
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + return ret;
> +
> imx_ocotp_clr_err_if_set(priv);
> clk_disable_unprepare(priv->clk);
Reviewed-by: Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe
2026-11-29 19:25 [PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe Jiawen Liu
2026-11-30 2:41 ` Peng Fan (OSS)
@ 2026-12-01 13:56 ` Srinivas Kandagatla
1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2026-12-01 13:56 UTC (permalink / raw)
To: Jiawen Liu, Srinivas Kandagatla, Frank Li, Sascha Hauer
Cc: Pengutronix Kernel Team, Fabio Estevam, imx, linux-arm-kernel
On 11/29/26 7:25 PM, Jiawen Liu wrote:
> imx_ocotp_probe() ignores the return value of clk_prepare_enable().
> On i.MX6SL, preparing the OCOTP clock can propagate a PLL2 lock timeout
> if PLL2 is selected and the shared clock chain is unprepared. The clock
> provider can still publish the OCOTP gate if registration of the critical
> MMDC IPG gate fails to prepare that chain.
>
> Probe then accesses the OCOTP registers without acquiring the clock,
> attempts an unmatched clk_disable_unprepare(), and can report success
> if NVMEM registration succeeds.
>
> Return the original clock error before clearing the OCOTP status or
> registering NVMEM. On success, release the clock after clearing the
> status, before registering NVMEM.
>
> Verified the probe and devres paths
> by source inspection, ran git diff --check and checkpatch.pl, and built
> imx-ocotp.o with Clang 19 using the ARM imx_v6_v7_defconfig.
> Runtime and hardware reproduction were not performed.
>
> Fixes: c33c585f1b3a ("nvmem: imx-ocotp: reset error status on probe")
CC stable missing.
--srini
> Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
> ---
> drivers/nvmem/imx-ocotp.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
> index 55e07fd919a21..ecc085bb39e31 100644
> --- a/drivers/nvmem/imx-ocotp.c
> +++ b/drivers/nvmem/imx-ocotp.c
> @@ -598,6 +598,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct ocotp_priv *priv;
> struct nvmem_device *nvmem;
> + int ret;
>
> priv = devm_kzalloc_obj(dev, *priv);
> if (!priv)
> @@ -622,7 +623,10 @@ static int imx_ocotp_probe(struct platform_device *pdev)
>
> priv->config = &imx_ocotp_nvmem_config;
>
> - clk_prepare_enable(priv->clk);
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + return ret;
> +
> imx_ocotp_clr_err_if_set(priv);
> clk_disable_unprepare(priv->clk);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-01 13:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:25 [PATCH] nvmem: imx-ocotp: Propagate clock setup errors from probe Jiawen Liu
2026-11-30 2:41 ` Peng Fan (OSS)
2026-12-01 13:56 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox