Skip to contentSkip to conversation

mtd: rawnand: gpmi: fix probe error path when CONFIG_PM=N

PATCH In review Yige Jiang 2 participants 2 messages Nov 26 – Nov 27

Subsystems (5)
lore
Share & tools
lore

Yige Jiang

author
#0 lore raw

PATCH 1/1 mtd: rawnand: gpmi: fix probe error path when CONFIG_PM=N

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")

---
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(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +5 -1
index 019df54c4bb0..fdfe11439a6c 100644
@@ -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