From patchwork Thu May 5 11:14:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1354 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:51:18 -0000 Delivered-To: patches@linaro.org Received: by 10.224.184.145 with SMTP id ck17cs93872qab; Thu, 5 May 2011 04:14:39 -0700 (PDT) Received: by 10.213.20.212 with SMTP id g20mr227318ebb.7.1304594078661; Thu, 05 May 2011 04:14:38 -0700 (PDT) Received: from eu1sys200aog106.obsmtp.com (eu1sys200aog106.obsmtp.com [207.126.144.121]) by mx.google.com with SMTP id f16si1729379eec.46.2011.05.05.04.14.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2011 04:14:38 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.121; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob106.postini.com ([207.126.147.11]) with SMTP ID DSNKTcKGl4fkkunXIQb0BNyXjvQWlxoNzFKX@postini.com; Thu, 05 May 2011 11:14:38 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 2F21113F; Thu, 5 May 2011 11:14:29 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id E0370A3E; Thu, 5 May 2011 11:14:28 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 77580A80AD; Thu, 5 May 2011 13:14:23 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.2.254.0; Thu, 5 May 2011 13:14:27 +0200 From: Linus Walleij To: , Cc: Lee Jones , Dmitry Tarnyagin , Linus Walleij Subject: [PATCH 2/2] mmci: fixup sg buffer handling in mmci_pio_irq. Date: Thu, 5 May 2011 13:14:23 +0200 Message-ID: <1304594063-19408-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Dmitry Tarnyagin Earlier code was expecting that mmci_pio_write() returns not more than 'remain' bytes transferred. It is not the case for buffers which are not multiple of 4 bytes length. The patch fix the problem by checking result of mmci_pio_write(). The fault was introduced in the change: I2e506ec1f5a7fadf9780c18d8d31573eaf048273 MMCI: Fixup sg buffer handling in pio_write Signed-off-by: Dmitry Tarnyagin Signed-off-by: Linus Walleij --- drivers/mmc/host/mmci.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 6e27433..e238462 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -753,7 +753,10 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) if (status & MCI_TXACTIVE) len = mmci_pio_write(host, buffer, remain, status); - sg_miter->consumed = len; + if (len > sg_miter->consumed) + len = sg_miter->consumed; + else + sg_miter->consumed = len; host->size -= len; remain -= len;