[PATCH 5/10] ARM: fix DMA-bounce code to allow sync from_device and to_device with bidirectional mappings.

Krzysztof Halasa
2012-09-20T20:19:40Z

Signed-off-by: Krzysztof Ha?asa <khc@pm.waw.pl>

--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -375,7 +375,7 @@ static int __dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,

off = addr - buf->safe_dma_addr;

- BUG_ON(buf->direction != dir);
+ BUG_ON(buf->direction != dir && buf->direction != DMA_BIDIRECTIONAL);

dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
@@ -415,7 +415,7 @@ static int __dmabounce_sync_for_device(struct device *dev, dma_addr_t addr,

off = addr - buf->safe_dma_addr;

- BUG_ON(buf->direction != dir);
+ BUG_ON(buf->direction != dir && buf->direction != DMA_BIDIRECTIONAL);

dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,