From patchwork Mon Dec 12 15:36:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5601 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 01FB023E18 for ; Mon, 12 Dec 2011 15:36:42 +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 E35B2A1856E for ; Mon, 12 Dec 2011 15:36:41 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id 17so7484197bke.11 for ; Mon, 12 Dec 2011 07:36:41 -0800 (PST) Received: by 10.204.152.138 with SMTP id g10mr8150759bkw.36.1323704201711; Mon, 12 Dec 2011 07:36:41 -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 hg2cs50801bkc; Mon, 12 Dec 2011 07:36:41 -0800 (PST) Received: by 10.14.10.18 with SMTP id 18mr456217eeu.194.1323704199633; Mon, 12 Dec 2011 07:36:39 -0800 (PST) Received: from eu1sys200aog118.obsmtp.com (eu1sys200aog118.obsmtp.com. [207.126.144.145]) by mx.google.com with SMTP id z15si6146160eef.136.2011.12.12.07.36.35 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Dec 2011 07:36:39 -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-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKTuYfgXcyQB/Q1HSgy/QIJcDksvTeVsN+@postini.com; Mon, 12 Dec 2011 15:36:39 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id B7561C0; Mon, 12 Dec 2011 15:28:04 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 5F65B10BE; Mon, 12 Dec 2011 15:36:30 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 9A320A807B; Mon, 12 Dec 2011 16:36:23 +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:29 +0100 From: Ulf Hansson To: , Cc: Russell King , Ulf Hansson , Lee Jones , Stefan Nilsson XK , Fredrik Soderstedt Subject: [PATCH 4/5] mmc: mmci: Fix PIO read for small SDIO packets Date: Mon, 12 Dec 2011 16:36:06 +0100 Message-ID: <1323704167-10247-5-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 From: Stefan Nilsson XK Corrects a bug in MMCI host driver which silently causes small reads (< 4 bytes as only used in SDIO) from PL-18X to fail. Signed-off-by: Stefan Nilsson XK Signed-off-by: Ulf Hansson Signed-off-by: Fredrik Soderstedt --- drivers/mmc/host/mmci.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 9ea2f13..94c04c3 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -876,7 +876,24 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema if (count <= 0) break; - readsl(base + MMCIFIFO, ptr, count >> 2); + /* + * SDIO especially may want to send something that is + * not divisible by 4 (as opposed to card sectors + * etc). Therefore make sure to always read the last bytes + * while only doing full 32-bit reads towards the FIFO. + */ + if (unlikely(count & 0x3)) { + if (count < 4) { + unsigned char buf[4]; + readsl(base + MMCIFIFO, buf, 1); + memcpy(ptr, buf, count); + } else { + readsl(base + MMCIFIFO, ptr, count >> 2); + count &= ~0x3; + } + } else { + readsl(base + MMCIFIFO, ptr, count >> 2); + } ptr += count; remain -= count;