MIPS: Support SWIOTLB in default dma operations
authorJayachandran C <jchandra@broadcom.com>
Mon, 10 Jun 2013 06:28:08 +0000 (06:28 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 13 Jun 2013 15:46:40 +0000 (17:46 +0200)
Provide a default implementation of phys_to_dma and dma_to_phys in
mach-generic/dma_coherence.h.

If CONFIG_NEED_SG_DMA_LENGTH is defined, the dma_length field in
struct scatterlist is used. Set this up in mips_dma_map_sg so that
the default mips DMA ops can be used when SWIOTLB is enabled.

Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5409/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/mach-generic/dma-coherence.h
arch/mips/mm/dma-default.c

index fe23034aaf721497af158ee2deec840038478dcf..74cb99257d5b9b25dda5aec6fa1eaa1553612086 100644 (file)
@@ -66,4 +66,16 @@ static inline int plat_device_is_coherent(struct device *dev)
 #endif
 }
 
+#ifdef CONFIG_SWIOTLB
+static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+       return paddr;
+}
+
+static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+       return daddr;
+}
+#endif
+
 #endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
index caf92ecb37d6966639c47e6eb277d74cb42f2012..aaccf1c106997aecc8fa7050a4bfa8072212dab0 100644 (file)
@@ -246,6 +246,9 @@ static int mips_dma_map_sg(struct device *dev, struct scatterlist *sg,
                if (!plat_device_is_coherent(dev))
                        __dma_sync(sg_page(sg), sg->offset, sg->length,
                                   direction);
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+               sg->dma_length = sg->length;
+#endif
                sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) +
                                  sg->offset;
        }