diff mbox

[2/2] omap2-mcspi: fall back to PIO when the buffer is in high mem

Message ID 1346338971-9106-2-git-send-email-jlu@pengutronix.de (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Jan Lübbe Aug. 30, 2012, 3:02 p.m. UTC
UBI uses vmalloc'ed buffers in some cases which are not valid for
DMA, so use PIO instead.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/spi/spi-omap2-mcspi.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index ceb27fc..6f361a1 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -927,7 +927,9 @@  static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
 				__raw_writel(0, cs->base
 						+ OMAP2_MCSPI_TX0);
 
-			if (m->is_dma_mapped || t->len >= DMA_MIN_BYTES)
+			if (m->is_dma_mapped || (t->len >= DMA_MIN_BYTES
+				&& t->tx_buf < high_memory
+				&& t->rx_buf < high_memory))
 				count = omap2_mcspi_txrx_dma(spi, t);
 			else
 				count = omap2_mcspi_txrx_pio(spi, t);
@@ -1004,6 +1006,11 @@  static int omap2_mcspi_transfer_one_message(struct spi_master *master,
 		if (m->is_dma_mapped || len < DMA_MIN_BYTES)
 			continue;
 
+		if (tx_buf >= high_memory || rx_buf >= high_memory) {
+			WARN_ONCE(1, "high memory is invalid for DMA, falling back to PIO\n");
+			continue;
+		}
+
 		if (tx_buf != NULL) {
 			t->tx_dma = dma_map_single(mcspi->dev, (void *) tx_buf,
 					len, DMA_TO_DEVICE);