From patchwork Wed Oct 10 15:43:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 12149 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 34E4323F58 for ; Wed, 10 Oct 2012 15:44:29 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id A9A4DA18814 for ; Wed, 10 Oct 2012 15:44:28 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1121984iej.11 for ; Wed, 10 Oct 2012 08:44:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=6lcEVzhYkpOAohSY8whOi8dd4Em1+mHQlqxmUW8D+FU=; b=gMHmmcnyeoqygk+5g9bSJp0kbqtKI3OLnR7ZG8nINIrotHyPOp2Fa3tDm+VMmnRTOA RZOKpVG1kMr8yAIyaqLiZ4ZqWdq04Z5SVmBNdhW33jMvKSUoxbIAYLYkIPh30PDvWWUH 8WdNev8LC0sFUj/mz3vLXdzrnhF10dCEqznja243VvCb3oUoPvpK8GJpBMq1hakqy5oW WFBi57DGnETfp9ifYJsRSE+lxFpHiZi9tF6nX7R1MDOa1Aaqn2Bm5jxpQMNZQFWC/6w6 HCoo4afUX7pEfqSg3zj847iiYHBv0D6NT50opp2YXPlSPF+1VeLDDCwFjREX5ghlEvMW Gg1Q== Received: by 10.50.152.137 with SMTP id uy9mr5637342igb.62.1349883868054; Wed, 10 Oct 2012 08:44:28 -0700 (PDT) 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.50.67.148 with SMTP id n20csp243435igt; Wed, 10 Oct 2012 08:44:27 -0700 (PDT) Received: by 10.14.211.193 with SMTP id w41mr7568181eeo.32.1349883865403; Wed, 10 Oct 2012 08:44:25 -0700 (PDT) Received: from eu1sys200aog101.obsmtp.com (eu1sys200aog101.obsmtp.com [207.126.144.111]) by mx.google.com with SMTP id g9si1321951eep.0.2012.10.10.08.44.20 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 08:44:25 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.111 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.111; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.111 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 eu1sys200aob101.postini.com ([207.126.147.11]) with SMTP ID DSNKUHWXznUL2zfm9MZ09zEKnRQg1TG0u/nv@postini.com; Wed, 10 Oct 2012 15:44:25 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 1A7974A; Wed, 10 Oct 2012 15:43:20 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id CEDE14A; Wed, 10 Oct 2012 11:22:34 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 2E5F2A8098; Wed, 10 Oct 2012 17:43:45 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 10 Oct 2012 17:43:51 +0200 From: Ulf Hansson To: , Chris Ball Cc: , Russell King , Linus Walleij , Ulf Hansson Subject: [PATCH 1/2] mmc: mmci: Fix incorrect handling of HW flow control for SDIO Date: Wed, 10 Oct 2012 17:43:44 +0200 Message-ID: <1349883825-22517-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmWnGeckeV2WEi8TenROVfkMMWmiaBLOgwOfKUl3rvKfDKxNUUycEOUBPVJKzovPdPMAAy/ From: Ulf Hansson <(address hidden)> For data writes <= 8 bytes, HW flow control was disabled but never re-enabled when the transfer was completed. This meant that a following read request would give buffer overrun errors. Signed-off-by: Ulf Hansson --- drivers/mmc/host/mmci.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index edc3e9b..877079e 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -654,9 +654,29 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) /* 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 variants has a special bit + * to enable SDIO. + */ + u32 clk; + datactrl |= MCI_ST_DPSM_SDIOEN; + /* + * The ST Micro variant for SDIO transfer sizes + * less then 8 bytes should have clock H/W flow + * control disabled. + */ + 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); + } + /* * Attempt to use DMA operation mode, if this * should fail, fall back to PIO mode @@ -877,22 +897,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.