From: akpm@linux-foundation.org Subject: [patch 072/232] omap_hsmmc: set a large data timeout for commands with busy signal Date: Tue, 22 Sep 2009 16:45:03 -0700 Message-ID: <200909222345.n8MNj4E8013543@imap1.linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:48359 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753359AbZIWARx (ORCPT ); Tue, 22 Sep 2009 20:17:53 -0400 Sender: linux-mmc-owner@vger.kernel.org List-Id: linux-mmc@vger.kernel.org To: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org, adrian.hunter@nokia.com, ext-denis.2.karpov@nokia.com, ian@mnementh.co.uk, jarkko.lavinen@nokia.com, linux-mmc@vger.kernel.org, madhu.cr@ti.com, matt@console-pimps.org, philipl@overt.org, pierre@ossman.eu, roberto.foglietta@gmail.com From: Adrian Hunter 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 Acked-by: Matt Fleming Cc: Ian Molton Cc: "Roberto A. Foglietta" Cc: Jarkko Lavinen Cc: Denis Karpov Cc: Pierre Ossman Cc: Philip Langdale Cc: "Madhusudhan" Cc: Signed-off-by: Andrew Morton --- drivers/mmc/host/omap_hsmmc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff -puN drivers/mmc/host/omap_hsmmc.c~omap_hsmmc-set-a-large-data-timeout-for-commands-with-busy-signal drivers/mmc/host/omap_hsmmc.c --- a/drivers/mmc/host/omap_hsmmc.c~omap_hsmmc-set-a-large-data-timeout-for-commands-with-busy-signal +++ a/drivers/mmc/host/omap_hsmmc.c @@ -997,7 +997,8 @@ static int omap_hsmmc_start_dma_transfer } 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; @@ -1008,8 +1009,8 @@ static void set_data_timeout(struct omap 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; @@ -1043,12 +1044,18 @@ omap_hsmmc_prepare_data(struct omap_hsmm 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); _