arm64/dma-mapping: __generic_dma_ops always call swiotlb_dma_ops
authorJianqun Xu <jay.xu@rock-chips.com>
Tue, 26 Jul 2016 09:21:25 +0000 (17:21 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Tue, 26 Jul 2016 11:11:09 +0000 (19:11 +0800)
Arm64 dma-mapping will return dummy_dma_ops if none call arch_setup_dma_ops
at device creation time.

For ion APIS, ion_pages_sync_for_device and ion_pages_sync_for_cpu always
pass "NULL" as device, then dma-mapping return dummy_dma_ops, which cause
ion pages fail to sync.

This patch fixs __generic_dma_ops to return swiotlb_dma_ops instead of
dummy_dma_ops.

Change-Id: Ic00db5d4547bcd5f74e5fd155133fde408a05cdb
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
arch/arm64/include/asm/dma-mapping.h
arch/arm64/mm/dma-mapping.c

index e8d209e352ce5536c0f3c8ebbd953724eabf4887..6cf04c73e9837608a9e3e8af2a6eba8d1433a0e5 100644 (file)
 
 #define DMA_ERROR_CODE (~(dma_addr_t)0)
 extern struct dma_map_ops dummy_dma_ops;
+extern struct dma_map_ops swiotlb_dma_ops;
 
 static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
 {
        if (dev && dev->archdata.dma_ops)
                return dev->archdata.dma_ops;
 
+       /*
+        * For ion APIs, they have no devices, we force it to call swiotlb_dma_ops
+        * to sync device.
+        * Revert me if ion has fixed this issue.
+       */
+       return &swiotlb_dma_ops;
        /*
         * We expect no ISA devices, and all other DMA masters are expected to
         * have someone call arch_setup_dma_ops at device creation time.
index 2b05653e81567b4fcbe541aa30d38f2d5e19238d..93a82b0a01b778f205476abdfc6e9cdb299f0c56 100644 (file)
@@ -334,7 +334,7 @@ static int __swiotlb_get_sgtable(struct device *dev, struct sg_table *sgt,
        return ret;
 }
 
-static struct dma_map_ops swiotlb_dma_ops = {
+struct dma_map_ops swiotlb_dma_ops = {
        .alloc = __dma_alloc,
        .free = __dma_free,
        .mmap = __swiotlb_mmap,
@@ -350,6 +350,7 @@ static struct dma_map_ops swiotlb_dma_ops = {
        .dma_supported = swiotlb_dma_supported,
        .mapping_error = swiotlb_dma_mapping_error,
 };
+EXPORT_SYMBOL(swiotlb_dma_ops);
 
 static int __init atomic_pool_init(void)
 {