Thread (40 messages) 40 messages, 8 authors, 2014-07-21
STALE4344d

[PATCH 1/6] mmc: sdhci-s3c: Fix local I/O clock gating

From: Tomasz Figa <hidden>
Date: 2014-06-24 13:57:52
Also in: linux-mmc, linux-samsung-soc, lkml
Subsystem: multimedia card (mmc), secure digital (sd) and sdio subsystem, secure digital host controller interface (sdhci) driver, secure digital host controller interface (sdhci) samsung driver, the rest · Maintainers: Ulf Hansson, Adrian Hunter, Ben Dooks, Jaehoon Chung, Linus Torvalds

For internal card detection mechanism it is required that the local I/O
clock is always running. However while current implementation accounts
for this, it does so incorrectly leading to race conditions and warnings
about unbalanced clock disables.

This patch fixes it by inverting the logic, which now increases local
I/O clock enable count when internal card detect is used, instead of
decreasing it otherwise.

Signed-off-by: Tomasz Figa <redacted>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Chris Ball <redacted>
Cc: Ulf Hansson <redacted>
Cc: linux-mmc at vger.kernel.org
---
 drivers/mmc/host/sdhci-s3c.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index fa5954a..1795e1f 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -487,8 +487,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 		goto err_pdata_io_clk;
 	}
 
-	/* enable the local io clock and keep it running for the moment. */
-	clk_prepare_enable(sc->clk_io);
+	/*
+	 * Keep local I/O clock enabled for internal card detect pin
+	 * or runtime PM is disabled.
+	 */
+	if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL
+	    || !IS_ENABLED(CONFIG_PM_RUNTIME))
+		clk_prepare_enable(sc->clk_io);
 
 	for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
 		char name[14];
@@ -611,15 +616,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 		goto err_req_regs;
 	}
 
-#ifdef CONFIG_PM_RUNTIME
-	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
-		clk_disable_unprepare(sc->clk_io);
-#endif
 	return 0;
 
  err_req_regs:
  err_no_busclks:
-	clk_disable_unprepare(sc->clk_io);
+	if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL
+	    || !IS_ENABLED(CONFIG_PM_RUNTIME))
+		clk_disable_unprepare(sc->clk_io);
 
  err_pdata_io_clk:
 	sdhci_free_host(host);
-- 
1.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help