mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: gpmi: fix probe error path when CONFIG_PM=N
@ 2026-11-26 13:32 Yige Jiang
  0 siblings, 0 replies; only message in thread
From: Yige Jiang @ 2026-11-26 13:32 UTC (permalink / raw)
  To: Han Xu, Miquel Raynal, Vignesh Raghavendra
  Cc: Yige Jiang, Richard Weinberger, Maarten Zanders, imx, linux-mtd,
	linux-kernel, stable

With CONFIG_PM disabled, gpmi_nand_probe() enables the clocks by hand
and gpmi_nand_remove() disables them again, but the probe error path
was not updated to match:

- if gpmi_init() or gpmi_nand_init() fails, exit_nfc_init releases the
  DMA channel but leaves the clocks prepared and enabled, so every
  failed probe attempt adds another enable count;
- if gpmi_enable_clk() fails, the jump to exit_acquire_resources skips
  release_resources(), so the DMA channel taken by acquire_resources()
  is never released.

Disable the clocks in the error path when CONFIG_PM is disabled, and
let a clock enable failure fall through to the runtime PM and DMA
cleanup. Builds with CONFIG_PM=y are unchanged.

Fixes: 1001cc117124 ("mtd: nand: raw: gpmi: fix clocks when CONFIG_PM=N")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_MTD_NAND_GPMI_NAND with CONFIG_PM=y (defconfig, =m) and CONFIG_PM=n (allnoconfig, =y), CONFIG_COMPILE_TEST=y (object only; no new warnings in either).
No hardware or runtime test was performed.
Needs a CONFIG_PM=n kernel on i.MX and a gpmi_init()/gpmi_nand_init() failure (e.g. no NAND chip found) or a clk_prepare_enable() failure in probe.

 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 019df54c4bb0..fdfe11439a6c 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -2806,7 +2806,7 @@ static int gpmi_nand_probe(struct platform_device *pdev)
 #ifndef CONFIG_PM
 	ret = gpmi_enable_clk(this);
 	if (ret)
-		goto exit_acquire_resources;
+		goto exit_disable_pm;
 #endif
 
 	ret = gpmi_init(this);
@@ -2822,6 +2822,10 @@ static int gpmi_nand_probe(struct platform_device *pdev)
 	return 0;
 
 exit_nfc_init:
+#ifndef CONFIG_PM
+	gpmi_disable_clk(this);
+exit_disable_pm:
+#endif
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	release_resources(this);

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

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

only message in thread, other threads:[~2026-11-26 13:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 13:32 [PATCH] mtd: rawnand: gpmi: fix probe error path when CONFIG_PM=N Yige Jiang

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®