hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/arm/include/asm/dma-mapping.h
....@@ -6,9 +6,6 @@
66
77 #include <linux/mm_types.h>
88 #include <linux/scatterlist.h>
9
-#include <linux/dma-debug.h>
10
-
11
-#include <asm/memory.h>
129
1310 #include <xen/xen.h>
1411 #include <asm/xen/hypervisor.h>
....@@ -18,95 +15,9 @@
1815
1916 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
2017 {
21
- return IS_ENABLED(CONFIG_MMU) ? &arm_dma_ops : &dma_direct_ops;
22
-}
23
-
24
-#ifdef __arch_page_to_dma
25
-#error Please update to __arch_pfn_to_dma
26
-#endif
27
-
28
-/*
29
- * dma_to_pfn/pfn_to_dma/dma_to_virt/virt_to_dma are architecture private
30
- * functions used internally by the DMA-mapping API to provide DMA
31
- * addresses. They must not be used by drivers.
32
- */
33
-#ifndef __arch_pfn_to_dma
34
-static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
35
-{
36
- if (dev)
37
- pfn -= dev->dma_pfn_offset;
38
- return (dma_addr_t)__pfn_to_bus(pfn);
39
-}
40
-
41
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
42
-{
43
- unsigned long pfn = __bus_to_pfn(addr);
44
-
45
- if (dev)
46
- pfn += dev->dma_pfn_offset;
47
-
48
- return pfn;
49
-}
50
-
51
-static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
52
-{
53
- if (dev) {
54
- unsigned long pfn = dma_to_pfn(dev, addr);
55
-
56
- return phys_to_virt(__pfn_to_phys(pfn));
57
- }
58
-
59
- return (void *)__bus_to_virt((unsigned long)addr);
60
-}
61
-
62
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
63
-{
64
- if (dev)
65
- return pfn_to_dma(dev, virt_to_pfn(addr));
66
-
67
- return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
68
-}
69
-
70
-#else
71
-static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
72
-{
73
- return __arch_pfn_to_dma(dev, pfn);
74
-}
75
-
76
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
77
-{
78
- return __arch_dma_to_pfn(dev, addr);
79
-}
80
-
81
-static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
82
-{
83
- return __arch_dma_to_virt(dev, addr);
84
-}
85
-
86
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
87
-{
88
- return __arch_virt_to_dma(dev, addr);
89
-}
90
-#endif
91
-
92
-/* The ARM override for dma_max_pfn() */
93
-static inline unsigned long dma_max_pfn(struct device *dev)
94
-{
95
- return dma_to_pfn(dev, *dev->dma_mask);
96
-}
97
-#define dma_max_pfn(dev) dma_max_pfn(dev)
98
-
99
-#define arch_setup_dma_ops arch_setup_dma_ops
100
-extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
101
- const struct iommu_ops *iommu, bool coherent);
102
-
103
-#define arch_teardown_dma_ops arch_teardown_dma_ops
104
-extern void arch_teardown_dma_ops(struct device *dev);
105
-
106
-/* do not use this function in a driver */
107
-static inline bool is_device_dma_coherent(struct device *dev)
108
-{
109
- return dev->archdata.dma_coherent;
18
+ if (IS_ENABLED(CONFIG_MMU) && !IS_ENABLED(CONFIG_ARM_LPAE))
19
+ return &arm_dma_ops;
20
+ return NULL;
11021 }
11122
11223 /**