From patchwork Mon Dec 12 15:36:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5599 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 23B9223E19 for ; Mon, 12 Dec 2011 15:36:36 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 12139A18576 for ; Mon, 12 Dec 2011 15:36:36 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id 17so7484197bke.11 for ; Mon, 12 Dec 2011 07:36:36 -0800 (PST) Received: by 10.205.120.135 with SMTP id fy7mr5179617bkc.54.1323704195887; Mon, 12 Dec 2011 07:36:35 -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.129.2 with SMTP id hg2cs50796bkc; Mon, 12 Dec 2011 07:36:35 -0800 (PST) Received: by 10.14.17.217 with SMTP id j65mr2639060eej.164.1323704193610; Mon, 12 Dec 2011 07:36:33 -0800 (PST) Received: from eu1sys200aog118.obsmtp.com (eu1sys200aog118.obsmtp.com. [207.126.144.145]) by mx.google.com with SMTP id u44si9576026eeb.44.2011.12.12.07.36.29 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Dec 2011 07:36:33 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.145 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.145; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.145 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-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKTuYfeVMMa0csuzL3hLAXNZtgJS9r0oJ/@postini.com; Mon, 12 Dec 2011 15:36:33 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9F4F31BD; Mon, 12 Dec 2011 15:36:24 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D5CB229BB; Mon, 12 Dec 2011 15:36:23 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 7CA3524C2E5; Mon, 12 Dec 2011 16:36:15 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 12 Dec 2011 16:36:22 +0100 From: Ulf Hansson To: , Cc: Russell King , Ulf Hansson , Lee Jones , Stefan Nilsson XK , Fredrik Soderstedt Subject: [PATCH 2/5] mmc: mmci: Fix incorrect handling of HW flow control for SDIO Date: Mon, 12 Dec 2011 16:36:04 +0100 Message-ID: <1323704167-10247-3-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323704167-10247-1-git-send-email-ulf.hansson@stericsson.com> References: <1323704167-10247-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 --- 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 d311f83..b949e07 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 @@ -846,22 +864,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.