From 02f4e8fd9f77266c6e5defda4882d70f08e05bfd Mon Sep 17 00:00:00 2001 From: Ned Forrester Date: Wed, 19 Nov 2008 15:36:21 -0800 Subject: [PATCH] --- yaml --- r: 119181 b: refs/heads/master c: 393df744e056ba24e9531d0657d09fc3c7c0dd22 h: refs/heads/master i: 119179: 5ab278092f75caa615faf5c5d92186c128bd4ea4 v: v3 --- [refs] | 2 +- trunk/drivers/spi/pxa2xx_spi.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/[refs] b/[refs] index bf414514ccbf..92f7e164a4f4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f652c521e0bec2e70cf123f47e80117a7e6ed139 +refs/heads/master: 393df744e056ba24e9531d0657d09fc3c7c0dd22 diff --git a/trunk/drivers/spi/pxa2xx_spi.c b/trunk/drivers/spi/pxa2xx_spi.c index dae87b1a4c6e..cf12f2d84be2 100644 --- a/trunk/drivers/spi/pxa2xx_spi.c +++ b/trunk/drivers/spi/pxa2xx_spi.c @@ -352,21 +352,21 @@ static int map_dma_buffers(struct driver_data *drv_data) } else drv_data->tx_map_len = drv_data->len; - /* Stream map the rx buffer */ - drv_data->rx_dma = dma_map_single(dev, drv_data->rx, - drv_data->rx_map_len, - DMA_FROM_DEVICE); - if (dma_mapping_error(dev, drv_data->rx_dma)) - return 0; - - /* Stream map the tx buffer */ + /* Stream map the tx buffer. Always do DMA_TO_DEVICE first + * so we flush the cache *before* invalidating it, in case + * the tx and rx buffers overlap. + */ drv_data->tx_dma = dma_map_single(dev, drv_data->tx, - drv_data->tx_map_len, - DMA_TO_DEVICE); + drv_data->tx_map_len, DMA_TO_DEVICE); + if (dma_mapping_error(dev, drv_data->tx_dma)) + return 0; - if (dma_mapping_error(dev, drv_data->tx_dma)) { - dma_unmap_single(dev, drv_data->rx_dma, + /* Stream map the rx buffer */ + drv_data->rx_dma = dma_map_single(dev, drv_data->rx, drv_data->rx_map_len, DMA_FROM_DEVICE); + if (dma_mapping_error(dev, drv_data->rx_dma)) { + dma_unmap_single(dev, drv_data->tx_dma, + drv_data->tx_map_len, DMA_TO_DEVICE); return 0; }