From patchwork Fri Feb 25 18:49:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Rakity X-Patchwork-Id: 590941 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1PIoFAJ030127 for ; Fri, 25 Feb 2011 18:50:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756236Ab1BYSuM (ORCPT ); Fri, 25 Feb 2011 13:50:12 -0500 Received: from na3sys009aog115.obsmtp.com ([74.125.149.238]:42044 "EHLO na3sys009aog115.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755794Ab1BYSuL convert rfc822-to-8bit (ORCPT ); Fri, 25 Feb 2011 13:50:11 -0500 Received: from source ([65.219.4.130]) (using TLSv1) by na3sys009aob115.postini.com ([74.125.148.12]) with SMTP ID DSNKTWf5wAG2EpiZ9JKpjxGknrMu2wUUjSwn@postini.com; Fri, 25 Feb 2011 10:50:11 PST Received: from SC-vEXCH3.marvell.com ([10.93.76.133]) by sc-owa02.marvell.com ([10.93.76.22]) with mapi; Fri, 25 Feb 2011 10:49:27 -0800 From: Philip Rakity To: Wolfram Sang CC: "linux-mmc@vger.kernel.org" , Kyungmin Park , Jae hoon Chung , Chuanxiao Dong , "linux-kernel@vger.kernel.org" Date: Fri, 25 Feb 2011 10:49:25 -0800 Subject: [PATCH V2] sdhci: always use max timeout for xfers Thread-Topic: [PATCH V2] sdhci: always use max timeout for xfers Thread-Index: AcvVHLqSSU9pHG6NQtykrm6kaJx+Fw== Message-ID: <62F39533-530F-4DF4-BBC6-AF8E9AB9E751@marvell.com> References: <20110225180248.GA15491@pengutronix.de> <9C437661-BFCC-4F73-989E-06589E0D37CA@marvell.com> <20110225182206.GC15491@pengutronix.de> In-Reply-To: <20110225182206.GC15491@pengutronix.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 25 Feb 2011 18:50:15 +0000 (UTC) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 655617c..d615173 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -592,55 +592,6 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } -static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) -{ - u8 count; - unsigned target_timeout, current_timeout; - - /* - * If the host controller provides us with an incorrect timeout - * value, just skip the check and use 0xE. The hardware may take - * longer to time out, but that's much better than having a too-short - * timeout value. - */ - if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL) - return 0xE; - - /* timeout in us */ - target_timeout = data->timeout_ns / 1000 + - data->timeout_clks / host->clock; - - if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) - host->timeout_clk = host->clock / 1000; - - /* - * Figure out needed cycles. - * We do this in steps in order to fit inside a 32 bit int. - * The first step is the minimum timeout, which will have a - * minimum resolution of 6 bits: - * (1) 2^13*1000 > 2^22, - * (2) host->timeout_clk < 2^16 - * => - * (1) / (2) > 2^6 - */ - count = 0; - current_timeout = (1 << 13) * 1000 / host->timeout_clk; - while (current_timeout < target_timeout) { - count++; - current_timeout <<= 1; - if (count >= 0xF) - break; - } - - if (count >= 0xF) { - printk(KERN_WARNING "%s: Too large timeout requested!\n", - mmc_hostname(host->mmc)); - count = 0xE; - } - - return count; -} - static void sdhci_set_transfer_irqs(struct sdhci_host *host) { u32 pio_irqs = SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL; @@ -654,7 +605,6 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host) static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) { - u8 count; u8 ctrl; int ret; @@ -671,8 +621,13 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) host->data = data; host->data_early = 0; - count = sdhci_calc_timeout(host, data); - sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); + /* + * The host controller/card can provide us with an incorrect timeout + * value, just use the maximum value 0xE. The hardware may take + * longer to time out, but that's much better than having a too-short + * timeout value. + */ + sdhci_writeb(host, SDHCI_TIMEOUT_MAX, SDHCI_TIMEOUT_CONTROL); if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) host->flags |= SDHCI_REQ_USE_DMA; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 1f032c0..19b4d41 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -103,6 +103,7 @@ #define SDHCI_CLOCK_INT_EN 0x0001 #define SDHCI_TIMEOUT_CONTROL 0x2E +#define SDHCI_TIMEOUT_MAX 0xE #define SDHCI_SOFTWARE_RESET 0x2F #define SDHCI_RESET_ALL 0x01