Skip to contentSkip to conversation

Add erase timeout calculation routine for sdhci host

PATCH In review Chuanxiao.Dong 2 participants 5 messages Nov 11, 2010

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

PATCH 1/3 Add erase timeout calculation routine for sdhci host

Quoted 1 line

From 04704a1c769dc4d15b5fb54d65d8ad46f6c5f57a Mon Sep 17 00:00:00 2001

From: Chuanxiao Dong <[email protected]>
Date: Thu, 11 Nov 2010 13:42:32 +0800
Subject: [PATCH 1/3] mmc: add erase timeout calculation routine for sdhci host

Erase command needs R1b response which means after HD handle a CMD_RESPONSE interrupt, driver also need to wait for a while. For SDHCI host controller, HD also need to handle a DATA_END interrupt.
During device handle erase cmd, if the blocks need to be erased are too many, some SDHCI host controller maybe launch a TIMEOUT interrupt before the erase cmd finishing. To avoid this kind of situation, SDHCI HD need to calculate a correct timeout value before issuing erase cmd. Patch added a routine to implement this.

---
 drivers/mmc/core/core.c  |    4 ++++
 drivers/mmc/host/sdhci.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
drivers/mmc/core/core.c +4 -0
index 8bf542c..d48bb26 100644
@@ -170,6 +170,9 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
 
 	mrq->cmd->error = 0;
 	mrq->cmd->mrq = mrq;
+	if (mrq->cmd->opcode != MMC_ERASE)
+		mrq->cmd->erase_timeout = 0;
+
 	if (mrq->data) {
 		BUG_ON(mrq->data->blksz > host->max_blk_size);
 		BUG_ON(mrq->data->blocks > host->max_blk_count);
@@ -190,6 +193,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
 			mrq->data->stop = mrq->stop;
 			mrq->stop->error = 0;
 			mrq->stop->mrq = mrq;
+			mrq->stop->erase_timeout = 0;
 		}
 	}
 	mmc_host_clk_ungate(host);
drivers/mmc/host/sdhci.c +46 -0

64 lines not on this page · raw message

Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 5 lines · Chuanxiao.Dong

From 04704a1c769dc4d15b5fb54d65d8ad46f6c5f57a Mon Sep 17 00:00:00 2001
From: Chuanxiao Dong <[email protected]>
Date: Thu, 11 Nov 2010 13:42:32 +0800
Subject: [PATCH 1/3] mmc: add erase timeout calculation routine for sdhci host

Quoted 10 lines

Erase command needs R1b response which means after HD handle a CMD_RESPONSE interrupt, driver also need to wait for a while. For SDHCI host controller, HD also need to handle a DATA_END interrupt.
During device handle erase cmd, if the blocks need to be erased are too many, some SDHCI host controller maybe launch a TIMEOUT interrupt before the erase cmd finishing. To avoid this kind of situation, SDHCI HD need to calculate a correct timeout value before issuing erase cmd. Patch added a routine to implement this.

Just a formal thing I noticed on a glimpse...

drivers/mmc/host/sdhci.c static void sdhci_finish_data(struct sdhci_host *host) · line 886

Quoted 13 lines
drivers/mmc/host/sdhci.c +5 -0
index 154cbf8..79fcca2 100644
@@ -879,6 +879,48 @@ static void sdhci_finish_data(struct sdhci_host *host)
 		tasklet_schedule(&host->finish_tasklet);
 }
 
+static void sdhci_set_erasetimeout(struct sdhci_host *host,
+		unsigned int erase_timeout)
+{
+	u64 current_timeout;
+	int count = 0xe;

I'd suggest a define with a speaking name instead of all the hardcoded 0xe.

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

Hi wolfram

Quoted 3 lines

Just a formal thing I noticed on a glimpse...

You mean can directly set the TIMEOUT CONTROL register to be the maximum value? And any comment about patch2 and patch3?

Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/sdhci.c index renamed from drivers/mmc/host/sdhci.c +0 -0

154cbf8..79fcca2 100644

drivers/mmc/host/sdhci.c +0 -0
@@ -879,6 +879,48 @@ static void sdhci_finish_data(struct sdhci_host *host)
 		tasklet_schedule(&host->finish_tasklet);
 }
 
Quoted 7 lines

drivers/mmc/host/sdhci.c static void sdhci_finish_data(struct sdhci_host *host) · line 886

Quoted 5 lines
drivers/mmc/host/sdhci.c +5 -0
+static void sdhci_set_erasetimeout(struct sdhci_host *host,
+		unsigned int erase_timeout)
+{
+	u64 current_timeout;
+	int count = 0xe;

I'd suggest a define with a speaking name instead of all the hardcoded 0xe.

Ok, will fix it in the next version submission.
Thanks

#3 lore raw
Quoted 5 lines · Chuanxiao

Hi wolfram

Quoted 3 lines

Just a formal thing I noticed on a glimpse...

You mean can directly set the TIMEOUT CONTROL register to be the maximum value?

Well, just use a #define instead of 0xe. I did not mean more :)

Quoted 1 line

And any comment about patch2 and patch3?

Sadly not. No resources left currently :(

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#4 lore raw
Quoted 8 lines
Quoted 1 line

You mean can directly set the TIMEOUT CONTROL register to be the maximum

value?

Well, just use a #define instead of 0xe. I did not mean more :)

Quoted 1 line

And any comment about patch2 and patch3?

Sadly not. No resources left currently :(

Never matter, thanks.

Regards
Chuanxiao