[PATCH 31/32] omap_hsmmc: set a large data timeout for commands with busy signal



From 54996066acb35e82f89715c6c59b28bc81e12239 Mon Sep 17 00:00:00 2001
From: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Date: Fri, 26 Jun 2009 11:29:20 +0300
Subject: [PATCH] omap_hsmmc: set a large data timeout for commands with busy signal

Commands like SWITCH (CMD6) send a response and then signal busy
while the operation is completed. These commands are expected
to always succeed (otherwise the response would have indicated an
error).

Set an arbitrarily large data timeout value (100ms) for these commands
to ensure that premature timeouts do not occur.

Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
---
drivers/mmc/host/omap_hsmmc.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 427bd49..ae8d33b 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -982,7 +982,8 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host,
}

static void set_data_timeout(struct omap_hsmmc_host *host,
- struct mmc_request *req)
+ unsigned int timeout_ns,
+ unsigned int timeout_clks)
{
unsigned int timeout, cycle_ns;
uint32_t reg, clkd, dto = 0;
@@ -993,8 +994,8 @@ static void set_data_timeout(struct omap_hsmmc_host *host,
clkd = 1;

cycle_ns = 1000000000 / (clk_get_rate(host->fclk) / clkd);
- timeout = req->data->timeout_ns / cycle_ns;
- timeout += req->data->timeout_clks;
+ timeout = timeout_ns / cycle_ns;
+ timeout += timeout_clks;
if (timeout) {
while ((timeout & 0x80000000) == 0) {
dto += 1;
@@ -1028,12 +1029,18 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req)

if (req->data == NULL) {
OMAP_HSMMC_WRITE(host->base, BLK, 0);
+ /*
+ * Set an arbitrary 100ms data timeout for commands with
+ * busy signal.
+ */
+ if (req->cmd->flags & MMC_RSP_BUSY)
+ set_data_timeout(host, 100000000U, 0);
return 0;
}

OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
| (req->data->blocks << 16));
- set_data_timeout(host, req);
+ set_data_timeout(host, req->data->timeout_ns, req->data->timeout_clks);

if (host->use_dma) {
ret = omap_hsmmc_start_dma_transfer(host, req);
--
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH 2/4 v2] libata: Implement disk shock protection support
    ... Doesn't prepare_to_waithave to come before pull_action and timeout ... to failed commands on another device. ... int nr_failed_devs; ...
    (Linux-Kernel)
  • Re: socket buffer flush question
    ... hardware, in which there could sometimes be timeouts. ... responses from that hardware. ... When a timeout happens, for some reason extra data is stored inside ... It looks to me like you've sent 6 more commands during the timeout period, ...
    (comp.lang.python)
  • Re: Set an SQLCommand timeout default application wide?
    ... The commands that timeout are typically updating/inserting 100's of ... > this b/c I the default is 30 seconds and I don't believe it's read out of ... > most many instances,chaning the command timeout is a bandaid and it tends ... we are seeing SQLCommand timeouts. ...
    (microsoft.public.dotnet.framework.adonet)
  • read data from a modem
    ... you can increase your timeout by using this: ... matlab commands to read data from a GSM modem through RS232 ...
    (comp.soft-sys.matlab)
  • [PATCH V2 31/32] omap_hsmmc: set a large data timeout for commands with busy signal
    ... Subject: omap_hsmmc: set a large data timeout for commands with busy signal ... Commands like SWITCH send a response and then signal busy ...
    (Linux-Kernel)