Skip to contentSkip to conversation

mmc: sdhci: Deal with failure case in sdhci_suspend_host

PATCH In review Aaron Lu 3 participants 3 messages Jan 4, 2012 – Jan 11, 2012

Subsystems (2)
lore
Share & tools
lore

Aaron Lu

author
#0 lore raw

PATCH v3 2/2 mmc: sdhci: Deal with failure case in sdhci_suspend_host

V3: Rework on top of Adrian's vmmc patch

V2: Error processing code in sdhci_pci_suspend should not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian.

If there are errors happened in sdhci_suspend_host, handle it so that when the function returns with an error, the host's behaviour is the same before this function call, e.g. card detection is enabled and tuning timer is active, etc.

---
 drivers/mmc/host/sdhci.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci.c +14 -4
index 988ae06..823b83e 100644
@@ -2349,20 +2349,30 @@ out:
 
 int sdhci_suspend_host(struct sdhci_host *host)
 {
-	int ret;
+	int ret, has_tuning_timer;
 
 	sdhci_disable_card_detection(host);
 
 	/* Disable tuning since we are suspending */
-	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
+	has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
+		host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
+	if (has_tuning_timer) {
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 	}
 
 	ret = mmc_suspend_host(host->mmc);
-	if (ret)
+	if (ret) {
+		if (has_tuning_timer) {
+			host->flags |= SDHCI_NEEDS_RETUNING;
+			mod_timer(&host->tuning_timer, jiffies +
+					host->tuning_count * HZ);
+		}
+
+		sdhci_enable_card_detection(host);
+
 		return ret;
+	}
 
 	free_irq(host->irq, host);
 
Signature · 1 line
1.7.7.5
maintainer Acked-by on v3 2/2
#1 lore raw
Quoted 6 lines · Aaron Lu

V3: Rework on top of Adrian's vmmc patch

V2: Error processing code in sdhci_pci_suspend should not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian.

Quoted 8 lines

If there are errors happened in sdhci_suspend_host, handle it so that when the function returns with an error, the host's behaviour is the same before this function call, e.g. card detection is enabled and tuning timer is active, etc.

Quoted 43 lines
---
 drivers/mmc/host/sdhci.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci.c +14 -4
index 988ae06..823b83e 100644
@@ -2349,20 +2349,30 @@ out:
 
 int sdhci_suspend_host(struct sdhci_host *host)
 {
-	int ret;
+	int ret, has_tuning_timer;
 
 	sdhci_disable_card_detection(host);
 
 	/* Disable tuning since we are suspending */
-	if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
-	    host->tuning_mode == SDHCI_TUNING_MODE_1) {
+	has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
+		host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
+	if (has_tuning_timer) {
 		del_timer_sync(&host->tuning_timer);
 		host->flags &= ~SDHCI_NEEDS_RETUNING;
 	}
 
 	ret = mmc_suspend_host(host->mmc);
-	if (ret)
+	if (ret) {
+		if (has_tuning_timer) {
+			host->flags |= SDHCI_NEEDS_RETUNING;
+			mod_timer(&host->tuning_timer, jiffies +
+					host->tuning_count * HZ);
+		}
+
+		sdhci_enable_card_detection(host);
+
 		return ret;
+	}
 
 	free_irq(host->irq, host);
 
#2 lore raw

Hi,

Quoted 12 lines · Adrian Hunter
Quoted 11 lines · Aaron Lu

V3: Rework on top of Adrian's vmmc patch

V2: Error processing code in sdhci_pci_suspend should not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian.

If there are errors happened in sdhci_suspend_host, handle it so that when the function returns with an error, the host's behaviour is the same before this function call, e.g. card detection is enabled and tuning timer is active, etc.

Quoted 5 lines
Quoted 3 lines

Thanks, I'll push for 3.3 with Adrian's ACK and:

drivers/mmc/host/sdhci.c +2 -1
index a8f1f7e..0636e9a 100644
@@ -2348,7 +2348,8 @@ out:
 
 int sdhci_suspend_host(struct sdhci_host *host)
 {
-	int ret, has_tuning_timer;
+	int ret;
+	bool has_tuning_timer;
 
 	sdhci_disable_card_detection(host);
 

- Chris.

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