Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

asm-generic/io.h: rework split ioread64/iowrite64 helpers

There are two incompatible sets of definitions of these eight functions:
On 64-bit architectures setting CONFIG_HAS_IOPORT, they turn into
either pair of 32-bit PIO (inl/outl) accesses or a single 64-bit MMIO
(readq/writeq). On other 64-bit architectures, they are always split
into 32-bit accesses.

Depending on which header gets included in a driver, there are
additionally definitions for ioread64()/iowrite64() that are
expected to produce a 64-bit register MMIO access on all 64-bit
architectures.

To separate the conflicting definitions, make the version in
include/linux/io-64-nonatomic-*.h visible on all architectures
but pick the one from lib/iomap.c on architectures that set
CONFIG_GENERIC_IOMAP in place of the default fallback.

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+60 -48
+8 -28
include/asm-generic/iomap.h
··· 31 31 extern unsigned int ioread16be(const void __iomem *); 32 32 extern unsigned int ioread32(const void __iomem *); 33 33 extern unsigned int ioread32be(const void __iomem *); 34 - #ifdef CONFIG_64BIT 35 - extern u64 ioread64(const void __iomem *); 36 - extern u64 ioread64be(const void __iomem *); 37 - #endif 38 34 39 - #ifdef readq 40 - #define ioread64_lo_hi ioread64_lo_hi 41 - #define ioread64_hi_lo ioread64_hi_lo 42 - #define ioread64be_lo_hi ioread64be_lo_hi 43 - #define ioread64be_hi_lo ioread64be_hi_lo 44 - extern u64 ioread64_lo_hi(const void __iomem *addr); 45 - extern u64 ioread64_hi_lo(const void __iomem *addr); 46 - extern u64 ioread64be_lo_hi(const void __iomem *addr); 47 - extern u64 ioread64be_hi_lo(const void __iomem *addr); 48 - #endif 35 + extern u64 __ioread64_lo_hi(const void __iomem *addr); 36 + extern u64 __ioread64_hi_lo(const void __iomem *addr); 37 + extern u64 __ioread64be_lo_hi(const void __iomem *addr); 38 + extern u64 __ioread64be_hi_lo(const void __iomem *addr); 49 39 50 40 extern void iowrite8(u8, void __iomem *); 51 41 extern void iowrite16(u16, void __iomem *); 52 42 extern void iowrite16be(u16, void __iomem *); 53 43 extern void iowrite32(u32, void __iomem *); 54 44 extern void iowrite32be(u32, void __iomem *); 55 - #ifdef CONFIG_64BIT 56 - extern void iowrite64(u64, void __iomem *); 57 - extern void iowrite64be(u64, void __iomem *); 58 - #endif 59 45 60 - #ifdef writeq 61 - #define iowrite64_lo_hi iowrite64_lo_hi 62 - #define iowrite64_hi_lo iowrite64_hi_lo 63 - #define iowrite64be_lo_hi iowrite64be_lo_hi 64 - #define iowrite64be_hi_lo iowrite64be_hi_lo 65 - extern void iowrite64_lo_hi(u64 val, void __iomem *addr); 66 - extern void iowrite64_hi_lo(u64 val, void __iomem *addr); 67 - extern void iowrite64be_lo_hi(u64 val, void __iomem *addr); 68 - extern void iowrite64be_hi_lo(u64 val, void __iomem *addr); 69 - #endif 46 + extern void __iowrite64_lo_hi(u64 val, void __iomem *addr); 47 + extern void __iowrite64_hi_lo(u64 val, void __iomem *addr); 48 + extern void __iowrite64be_lo_hi(u64 val, void __iomem *addr); 49 + extern void __iowrite64be_hi_lo(u64 val, void __iomem *addr); 70 50 71 51 /* 72 52 * "string" versions of the above. Note that they
+16
include/linux/io-64-nonatomic-hi-lo.h
··· 101 101 102 102 #ifndef ioread64 103 103 #define ioread64_is_nonatomic 104 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 105 + #define ioread64 __ioread64_hi_lo 106 + #else 104 107 #define ioread64 ioread64_hi_lo 108 + #endif 105 109 #endif 106 110 107 111 #ifndef iowrite64 108 112 #define iowrite64_is_nonatomic 113 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 114 + #define iowrite64 __iowrite64_hi_lo 115 + #else 109 116 #define iowrite64 iowrite64_hi_lo 117 + #endif 110 118 #endif 111 119 112 120 #ifndef ioread64be 113 121 #define ioread64be_is_nonatomic 122 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 123 + #define ioread64be __ioread64be_hi_lo 124 + #else 114 125 #define ioread64be ioread64be_hi_lo 126 + #endif 115 127 #endif 116 128 117 129 #ifndef iowrite64be 118 130 #define iowrite64be_is_nonatomic 131 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 132 + #define iowrite64be __iowrite64be_hi_lo 133 + #else 119 134 #define iowrite64be iowrite64be_hi_lo 135 + #endif 120 136 #endif 121 137 122 138 #endif /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */
+16
include/linux/io-64-nonatomic-lo-hi.h
··· 101 101 102 102 #ifndef ioread64 103 103 #define ioread64_is_nonatomic 104 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 105 + #define ioread64 __ioread64_lo_hi 106 + #else 104 107 #define ioread64 ioread64_lo_hi 108 + #endif 105 109 #endif 106 110 107 111 #ifndef iowrite64 108 112 #define iowrite64_is_nonatomic 113 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 114 + #define iowrite64 __iowrite64_lo_hi 115 + #else 109 116 #define iowrite64 iowrite64_lo_hi 117 + #endif 110 118 #endif 111 119 112 120 #ifndef ioread64be 113 121 #define ioread64be_is_nonatomic 122 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 123 + #define ioread64be __ioread64be_lo_hi 124 + #else 114 125 #define ioread64be ioread64be_lo_hi 126 + #endif 115 127 #endif 116 128 117 129 #ifndef iowrite64be 118 130 #define iowrite64be_is_nonatomic 131 + #if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT) 132 + #define iowrite64be __iowrite64be_lo_hi 133 + #else 119 134 #define iowrite64be iowrite64be_lo_hi 135 + #endif 120 136 #endif 121 137 122 138 #endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */
+20 -20
lib/iomap.c
··· 111 111 EXPORT_SYMBOL(ioread32); 112 112 EXPORT_SYMBOL(ioread32be); 113 113 114 - #ifdef readq 114 + #ifdef CONFIG_64BIT 115 115 static u64 pio_read64_lo_hi(unsigned long port) 116 116 { 117 117 u64 lo, hi; ··· 153 153 } 154 154 155 155 __no_kmsan_checks 156 - u64 ioread64_lo_hi(const void __iomem *addr) 156 + u64 __ioread64_lo_hi(const void __iomem *addr) 157 157 { 158 158 IO_COND(addr, return pio_read64_lo_hi(port), return readq(addr)); 159 159 return 0xffffffffffffffffULL; 160 160 } 161 161 162 162 __no_kmsan_checks 163 - u64 ioread64_hi_lo(const void __iomem *addr) 163 + u64 __ioread64_hi_lo(const void __iomem *addr) 164 164 { 165 165 IO_COND(addr, return pio_read64_hi_lo(port), return readq(addr)); 166 166 return 0xffffffffffffffffULL; 167 167 } 168 168 169 169 __no_kmsan_checks 170 - u64 ioread64be_lo_hi(const void __iomem *addr) 170 + u64 __ioread64be_lo_hi(const void __iomem *addr) 171 171 { 172 172 IO_COND(addr, return pio_read64be_lo_hi(port), 173 173 return mmio_read64be(addr)); ··· 175 175 } 176 176 177 177 __no_kmsan_checks 178 - u64 ioread64be_hi_lo(const void __iomem *addr) 178 + u64 __ioread64be_hi_lo(const void __iomem *addr) 179 179 { 180 180 IO_COND(addr, return pio_read64be_hi_lo(port), 181 181 return mmio_read64be(addr)); 182 182 return 0xffffffffffffffffULL; 183 183 } 184 184 185 - EXPORT_SYMBOL(ioread64_lo_hi); 186 - EXPORT_SYMBOL(ioread64_hi_lo); 187 - EXPORT_SYMBOL(ioread64be_lo_hi); 188 - EXPORT_SYMBOL(ioread64be_hi_lo); 185 + EXPORT_SYMBOL(__ioread64_lo_hi); 186 + EXPORT_SYMBOL(__ioread64_hi_lo); 187 + EXPORT_SYMBOL(__ioread64be_lo_hi); 188 + EXPORT_SYMBOL(__ioread64be_hi_lo); 189 189 190 - #endif /* readq */ 190 + #endif /* CONFIG_64BIT */ 191 191 192 192 #ifndef pio_write16be 193 193 #define pio_write16be(val,port) outw(swab16(val),port) ··· 236 236 EXPORT_SYMBOL(iowrite32); 237 237 EXPORT_SYMBOL(iowrite32be); 238 238 239 - #ifdef writeq 239 + #ifdef CONFIG_64BIT 240 240 static void pio_write64_lo_hi(u64 val, unsigned long port) 241 241 { 242 242 outl(val, port); ··· 261 261 pio_write32be(val, port + sizeof(u32)); 262 262 } 263 263 264 - void iowrite64_lo_hi(u64 val, void __iomem *addr) 264 + void __iowrite64_lo_hi(u64 val, void __iomem *addr) 265 265 { 266 266 /* Make sure uninitialized memory isn't copied to devices. */ 267 267 kmsan_check_memory(&val, sizeof(val)); ··· 269 269 writeq(val, addr)); 270 270 } 271 271 272 - void iowrite64_hi_lo(u64 val, void __iomem *addr) 272 + void __iowrite64_hi_lo(u64 val, void __iomem *addr) 273 273 { 274 274 /* Make sure uninitialized memory isn't copied to devices. */ 275 275 kmsan_check_memory(&val, sizeof(val)); ··· 277 277 writeq(val, addr)); 278 278 } 279 279 280 - void iowrite64be_lo_hi(u64 val, void __iomem *addr) 280 + void __iowrite64be_lo_hi(u64 val, void __iomem *addr) 281 281 { 282 282 /* Make sure uninitialized memory isn't copied to devices. */ 283 283 kmsan_check_memory(&val, sizeof(val)); ··· 285 285 mmio_write64be(val, addr)); 286 286 } 287 287 288 - void iowrite64be_hi_lo(u64 val, void __iomem *addr) 288 + void __iowrite64be_hi_lo(u64 val, void __iomem *addr) 289 289 { 290 290 /* Make sure uninitialized memory isn't copied to devices. */ 291 291 kmsan_check_memory(&val, sizeof(val)); ··· 293 293 mmio_write64be(val, addr)); 294 294 } 295 295 296 - EXPORT_SYMBOL(iowrite64_lo_hi); 297 - EXPORT_SYMBOL(iowrite64_hi_lo); 298 - EXPORT_SYMBOL(iowrite64be_lo_hi); 299 - EXPORT_SYMBOL(iowrite64be_hi_lo); 296 + EXPORT_SYMBOL(__iowrite64_lo_hi); 297 + EXPORT_SYMBOL(__iowrite64_hi_lo); 298 + EXPORT_SYMBOL(__iowrite64be_lo_hi); 299 + EXPORT_SYMBOL(__iowrite64be_hi_lo); 300 300 301 - #endif /* readq */ 301 + #endif /* CONFIG_64BIT */ 302 302 303 303 /* 304 304 * These are the "repeat MMIO read/write" functions.