.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright © 2008 Keith Packard <keithp@keithp.com> |
---|
3 | | - * |
---|
4 | | - * This file is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of version 2 of the GNU General Public License |
---|
6 | | - * as published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License |
---|
14 | | - * along with this program; if not, write to the Free Software Foundation, |
---|
15 | | - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
16 | 4 | */ |
---|
17 | 5 | |
---|
18 | 6 | #ifndef _LINUX_IO_MAPPING_H |
---|
.. | .. |
---|
22 | 10 | #include <linux/slab.h> |
---|
23 | 11 | #include <linux/bug.h> |
---|
24 | 12 | #include <linux/io.h> |
---|
| 13 | +#include <linux/pgtable.h> |
---|
25 | 14 | #include <asm/page.h> |
---|
26 | 15 | |
---|
27 | 16 | /* |
---|
28 | 17 | * The io_mapping mechanism provides an abstraction for mapping |
---|
29 | 18 | * individual pages from an io device to the CPU in an efficient fashion. |
---|
30 | 19 | * |
---|
31 | | - * See Documentation/io-mapping.txt |
---|
| 20 | + * See Documentation/driver-api/io-mapping.rst |
---|
32 | 21 | */ |
---|
33 | 22 | |
---|
34 | 23 | struct io_mapping { |
---|
.. | .. |
---|
40 | 29 | |
---|
41 | 30 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP |
---|
42 | 31 | |
---|
| 32 | +#include <linux/pfn.h> |
---|
43 | 33 | #include <asm/iomap.h> |
---|
44 | 34 | /* |
---|
45 | 35 | * For small address space machines, mapping large objects |
---|
.. | .. |
---|
70 | 60 | iomap_free(mapping->base, mapping->size); |
---|
71 | 61 | } |
---|
72 | 62 | |
---|
73 | | -/* Atomic map/unmap */ |
---|
| 63 | +/* Temporary mappings which are only valid in the current context */ |
---|
74 | 64 | static inline void __iomem * |
---|
75 | | -io_mapping_map_atomic_wc(struct io_mapping *mapping, |
---|
76 | | - unsigned long offset) |
---|
| 65 | +io_mapping_map_local_wc(struct io_mapping *mapping, unsigned long offset) |
---|
77 | 66 | { |
---|
78 | 67 | resource_size_t phys_addr; |
---|
79 | | - unsigned long pfn; |
---|
80 | 68 | |
---|
81 | 69 | BUG_ON(offset >= mapping->size); |
---|
82 | 70 | phys_addr = mapping->base + offset; |
---|
83 | | - pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); |
---|
84 | | - return iomap_atomic_prot_pfn(pfn, mapping->prot); |
---|
| 71 | + return __iomap_local_pfn_prot(PHYS_PFN(phys_addr), mapping->prot); |
---|
85 | 72 | } |
---|
86 | 73 | |
---|
87 | | -static inline void |
---|
88 | | -io_mapping_unmap_atomic(void __iomem *vaddr) |
---|
| 74 | +static inline void io_mapping_unmap_local(void __iomem *vaddr) |
---|
89 | 75 | { |
---|
90 | | - iounmap_atomic(vaddr); |
---|
| 76 | + kunmap_local_indexed((void __force *)vaddr); |
---|
91 | 77 | } |
---|
92 | 78 | |
---|
93 | 79 | static inline void __iomem * |
---|
.. | .. |
---|
109 | 95 | iounmap(vaddr); |
---|
110 | 96 | } |
---|
111 | 97 | |
---|
112 | | -#else |
---|
| 98 | +#else /* HAVE_ATOMIC_IOMAP */ |
---|
113 | 99 | |
---|
114 | 100 | #include <linux/uaccess.h> |
---|
115 | | -#include <asm/pgtable.h> |
---|
116 | 101 | |
---|
117 | 102 | /* Create the io_mapping object*/ |
---|
118 | 103 | static inline struct io_mapping * |
---|
.. | .. |
---|
157 | 142 | { |
---|
158 | 143 | } |
---|
159 | 144 | |
---|
160 | | -/* Atomic map/unmap */ |
---|
| 145 | +/* Temporary mappings which are only valid in the current context */ |
---|
161 | 146 | static inline void __iomem * |
---|
162 | | -io_mapping_map_atomic_wc(struct io_mapping *mapping, |
---|
163 | | - unsigned long offset) |
---|
| 147 | +io_mapping_map_local_wc(struct io_mapping *mapping, unsigned long offset) |
---|
164 | 148 | { |
---|
165 | | - preempt_disable(); |
---|
166 | | - pagefault_disable(); |
---|
167 | 149 | return io_mapping_map_wc(mapping, offset, PAGE_SIZE); |
---|
168 | 150 | } |
---|
169 | 151 | |
---|
170 | | -static inline void |
---|
171 | | -io_mapping_unmap_atomic(void __iomem *vaddr) |
---|
| 152 | +static inline void io_mapping_unmap_local(void __iomem *vaddr) |
---|
172 | 153 | { |
---|
173 | 154 | io_mapping_unmap(vaddr); |
---|
174 | | - pagefault_enable(); |
---|
175 | | - preempt_enable(); |
---|
176 | 155 | } |
---|
177 | 156 | |
---|
178 | | -#endif /* HAVE_ATOMIC_IOMAP */ |
---|
| 157 | +#endif /* !HAVE_ATOMIC_IOMAP */ |
---|
179 | 158 | |
---|
180 | 159 | static inline struct io_mapping * |
---|
181 | 160 | io_mapping_create_wc(resource_size_t base, |
---|