r4653 - developers/werner/wlan-spi/patches
werner at docs.openmoko.org
werner at docs.openmoko.org
Thu Sep 18 05:53:45 CEST 2008
Author: werner
Date: 2008-09-18 05:53:44 +0200 (Thu, 18 Sep 2008)
New Revision: 4653
Added:
developers/werner/wlan-spi/patches/s3c-spi-stray-irq.patch
Log:
Make spi_s3c24xx.c absorb an initial stray interrupt without unleashing
chaos and mayhem.
Added: developers/werner/wlan-spi/patches/s3c-spi-stray-irq.patch
===================================================================
--- developers/werner/wlan-spi/patches/s3c-spi-stray-irq.patch (rev 0)
+++ developers/werner/wlan-spi/patches/s3c-spi-stray-irq.patch 2008-09-18 03:53:44 UTC (rev 4653)
@@ -0,0 +1,66 @@
+s3c-spi-stray-irq.patch
+
+The S3C SPI hardware may generate a stray interrupt when first activated.
+This interrupt was treated by spi_s3c24xx like the termination of a
+transfer, which led to the following sequence of events:
+
+- s3c24xx_spi_irq called complete(), increasing hw->done.done to 1,
+ therefore
+
+- subsequent calls to s3c24xx_spi_txrx did not wait for completion
+ but returned almost immediately, which
+
+- if running at a slow enough SPI clock, caused
+ a) s3c24xx_spi_txrx to return with less than t->len bytes
+ sent/received,
+ b) bitbang_work to deassert chip select while the transfer was still
+ in progress, and
+ c) occasionally also made the next transfer overrun the previous one.
+
+- all this caused communication with the SDIO module to fail completely,
+ usually already at the very first command
+
+This patch makes the driver silently absorb any interrupts received
+before the first transfer starts and it also adds a few paranoia BUG_ONs
+to ensure the problem stays solved.
+
+Note that there is a race between the moment the stray interrupt is
+generated and the moment the first transfer begins. The assumption here
+is that this first interrupt is delivered immediately after registering
+the interrupt and/or the SPI clock, and can thus never conflict with a
+transfer. This still needs verifying.
+
+Not-Yet-Signed-off-by: Werner Almesberger <werner at openmoko.org>
+
+Index: korig/drivers/spi/spi_s3c24xx.c
+===================================================================
+--- korig.orig/drivers/spi/spi_s3c24xx.c 2008-09-17 19:10:35.000000000 -0300
++++ korig/drivers/spi/spi_s3c24xx.c 2008-09-17 19:24:12.000000000 -0300
+@@ -187,6 +187,8 @@
+ dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n",
+ t->tx_buf, t->rx_buf, t->len);
+
++ BUG_ON(!t->len);
++
+ hw->tx = t->tx_buf;
+ hw->rx = t->rx_buf;
+ hw->len = t->len;
+@@ -205,6 +207,18 @@
+ unsigned int spsta = readb(hw->regs + S3C2410_SPSTA);
+ unsigned int count = hw->count;
+
++ /*
++ * We may get a stray interrupt before the first request.
++ * Just ignore it.
++ */
++
++ if (!hw->len)
++ return IRQ_HANDLED;
++
++ /* make sure we're *really* properly synchronized */
++
++ BUG_ON(hw->done.done);
++
+ if (spsta & S3C2410_SPSTA_DCOL) {
+ dev_dbg(hw->dev, "data-collision\n");
+ complete(&hw->done);
More information about the commitlog
mailing list