From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org, jejb@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Ned Forrester <nforrester@whoi.edu>,
Vernon Sauder <vernoninhand@gmail.com>,
Eric Miao <eric.y.miao@gmail.com>,
David Brownell <dbrownell@users.sourceforge.net>
Subject: [patch 02/28] pxa2xx_spi: dma bugfixes
Date: Mon, 6 Oct 2008 16:17:01 -0700 [thread overview]
Message-ID: <20081006231701.GC20567@suse.de> (raw)
In-Reply-To: <20081006231639.GA20567@suse.de>
[-- Attachment #1: pxa2xx_spi-dma-bugfixes.patch --]
[-- Type: text/plain, Size: 4822 bytes --]
2.6.25-stable review patch. If anyone has any objections, please let us
know.
------------------
From: Ned Forrester <nforrester@whoi.edu>
commit 7e96445533ac3f4f7964646a202ff3620602fab4 upstream
Fixes two DMA bugs in the pxa2xx_spi driver. The first bug is in all
versions of this driver; the second was introduced in the 2.6.20 kernel,
and prevents using the driver with chips like m25p16 flash (which can
issue large DMA reads).
1. Zero length transfers are permitted for use to insert timing,
but pxa2xx_spi.c will fail if this is requested in DMA mode.
Fixed by using programmed I/O (PIO) mode for such transfers.
2. Transfers larger than 8191 are not permitted in DMA mode. A
test for length rejects all large transfers regardless of DMA
or PIO mode. Worked around by rejecting only large transfers
with DMA mapped buffers, and forcing all other transfers
larger than 8191 to use PIO mode. A rate limited warning is
issued for DMA transfers forced to PIO mode.
This patch should apply to all kernels back to and including 2.6.20;
it was test patched against 2.6.20. An additional patch would be
required for older kernels, but those versions are very buggy anyway.
Signed-off-by: Ned Forrester <nforrester@whoi.edu>
Cc: Vernon Sauder <vernoninhand@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/spi/pxa2xx_spi.c | 57 +++++++++++++++++++++++++++++++++++------------
1 file changed, 43 insertions(+), 14 deletions(-)
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -48,9 +48,10 @@ MODULE_ALIAS("platform:pxa2xx-spi");
#define MAX_BUSES 3
-#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR)
-#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK)
-#define IS_DMA_ALIGNED(x) (((u32)(x)&0x07)==0)
+#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR)
+#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK)
+#define IS_DMA_ALIGNED(x) (((x) & 0x07) == 0)
+#define MAX_DMA_LEN 8191
/*
* for testing SSCR1 changes that require SSP restart, basically
@@ -846,14 +847,27 @@ static void pump_transfers(unsigned long
udelay(previous->delay_usecs);
}
- /* Check transfer length */
- if (transfer->len > 8191)
- {
- dev_warn(&drv_data->pdev->dev, "pump_transfers: transfer "
- "length greater than 8191\n");
- message->status = -EINVAL;
- giveback(drv_data);
- return;
+ /* Check for transfers that need multiple DMA segments */
+ if (transfer->len > MAX_DMA_LEN && chip->enable_dma) {
+
+ /* reject already-mapped transfers; PIO won't always work */
+ if (message->is_dma_mapped
+ || transfer->rx_dma || transfer->tx_dma) {
+ dev_err(&drv_data->pdev->dev,
+ "pump_transfers: mapped transfer length "
+ "of %lu is greater than %d\n",
+ transfer->len, MAX_DMA_LEN);
+ message->status = -EINVAL;
+ giveback(drv_data);
+ return;
+ }
+
+ /* warn ... we force this to PIO mode */
+ if (printk_ratelimit())
+ dev_warn(&message->spi->dev, "pump_transfers: "
+ "DMA disabled for transfer length %ld "
+ "greater than %d\n",
+ (long)drv_data->len, MAX_DMA_LEN);
}
/* Setup the transfer state based on the type of transfer */
@@ -922,7 +936,7 @@ static void pump_transfers(unsigned long
&dma_thresh))
if (printk_ratelimit())
dev_warn(&message->spi->dev,
- "pump_transfer: "
+ "pump_transfers: "
"DMA burst size reduced to "
"match bits_per_word\n");
}
@@ -936,8 +950,23 @@ static void pump_transfers(unsigned long
message->state = RUNNING_STATE;
- /* Try to map dma buffer and do a dma transfer if successful */
- if ((drv_data->dma_mapped = map_dma_buffers(drv_data))) {
+ /* Try to map dma buffer and do a dma transfer if successful, but
+ * only if the length is non-zero and less than MAX_DMA_LEN.
+ *
+ * Zero-length non-descriptor DMA is illegal on PXA2xx; force use
+ * of PIO instead. Care is needed above because the transfer may
+ * have have been passed with buffers that are already dma mapped.
+ * A zero-length transfer in PIO mode will not try to write/read
+ * to/from the buffers
+ *
+ * REVISIT large transfers are exactly where we most want to be
+ * using DMA. If this happens much, split those transfers into
+ * multiple DMA segments rather than forcing PIO.
+ */
+ drv_data->dma_mapped = 0;
+ if (drv_data->len > 0 && drv_data->len <= MAX_DMA_LEN)
+ drv_data->dma_mapped = map_dma_buffers(drv_data);
+ if (drv_data->dma_mapped) {
/* Ensure we have the correct interrupt handler */
drv_data->transfer_handler = dma_transfer;
--
next prev parent reply other threads:[~2008-10-06 23:22 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081006225949.357365087@mini.kroah.org>
2008-10-06 23:16 ` [patch 00/28] 2.6.25-stable review Greg KH
2008-10-06 23:16 ` [patch 01/28] USB: fix hcd interrupt disabling Greg KH
2008-10-06 23:17 ` Greg KH [this message]
2008-10-07 0:15 ` [patch 02/28] pxa2xx_spi: dma bugfixes Ned Forrester
2008-10-06 23:17 ` [patch 03/28] pxa2xx_spi: chipselect bugfixes Greg KH
2008-10-06 23:17 ` [patch 04/28] drivers/mmc/card/block.c: fix refcount leak in mmc_block_open() Greg KH
2008-10-06 23:17 ` [patch 05/28] ALSA: hda - Fix model for Dell Inspiron 1525 Greg KH
2008-10-07 5:55 ` Takashi Iwai
2008-10-09 2:38 ` Greg KH
2008-10-06 23:17 ` [patch 06/28] i2c-dev: Return correct error code on class_create() failure Greg KH
2008-10-06 23:17 ` [patch 07/28] ACPI: Fix thermal shutdowns Greg KH
2008-10-06 23:17 ` [patch 08/28] x86: add io delay quirk for Presario F700 Greg KH
2008-10-06 23:17 ` [patch 09/28] rtc: fix deadlock Greg KH
2008-10-06 23:17 ` [patch 10/28] ACPI: Avoid bogus EC timeout when EC is in Polling mode Greg KH
2008-10-06 23:17 ` [patch 11/28] clockevents: prevent clockevent event_handler ending up handler_noop Greg KH
2008-10-06 23:17 ` [patch 12/28] clockevents: prevent endless loop in periodic broadcast handler Greg KH
2008-10-06 23:17 ` [patch 13/28] clockevents: enforce reprogram in oneshot setup Greg KH
2008-10-06 23:17 ` [patch 14/28] clockevents: prevent multiple init/shutdown Greg KH
2008-10-06 23:17 ` [patch 15/28] clockevents: prevent endless loop lockup Greg KH
2008-10-06 23:17 ` [patch 16/28] HPET: make minimum reprogramming delta useful Greg KH
2008-10-06 23:17 ` [patch 17/28] clockevents: broadcast fixup possible waiters Greg KH
2008-10-06 23:17 ` [patch 18/28] x86: HPET fix moronic 32/64bit thinko Greg KH
2008-10-06 23:17 ` [patch 19/28] x86: HPET: read back compare register before reading counter Greg KH
2008-10-06 23:17 ` [patch 20/28] ntp: fix calculation of the next jiffie to trigger RTC sync Greg KH
2008-10-06 23:17 ` [patch 21/28] clockevents: remove WARN_ON which was used to gather information Greg KH
2008-10-06 23:17 ` [patch 22/28] x86: Fix broken LDT access in VMI Greg KH
2008-10-06 23:17 ` [patch 23/28] ipv6: Fix OOPS in ip6_dst_lookup_tail() Greg KH
2008-10-06 23:51 ` Neil Horman
2008-10-06 23:17 ` [patch 24/28] niu: panic on reset Greg KH
2008-10-06 23:17 ` [patch 25/28] netlink: fix overrun in attribute iteration Greg KH
2008-10-06 23:17 ` [patch 26/28] sctp: do not enable peer features if we cant do them Greg KH
2008-10-06 23:17 ` [patch 27/28] sctp: Fix oops when INIT-ACK indicates that peer doesnt support AUTH Greg KH
2008-10-06 23:18 ` [patch 28/28] udp: Fix rcv socket locking Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081006231701.GC20567@suse.de \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=dbrownell@users.sourceforge.net \
--cc=eric.y.miao@gmail.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jejb@kernel.org \
--cc=jmforbes@linuxtx.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=nforrester@whoi.edu \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=vernoninhand@gmail.com \
--cc=w@1wt.eu \
--cc=zwane@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).