1 From 4885eb650b27f5639c8c72b8d4daa37f533b0b4d Mon Sep 17 00:00:00 2001
2 From: Yutang Jiang <yutang.jiang@nxp.com>
3 Date: Fri, 22 Jul 2016 01:03:29 +0800
4 Subject: [PATCH 69/70] Revert "arm64: simplify dma_get_ops"
6 This reverts commit 1dccb598df549d892b6450c261da54cdd7af44b4.
8 arch/arm64/include/asm/dma-mapping.h | 13 ++++++++++---
9 arch/arm64/mm/dma-mapping.c | 16 ++++++++++++----
10 2 files changed, 22 insertions(+), 7 deletions(-)
12 --- a/arch/arm64/include/asm/dma-mapping.h
13 +++ b/arch/arm64/include/asm/dma-mapping.h
18 +#include <linux/acpi.h>
19 #include <linux/types.h>
20 #include <linux/vmalloc.h>
23 #include <asm/xen/hypervisor.h>
25 #define DMA_ERROR_CODE (~(dma_addr_t)0)
26 +extern struct dma_map_ops *dma_ops;
27 extern struct dma_map_ops dummy_dma_ops;
29 static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
31 - if (dev && dev->archdata.dma_ops)
34 + else if (dev->archdata.dma_ops)
35 return dev->archdata.dma_ops;
36 + else if (acpi_disabled)
40 - * We expect no ISA devices, and all other DMA masters are expected to
41 - * have someone call arch_setup_dma_ops at device creation time.
42 + * When ACPI is enabled, if arch_set_dma_ops is not called,
43 + * we will disable device DMA capability by setting it
46 return &dummy_dma_ops;
48 --- a/arch/arm64/mm/dma-mapping.c
49 +++ b/arch/arm64/mm/dma-mapping.c
53 #include <linux/gfp.h>
54 -#include <linux/acpi.h>
55 #include <linux/export.h>
56 #include <linux/slab.h>
57 #include <linux/genalloc.h>
60 #include <asm/cacheflush.h>
62 +struct dma_map_ops *dma_ops;
63 +EXPORT_SYMBOL(dma_ops);
65 static pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
68 @@ -513,7 +515,13 @@ EXPORT_SYMBOL(dummy_dma_ops);
70 static int __init arm64_dma_init(void)
72 - return atomic_pool_init();
75 + dma_ops = &swiotlb_dma_ops;
77 + ret = atomic_pool_init();
81 arch_initcall(arm64_dma_init);
83 @@ -987,8 +995,8 @@ static void __iommu_setup_dma_ops(struct
84 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
85 struct iommu_ops *iommu, bool coherent)
87 - if (!dev->archdata.dma_ops)
88 - dev->archdata.dma_ops = &swiotlb_dma_ops;
89 + if (!acpi_disabled && !dev->archdata.dma_ops)
90 + dev->archdata.dma_ops = dma_ops;
92 dev->archdata.dma_coherent = coherent;
93 __iommu_setup_dma_ops(dev, dma_base, size, iommu);