hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/linux/io-mapping.h
....@@ -1,18 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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.
164 */
175
186 #ifndef _LINUX_IO_MAPPING_H
....@@ -22,13 +10,14 @@
2210 #include <linux/slab.h>
2311 #include <linux/bug.h>
2412 #include <linux/io.h>
13
+#include <linux/pgtable.h>
2514 #include <asm/page.h>
2615
2716 /*
2817 * The io_mapping mechanism provides an abstraction for mapping
2918 * individual pages from an io device to the CPU in an efficient fashion.
3019 *
31
- * See Documentation/io-mapping.txt
20
+ * See Documentation/driver-api/io-mapping.rst
3221 */
3322
3423 struct io_mapping {
....@@ -40,6 +29,7 @@
4029
4130 #ifdef CONFIG_HAVE_ATOMIC_IOMAP
4231
32
+#include <linux/pfn.h>
4333 #include <asm/iomap.h>
4434 /*
4535 * For small address space machines, mapping large objects
....@@ -70,24 +60,20 @@
7060 iomap_free(mapping->base, mapping->size);
7161 }
7262
73
-/* Atomic map/unmap */
63
+/* Temporary mappings which are only valid in the current context */
7464 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)
7766 {
7867 resource_size_t phys_addr;
79
- unsigned long pfn;
8068
8169 BUG_ON(offset >= mapping->size);
8270 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);
8572 }
8673
87
-static inline void
88
-io_mapping_unmap_atomic(void __iomem *vaddr)
74
+static inline void io_mapping_unmap_local(void __iomem *vaddr)
8975 {
90
- iounmap_atomic(vaddr);
76
+ kunmap_local_indexed((void __force *)vaddr);
9177 }
9278
9379 static inline void __iomem *
....@@ -109,10 +95,9 @@
10995 iounmap(vaddr);
11096 }
11197
112
-#else
98
+#else /* HAVE_ATOMIC_IOMAP */
11399
114100 #include <linux/uaccess.h>
115
-#include <asm/pgtable.h>
116101
117102 /* Create the io_mapping object*/
118103 static inline struct io_mapping *
....@@ -157,25 +142,19 @@
157142 {
158143 }
159144
160
-/* Atomic map/unmap */
145
+/* Temporary mappings which are only valid in the current context */
161146 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)
164148 {
165
- preempt_disable();
166
- pagefault_disable();
167149 return io_mapping_map_wc(mapping, offset, PAGE_SIZE);
168150 }
169151
170
-static inline void
171
-io_mapping_unmap_atomic(void __iomem *vaddr)
152
+static inline void io_mapping_unmap_local(void __iomem *vaddr)
172153 {
173154 io_mapping_unmap(vaddr);
174
- pagefault_enable();
175
- preempt_enable();
176155 }
177156
178
-#endif /* HAVE_ATOMIC_IOMAP */
157
+#endif /* !HAVE_ATOMIC_IOMAP */
179158
180159 static inline struct io_mapping *
181160 io_mapping_create_wc(resource_size_t base,