Skip to contentSkip to conversation

mmc: sdhci-s3c: fix the card detection in runtime-pm

PATCH New Seungwon Jeon 5 participants 16 messages Oct 18, 2012 – Feb 11, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-s3c: fix the card detection in runtime-pm

If host clock is disabled, host cannot detect a card in case of using CD internal for detection.

---
 drivers/mmc/host/sdhci-s3c.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-s3c.c +4 -2
index 2903949..e57f200 100644
@@ -747,7 +747,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_disable(sc->clk_io);
 #endif
 	return 0;
 
@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v2 1/1 mmc: sdhci-s3c: fix the card detection in runtime-pm

If host clock is disabled, host cannot detect a card in case of using the internal or gpio card-detect for detection.

---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works on my machine. But I'm not sure if this would also be necessary for the external card detect.

 drivers/mmc/host/sdhci-s3c.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-s3c.c +6 -2
index 0cabf18..649dc32 100644
@@ -750,7 +750,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_disable(sc->clk_io);
 #endif
 	return 0;
 
@@ -797,7 +799,9 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
Signature · 1 line
1.7.2.3
#2 lore raw

On Thursday, October 18, 2012, Heiko Stuebner <[email protected]>

Quoted 9 lines

If host clock is disabled, host cannot detect a card in case of using the internal or gpio card-detect for detection.

---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works on my machine. But I'm not sure if this would also be necessary for the external card detect.

Card detection will be asserted out of host in case of using SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

Thanks.
Seungwon Jeon

Quoted 37 lines
 drivers/mmc/host/sdhci-s3c.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-s3c.c +6 -3
index 0cabf18..649dc32 100644
@@ -750,7 +750,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_disable(sc->clk_io);
 #endif
 	return 0;
 
@@ -797,7 +799,9 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
--

1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:

Quoted 12 lines

On Thursday, October 18, 2012, Heiko Stuebner <[email protected]>

Quoted 9 lines

If host clock is disabled, host cannot detect a card in case of using the internal or gpio card-detect for detection.

---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works on my machine. But I'm not sure if this would also be necessary for the external card detect.

Quoted 2 lines

Card detection will be asserted out of host in case of using SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

But it _was_ necessary :-) . Because only then did the problem go away. You might be right, that there exists a better solution for this, but something in the original patch is at least still missing to fix the problem.

Heiko

Quoted 46 lines
Quoted 46 lines
 drivers/mmc/host/sdhci-s3c.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-s3c.c +3 -1
index 0cabf18..649dc32 100644
@@ -750,7 +750,9 @@ static int __devinit sdhci_s3c_probe(struct
 platform_device *pdev)
 
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
 
-	clk_disable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_disable(sc->clk_io);

#endif

drivers/mmc/host/sdhci-s3c.c +3 -1
 	return 0;
@@ -797,7 +799,9 @@ static int __devexit sdhci_s3c_remove(struct
 platform_device *pdev)
 
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
 
-	clk_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_enable(sc->clk_io);

#endif

sdhci_remove_host(host, 1);

--
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Hi,

Quoted 13 lines · Heiko Stübner

Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:

Quoted 12 lines

On Thursday, October 18, 2012, Heiko Stuebner <[email protected]>

Quoted 9 lines

If host clock is disabled, host cannot detect a card in case of using the internal or gpio card-detect for detection.

---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works on my machine. But I'm not sure if this would also be necessary for the external card detect.

Quoted 6 lines
Quoted 2 lines

Card detection will be asserted out of host in case of using SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

But it _was_ necessary :-) . Because only then did the problem go away. You might be right, that there exists a better solution for this, but something in the original patch is at least still missing to fix the problem.

Seungwon, what would you like to do here? (I'm unhappy taking a patch with your name on it that's been modified in a way you disagree with.)

Thanks,

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#5 lore raw

Hi Chris,

Am Montag, 29. Oktober 2012, 22:16:47 schrieb Chris Ball:

Quoted 20 lines

Hi,

Quoted 17 lines · Heiko Stübner

Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:

Quoted 15 lines

On Thursday, October 18, 2012, Heiko Stuebner <[email protected]>

Quoted 9 lines

If host clock is disabled, host cannot detect a card in case of using the internal or gpio card-detect for detection.

---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works on my machine. But I'm not sure if this would also be necessary for the external card detect.

Card detection will be asserted out of host in case of using SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

Quoted 7 lines
Quoted 4 lines

But it _was_ necessary :-) . Because only then did the problem go away. You might be right, that there exists a better solution for this, but something in the original patch is at least still missing to fix the problem.

Seungwon, what would you like to do here? (I'm unhappy taking a patch with your name on it that's been modified in a way you disagree with.)

I agree with Seungwon, that the solution in my v2 is not the correct one :-) - should've called it RFC or so. The gpio-card-detect code _should_ be able to handle the resume of the host itself in the card detect case, but it seems it's not able to.

The patch in its v1 form does not fix the problem commit 2abeb5c5ded2 (mmc:
sdhci-s3c: Add clk_(enable/disable) in runtime suspend/resume) has caused for Samsung devices using the gpio card-detect - it's broken in 3.7 currently.

So for 3.7 the easiest way would of course be to revert the commit above and find a correct solution for 3.8.

Heiko

#6 lore raw
Quoted 36 lines · Heiko Stuebner

Hi Chris,

Am Montag, 29. Oktober 2012, 22:16:47 schrieb Chris Ball:

Quoted 20 lines

Hi,

Quoted 17 lines · Heiko Stübner

Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:

Quoted 15 lines

On Thursday, October 18, 2012, Heiko Stuebner <[email protected]>

Quoted 9 lines

If host clock is disabled, host cannot detect a card in case of using the internal or gpio card-detect for detection.

---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works on my machine. But I'm not sure if this would also be necessary for the external card detect.

Card detection will be asserted out of host in case of using SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

Quoted 7 lines
Quoted 4 lines

But it _was_ necessary :-) . Because only then did the problem go away. You might be right, that there exists a better solution for this, but something in the original patch is at least still missing to fix the problem.

Seungwon, what would you like to do here? (I'm unhappy taking a patch with your name on it that's been modified in a way you disagree with.)

I agree with Seungwon, that the solution in my v2 is not the correct one :-) - should've called it RFC or so. The gpio-card-detect code _should_ be able to handle the resume of the host itself in the card detect case, but it seems it's not able to.

Quoted 7 lines

The patch in its v1 form does not fix the problem commit 2abeb5c5ded2 (mmc:
sdhci-s3c: Add clk_(enable/disable) in runtime suspend/resume) has caused for Samsung devices using the gpio card-detect - it's broken in 3.7 currently.

So for 3.7 the easiest way would of course be to revert the commit above and find a correct solution for 3.8.

Hi Chris,

This patch doesn't aim Heiko's problem but guarantee card detection for using internal CD. Clock should be enabled for internal card detection of host.

Thanks,
Seungwon Jeon

Quoted 7 lines

Heiko
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

PATCH v2 1/2 mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable

In reply to Heiko Stübner

clock shoud be supplied during bus transaction. This patch defers clk_disabe in runtime_suspend if cmd/data line is used.

---
Rebased with mmc-next.

 drivers/mmc/host/sdhci-s3c.c |   13 +++++++++----
 drivers/mmc/host/sdhci.c     |   20 ++++----------------
 drivers/mmc/host/sdhci.h     |   11 +++++++++++
 3 files changed, 24 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci-s3c.c +9 -4
index a093e2e..a79b153 100644
@@ -845,12 +845,17 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_s3c *ourhost = to_s3c(host);
 	struct clk *busclk = ourhost->clk_io;
-	int ret;
+	int ret = 0;
 
-	ret = sdhci_runtime_suspend_host(host);
+	if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
+			(SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT))) {
+		ret = sdhci_runtime_suspend_host(host);
+		clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
+		clk_disable_unprepare(busclk);
+	} else {
+		sdhci_runtime_pm_put(host);
+	}
 
-	clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
-	clk_disable_unprepare(busclk);
 	return ret;
 }
 
drivers/mmc/host/sdhci.c +4 -16
index f05a377..d62646d 100644
@@ -54,20 +54,6 @@ static void sdhci_finish_command(struct sdhci_host *);
 static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
 static void sdhci_tuning_timer(unsigned long data);
 
-#ifdef CONFIG_PM_RUNTIME
-static int sdhci_runtime_pm_get(struct sdhci_host *host);
-static int sdhci_runtime_pm_put(struct sdhci_host *host);
-#else
-static inline int sdhci_runtime_pm_get(struct sdhci_host *host)
-{
-	return 0;
-}
-static inline int sdhci_runtime_pm_put(struct sdhci_host *host)
-{
-	return 0;
-}
-#endif
-
 static void sdhci_dumpregs(struct sdhci_host *host)
 {
 	pr_debug(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n",
@@ -2535,16 +2521,18 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);
 
 #ifdef CONFIG_PM_RUNTIME
 
-static int sdhci_runtime_pm_get(struct sdhci_host *host)
+int sdhci_runtime_pm_get(struct sdhci_host *host)
 {
 	return pm_runtime_get_sync(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_get);
 
-static int sdhci_runtime_pm_put(struct sdhci_host *host)
+int sdhci_runtime_pm_put(struct sdhci_host *host)
 {
 	pm_runtime_mark_last_busy(host->mmc->parent);
 	return pm_runtime_put_autosuspend(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_put);
 
 int sdhci_runtime_suspend_host(struct sdhci_host *host)
 {
drivers/mmc/host/sdhci.h +11 -0
index 71a4a7e..a42a192 100644
@@ -385,8 +385,19 @@ extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
 #endif
 
 #ifdef CONFIG_PM_RUNTIME
+extern int sdhci_runtime_pm_get(struct sdhci_host *host);
+extern int sdhci_runtime_pm_put(struct sdhci_host *host);
 extern int sdhci_runtime_suspend_host(struct sdhci_host *host);
 extern int sdhci_runtime_resume_host(struct sdhci_host *host);
+#else
+inline int sdhci_runtime_pm_get(struct sdhci_host *host)
+{
+	return 0;
+}
+inline int sdhci_runtime_pm_put(struct sdhci_host *host)
+{
+	return 0;
+}
 #endif
 
 #endif /* __SDHCI_HW_H */
Signature · 1 line
1.7.0.4
#8 lore raw

Re: [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable

Hi,

Quoted 5 lines · Seungwon Jeon

clock shoud be supplied during bus transaction. This patch defers clk_disabe in runtime_suspend if cmd/data line is used.

Thanks, pushed to mmc-next for 3.7.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#9 lore raw

PATCH 2/2 mmc: block: don't start new request when the card is removed

In reply to Heiko Stübner

Current request can be started newly while handling the error. But if the card is removed, it's unnecessary to restart a request. This makes the extra error handling.

---
 drivers/mmc/card/block.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/card/block.c +8 -2
index f79b468..1170afe 100644
@@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
 
  start_new_req:
 	if (rqc) {
-		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
-		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
+		if (mmc_card_removed(card)) {
+			rqc->cmd_flags |= REQ_QUIET;
+			blk_end_request_all(rqc, -EIO);
+		} else {
+			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
+			mmc_start_req(card->host,
+				      &mq->mqrq_cur->mmc_active, NULL);
+		}
 	}
 
 	return 0;
Signature · 1 line
1.7.0.4
maintainer Acked-by on v1 2/2
#10 lore raw

Re: [PATCH 2/2] mmc: block: don't start new request when the card is removed

Hi Seungwon,

It looks good to me..

Quoted 31 lines · Seungwon Jeon

Current request can be started newly while handling the error. But if the card is removed, it's unnecessary to restart a request. This makes the extra error handling.

---
 drivers/mmc/card/block.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/card/block.c +8 -2
index f79b468..1170afe 100644
@@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
 
  start_new_req:
 	if (rqc) {
-		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
-		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
+		if (mmc_card_removed(card)) {
+			rqc->cmd_flags |= REQ_QUIET;
+			blk_end_request_all(rqc, -EIO);
+		} else {
+			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
+			mmc_start_req(card->host,
+				      &mq->mqrq_cur->mmc_active, NULL);
+		}
 	}
 
 	return 0;
Tested-by on v1 2/2
#11 lore raw

Re: [PATCH 2/2] mmc: block: don't start new request when the card is removed

In reply to Seungwon Jeon
Quoted 31 lines · Seungwon Jeon

Current request can be started newly while handling the error. But if the card is removed, it's unnecessary to restart a request. This makes the extra error handling.

---
  drivers/mmc/card/block.c |   10 ++++++++--
  1 files changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/card/block.c +8 -2
index f79b468..1170afe 100644
@@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
 
   start_new_req:
  	if (rqc) {
-		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
-		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
+		if (mmc_card_removed(card)) {
+			rqc->cmd_flags |= REQ_QUIET;
+			blk_end_request_all(rqc, -EIO);
+		} else {
+			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
+			mmc_start_req(card->host,
+				      &mq->mqrq_cur->mmc_active, NULL);
+		}
  	}
 
  	return 0;
Signature · 4 lines
Konstantin Dorfman,
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center,
Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#12 lore raw

Re: [PATCH 2/2] mmc: block: don't start new request when the card is removed

In reply to Seungwon Jeon

Hi,

Quoted 20 lines · Seungwon Jeon

Current request can be started newly while handling the error. But if the card is removed, it's unnecessary to restart a request. This makes the extra error handling.

---
 drivers/mmc/card/block.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/card/block.c +1 -2
index f79b468..1170afe 100644
@@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
 
  start_new_req:
 	if (rqc) {
-		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
-		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
+		if (mmc_card_removed(card)) {

drivers/mmc/card/block.c static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) · line 1469

Quoted 10 lines
drivers/mmc/card/block.c +7 -0
+			rqc->cmd_flags |= REQ_QUIET;
+			blk_end_request_all(rqc, -EIO);
+		} else {
+			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
+			mmc_start_req(card->host,
+				      &mq->mqrq_cur->mmc_active, NULL);
+		}
 	}
 
 	return 0;

Thanks, pushed to mmc-next for 3.9.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#13 lore raw

PATCH v2 2/2 mmc: sdhci-s3c: fix the card detection in runtime-pm

In reply to Chris Ball

If host clock is disabled, host cannot detect a card in case of using CD internal for detection.

---
Rebased with mmc-next.

 drivers/mmc/host/sdhci-s3c.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-s3c.c +4 -2
index a79b153..d680c0b 100644
@@ -747,7 +747,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable_unprepare(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_disable_unprepare(sc->clk_io);
 #endif
 	return 0;
 
@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_prepare_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_prepare_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
Signature · 1 line
1.7.0.4
#14 lore raw

Hi,

Quoted 4 lines · Seungwon Jeon

If host clock is disabled, host cannot detect a card in case of using CD internal for detection.

Thanks, pushed to mmc-next for 3.7.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#15 lore raw

PATCH v3 1/1 mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable

In reply to Chris Ball

clock shoud be supplied during bus transaction. This patch defers clk_disabe in runtime_suspend if cmd/data line is used.

---
V3: Removed the error message. (reported by Fengguang Wu)

 drivers/mmc/host/sdhci-s3c.c |   13 +++++++++----
 drivers/mmc/host/sdhci.c     |   20 ++++----------------
 drivers/mmc/host/sdhci.h     |   12 ++++++++++++
 3 files changed, 25 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci-s3c.c +9 -4
index a54dd5d..d680c0b 100644
@@ -847,12 +847,17 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_s3c *ourhost = to_s3c(host);
 	struct clk *busclk = ourhost->clk_io;
-	int ret;
+	int ret = 0;
 
-	ret = sdhci_runtime_suspend_host(host);
+	if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
+			(SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT))) {
+		ret = sdhci_runtime_suspend_host(host);
+		clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
+		clk_disable_unprepare(busclk);
+	} else {
+		sdhci_runtime_pm_put(host);
+	}
 
-	clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
-	clk_disable_unprepare(busclk);
 	return ret;
 }
 
drivers/mmc/host/sdhci.c +4 -16
index c7851c0..59b60e1 100644
@@ -54,20 +54,6 @@ static void sdhci_finish_command(struct sdhci_host *);
 static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
 static void sdhci_tuning_timer(unsigned long data);
 
-#ifdef CONFIG_PM_RUNTIME
-static int sdhci_runtime_pm_get(struct sdhci_host *host);
-static int sdhci_runtime_pm_put(struct sdhci_host *host);
-#else
-static inline int sdhci_runtime_pm_get(struct sdhci_host *host)
-{
-	return 0;
-}
-static inline int sdhci_runtime_pm_put(struct sdhci_host *host)
-{
-	return 0;
-}
-#endif
-
 static void sdhci_dumpregs(struct sdhci_host *host)
 {
 	pr_debug(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n",
@@ -2538,16 +2524,18 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);
 
 #ifdef CONFIG_PM_RUNTIME
 
-static int sdhci_runtime_pm_get(struct sdhci_host *host)
+int sdhci_runtime_pm_get(struct sdhci_host *host)
 {
 	return pm_runtime_get_sync(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_get);
 
-static int sdhci_runtime_pm_put(struct sdhci_host *host)
+int sdhci_runtime_pm_put(struct sdhci_host *host)
 {
 	pm_runtime_mark_last_busy(host->mmc->parent);
 	return pm_runtime_put_autosuspend(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_put);
 
 int sdhci_runtime_suspend_host(struct sdhci_host *host)
 {
drivers/mmc/host/sdhci.h +12 -0
index 71a4a7e..02edce1 100644
@@ -385,8 +385,20 @@ extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
 #endif
 
 #ifdef CONFIG_PM_RUNTIME
+extern int sdhci_runtime_pm_get(struct sdhci_host *host);
+extern int sdhci_runtime_pm_put(struct sdhci_host *host);
 extern int sdhci_runtime_suspend_host(struct sdhci_host *host);
 extern int sdhci_runtime_resume_host(struct sdhci_host *host);
+#else
+static inline int sdhci_runtime_pm_get(struct sdhci_host *host)
+{
+	return 0;
+}
+
+static inline int sdhci_runtime_pm_put(struct sdhci_host *host)
+{
+	return 0;
+}
 #endif
 
 #endif /* __SDHCI_HW_H */
Signature · 1 line
1.7.0.4