From patchwork Tue Jan 17 14:34:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 6266 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 75C8223E0C for ; Tue, 17 Jan 2012 14:35:10 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 5F0E1A18583 for ; Tue, 17 Jan 2012 14:35:10 +0000 (UTC) Received: by mail-bk0-f52.google.com with SMTP id zt4so1750806bkb.11 for ; Tue, 17 Jan 2012 06:35:10 -0800 (PST) Received: by 10.205.141.72 with SMTP id jd8mr2300130bkc.135.1326810910208; Tue, 17 Jan 2012 06:35:10 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs120342bkc; Tue, 17 Jan 2012 06:35:09 -0800 (PST) Received: by 10.213.26.77 with SMTP id d13mr4289347ebc.132.1326810908447; Tue, 17 Jan 2012 06:35:08 -0800 (PST) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com. [207.126.144.147]) by mx.google.com with SMTP id v15si15408158eem.23.2012.01.17.06.35.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Jan 2012 06:35:08 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.147; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKTxWHEf4xSSdcdHfpw7YR3BDCyhIgnxxZ@postini.com; Tue, 17 Jan 2012 14:35:08 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 6CF5858; Tue, 17 Jan 2012 14:34:41 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 22DB458; Tue, 17 Jan 2012 13:40:27 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 0B12624C080; Tue, 17 Jan 2012 15:34:41 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 17 Jan 2012 15:34:48 +0100 From: Ulf Hansson To: , Cc: Russell King , Ulf Hansson , Lee Jones , Per Forlin , Johan Rudholm , Stefan Nilsson XK , Fredrik Soderstedt , Linus Walleij Subject: [PATCH 6/8] mmc: mmci: Fix incorrect handling of HW flow control for SDIO Date: Tue, 17 Jan 2012 15:34:25 +0100 Message-ID: <1326810867-5346-7-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1326810867-5346-1-git-send-email-ulf.hansson@stericsson.com> References: <1326810867-5346-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 For data writes smaller than 8 bytes (only SDIO case), HW flow control was disabled but never re-enabled again. This meant that a following large read request could randomly give buffer overrun errors. This patch is based upon a patch from Stefan Nilsson. Signed-off-by: Ulf Hansson Signed-off-by: Stefan Nilsson XK Signed-off-by: Fredrik Soderstedt Signed-off-by: Linus Walleij --- drivers/mmc/host/mmci.c | 38 ++++++++++++++++++++------------------ 1 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 3defe69..e7b4500 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -638,10 +638,28 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) if (data->flags & MMC_DATA_READ) datactrl |= MCI_DPSM_DIRECTION; - /* The ST Micro variants has a special bit to enable SDIO */ if (variant->sdio && host->mmc->card) - if (mmc_card_sdio(host->mmc->card)) + if (mmc_card_sdio(host->mmc->card)) { + + /* + * The ST Micro variant for SDIO write transfer sizes + * less then 8 bytes must have clock H/W flow control + * disabled. + */ + u32 clk; + if ((host->size < 8) && (data->flags & MMC_DATA_WRITE)) + clk = host->clk_reg & ~variant->clkreg_enable; + else + clk = host->clk_reg | variant->clkreg_enable; + + mmci_write_clkreg(host, clk); + + /* + * The ST Micro variants has a special bit + * to enable SDIO. + */ datactrl |= MCI_ST_DPSM_SDIOEN; + } /* * Attempt to use DMA operation mode, if this @@ -863,22 +881,6 @@ static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int rem count = min(remain, maxcnt); /* - * The ST Micro variant for SDIO transfer sizes - * less then 8 bytes should have clock H/W flow - * control disabled. - */ - if (variant->sdio && - mmc_card_sdio(host->mmc->card)) { - u32 clk; - if (count < 8) - clk = host->clk_reg & ~variant->clkreg_enable; - else - clk = host->clk_reg | variant->clkreg_enable; - - mmci_write_clkreg(host, clk); - } - - /* * SDIO especially may want to send something that is * not divisible by 4 (as opposed to card sectors * etc), and the FIFO only accept full 32-bit writes.