Skip to contentSkip to conversation

sdhci : handle busy timeout irq

PATCH Applied Matthieu CASTET 2 participants 4 messages Aug 14, 2014 – Aug 18, 2014

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

PATCH 1/2 sdhci : handle busy timeout irq

When we wait for busy after sending a command, if there is
a timeout, we got SDHCI_INT_DATA_TIMEOUT flags.
Before this commit we got the message :
"Got data interrupt 0x00100000 even though no data operation was in progress." and we need to wait 10s that sdhci_timeout_timer expires.

---
 drivers/mmc/host/sdhci.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +5 -0
index 47055f3..9df59a4 100644
@@ -2301,6 +2301,11 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
 		 * above in sdhci_cmd_irq().
 		 */
 		if (host->cmd && (host->cmd->flags & MMC_RSP_BUSY)) {
+			if (intmask & SDHCI_INT_DATA_TIMEOUT) {
+				host->cmd->error = -ETIMEDOUT;
+				tasklet_schedule(&host->finish_tasklet);
+				return;
+			}
 			if (intmask & SDHCI_INT_DATA_END) {
 				sdhci_finish_command(host);
 				return;
Signature · 1 line
2.1.0.rc1
#1 lore raw

PATCH 2/2 sdhci : recompute timeout_clk when needed

when SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK is set, timeout_clk is sdclk. We need to update it when we change sdclk in sdhci_set_clock. This allow to have a more precisse timeout and max_busy_timeout. This can help for command that need a big busy wait (erase, ...).

---
 drivers/mmc/host/sdhci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +6 -1
index 9df59a4..76b1aab 100644
@@ -1192,8 +1192,13 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 	}
 
 clock_set:
-	if (real_div)
+	if (real_div) {
 		host->mmc->actual_clock = (host->max_clk * clk_mul) / real_div;
+		if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
+			host->timeout_clk = host->mmc->actual_clock / 1000;
+			host->mmc->max_busy_timeout = (1 << 27) / host->timeout_clk;
+		}
+	}
 
 	clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT;
 	clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN)
Signature · 1 line
2.1.0.rc1
Applied
#2 lore raw

Re: [PATCH 2/2] sdhci : recompute timeout_clk when needed

Quoted 6 lines · Matthieu CASTET

when SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK is set, timeout_clk is sdclk. We need to update it when we change sdclk in sdhci_set_clock. This allow to have a more precisse timeout and max_busy_timeout. This can help for command that need a big busy wait (erase, ...).

Thanks! Applied for next.

This one didn't pass checkpatch, but I fixed it this time.

Kind regards
Uffe

Quoted 26 lines
---
 drivers/mmc/host/sdhci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +6 -2
index 9df59a4..76b1aab 100644
@@ -1192,8 +1192,13 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
        }
 
 clock_set:
-       if (real_div)
+       if (real_div) {
                host->mmc->actual_clock = (host->max_clk * clk_mul) / real_div;
+               if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
+                       host->timeout_clk = host->mmc->actual_clock / 1000;
+                       host->mmc->max_busy_timeout = (1 << 27) / host->timeout_clk;
+               }
+       }
 
        clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT;
        clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN)
--

2.1.0.rc1

Applied
#3 lore raw
In reply to Matthieu CASTET
Quoted 7 lines · Matthieu CASTET

When we wait for busy after sending a command, if there is
a timeout, we got SDHCI_INT_DATA_TIMEOUT flags.
Before this commit we got the message :
"Got data interrupt 0x00100000 even though no data operation was in progress." and we need to wait 10s that sdhci_timeout_timer expires.

Thanks! Applied for next.

Kind regards
Uffe

Quoted 23 lines
---
 drivers/mmc/host/sdhci.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +5 -1
index 47055f3..9df59a4 100644
@@ -2301,6 +2301,11 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
                 * above in sdhci_cmd_irq().
                 */
                if (host->cmd && (host->cmd->flags & MMC_RSP_BUSY)) {
+                       if (intmask & SDHCI_INT_DATA_TIMEOUT) {
+                               host->cmd->error = -ETIMEDOUT;
+                               tasklet_schedule(&host->finish_tasklet);
+                               return;
+                       }
                        if (intmask & SDHCI_INT_DATA_END) {
                                sdhci_finish_command(host);
                                return;
--

2.1.0.rc1