kernel: bump to 4.4.39
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 9069-Revert-arm64-simplify-dma_get_ops.patch
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"
5
6 This reverts commit 1dccb598df549d892b6450c261da54cdd7af44b4.
7 ---
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(-)
11
12 --- a/arch/arm64/include/asm/dma-mapping.h
13 +++ b/arch/arm64/include/asm/dma-mapping.h
14 @@ -18,6 +18,7 @@
15
16 #ifdef __KERNEL__
17
18 +#include <linux/acpi.h>
19 #include <linux/types.h>
20 #include <linux/vmalloc.h>
21
22 @@ -25,16 +26,22 @@
23 #include <asm/xen/hypervisor.h>
24
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;
28
29 static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
30 {
31 - if (dev && dev->archdata.dma_ops)
32 + if (unlikely(!dev))
33 + return dma_ops;
34 + else if (dev->archdata.dma_ops)
35 return dev->archdata.dma_ops;
36 + else if (acpi_disabled)
37 + return dma_ops;
38
39 /*
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
44 + * to dummy_dma_ops.
45 */
46 return &dummy_dma_ops;
47 }
48 --- a/arch/arm64/mm/dma-mapping.c
49 +++ b/arch/arm64/mm/dma-mapping.c
50 @@ -18,7 +18,6 @@
51 */
52
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>
58 @@ -29,6 +28,9 @@
59
60 #include <asm/cacheflush.h>
61
62 +struct dma_map_ops *dma_ops;
63 +EXPORT_SYMBOL(dma_ops);
64 +
65 static pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
66 bool coherent)
67 {
68 @@ -513,7 +515,13 @@ EXPORT_SYMBOL(dummy_dma_ops);
69
70 static int __init arm64_dma_init(void)
71 {
72 - return atomic_pool_init();
73 + int ret;
74 +
75 + dma_ops = &swiotlb_dma_ops;
76 +
77 + ret = atomic_pool_init();
78 +
79 + return ret;
80 }
81 arch_initcall(arm64_dma_init);
82
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)
86 {
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;
91
92 dev->archdata.dma_coherent = coherent;
93 __iommu_setup_dma_ops(dev, dma_base, size, iommu);