Skip to content

Commit 3a90a72

Browse files
committed
Merge tag 'asm-generic-6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
Pull asm-generic updates from Arnd Bergmann: "This is mainly set of cleanups of asm-generic/io.h, resolving problems with inconsistent semantics of ioread64/iowrite64 that were causing runtime and build issues. The "GENERIC_IOMAP" version that switches between inb()/outb() and readb()/writeb() style accessors is now only used on architectures that have PC-style ISA devices that are not memory mapped (x86, uml, m68k-q40 and powerpc-powernv), while alpha and parisc use a more complicated variant and everything else just maps the ioread interfaces to plan MMIO (readb/writeb etc). In addition there are two small changes from Raag Jadav to simplify the asm-generic/io.h indirect inclusions and from Jann Horn to fix a corner case with read_word_at_a_time" * tag 'asm-generic-6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: rwonce: fix crash by removing READ_ONCE() for unaligned read rwonce: handle KCSAN like KASAN in read_word_at_a_time() m68k: coldfire: select PCI_IOMAP for PCI mips: export pci_iounmap() mips: fix PCI_IOBASE definition m68k/nommu: stop using GENERIC_IOMAP mips: drop GENERIC_IOMAP wrapper powerpc: asm/io.h: remove split ioread64/iowrite64 helpers parisc: stop using asm-generic/iomap.h sh: remove duplicate ioread/iowrite helpers alpha: stop using asm-generic/iomap.h io.h: drop unused headers drm/draw: include missing headers asm-generic/io.h: rework split ioread64/iowrite64 helpers
2 parents 3536cb1 + 47a6039 commit 3a90a72

File tree

24 files changed

+167
-355
lines changed

24 files changed

+167
-355
lines changed

arch/alpha/include/asm/io.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include <asm/machvec.h>
1111
#include <asm/hwrpb.h>
1212

13-
/* The generic header contains only prototypes. Including it ensures that
14-
the implementation we have here matches that interface. */
15-
#include <asm-generic/iomap.h>
16-
1713
/*
1814
* Virtual -> physical identity mapping starts at this offset
1915
*/
@@ -276,13 +272,24 @@ extern void __raw_writeq(u64 b, volatile void __iomem *addr);
276272
#define __raw_writel __raw_writel
277273
#define __raw_writeq __raw_writeq
278274

279-
/*
280-
* Mapping from port numbers to __iomem space is pretty easy.
281-
*/
275+
extern unsigned int ioread8(const void __iomem *);
276+
extern unsigned int ioread16(const void __iomem *);
277+
extern unsigned int ioread32(const void __iomem *);
278+
extern u64 ioread64(const void __iomem *);
279+
280+
extern void iowrite8(u8, void __iomem *);
281+
extern void iowrite16(u16, void __iomem *);
282+
extern void iowrite32(u32, void __iomem *);
283+
extern void iowrite64(u64, void __iomem *);
284+
285+
extern void ioread8_rep(const void __iomem *port, void *buf, unsigned long count);
286+
extern void ioread16_rep(const void __iomem *port, void *buf, unsigned long count);
287+
extern void ioread32_rep(const void __iomem *port, void *buf, unsigned long count);
288+
289+
extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
290+
extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
291+
extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
282292

283-
/* These two have to be extern inline because of the extern prototype from
284-
<asm-generic/iomap.h>. It is not legal to mix "extern" and "static" for
285-
the same declaration. */
286293
extern inline void __iomem *ioport_map(unsigned long port, unsigned int size)
287294
{
288295
return IO_CONCAT(__IO_PREFIX,ioportmap) (port);
@@ -629,10 +636,6 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
629636
#define RTC_PORT(x) (0x70 + (x))
630637
#define RTC_ALWAYS_BCD 0
631638

632-
/*
633-
* These get provided from <asm-generic/iomap.h> since alpha does not
634-
* select GENERIC_IOMAP.
635-
*/
636639
#define ioread64 ioread64
637640
#define iowrite64 iowrite64
638641
#define ioread8_rep ioread8_rep

arch/m68k/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ config M68K
1818
select DMA_DIRECT_REMAP if M68K_NONCOHERENT_DMA && !COLDFIRE
1919
select GENERIC_ATOMIC64
2020
select GENERIC_CPU_DEVICES
21-
select GENERIC_IOMAP if HAS_IOPORT
21+
select GENERIC_IOMAP if HAS_IOPORT && MMU && !COLDFIRE
2222
select GENERIC_IRQ_SHOW
2323
select GENERIC_LIB_ASHLDI3
2424
select GENERIC_LIB_ASHRDI3
2525
select GENERIC_LIB_LSHRDI3
2626
select GENERIC_LIB_MULDI3
27+
select GENERIC_PCI_IOMAP if PCI
2728
select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
2829
select HAVE_ARCH_LIBGCC_H
2930
select HAVE_ARCH_SECCOMP

arch/m68k/include/asm/io_no.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ static inline void writel(u32 value, volatile void __iomem *addr)
123123
#define PCI_IO_SIZE 0x00010000 /* 64k */
124124
#define PCI_IO_MASK (PCI_IO_SIZE - 1)
125125

126-
#define HAVE_ARCH_PIO_SIZE
127-
#define PIO_OFFSET 0
128-
#define PIO_MASK 0xffff
129-
#define PIO_RESERVED 0x10000
130126
#define PCI_IOBASE ((void __iomem *) PCI_IO_PA)
131127
#define PCI_SPACE_LIMIT PCI_IO_MASK
132128
#endif /* CONFIG_PCI */

arch/mips/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ config MIPS
3838
select GENERIC_CMOS_UPDATE
3939
select GENERIC_CPU_AUTOPROBE
4040
select GENERIC_GETTIMEOFDAY
41-
select GENERIC_IOMAP
4241
select GENERIC_IRQ_PROBE
4342
select GENERIC_IRQ_SHOW
4443
select GENERIC_ISA_DMA if EISA
@@ -47,6 +46,7 @@ config MIPS
4746
select GENERIC_LIB_CMPDI2
4847
select GENERIC_LIB_LSHRDI3
4948
select GENERIC_LIB_UCMPDI2
49+
select GENERIC_PCI_IOMAP
5050
select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC
5151
select GENERIC_SMP_IDLE_THREAD
5252
select GENERIC_IDLE_POLL_SETUP

arch/mips/include/asm/io.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,6 @@ static inline void set_io_port_base(unsigned long base)
6666
mips_io_port_base = base;
6767
}
6868

69-
/*
70-
* Provide the necessary definitions for generic iomap. We make use of
71-
* mips_io_port_base for iomap(), but we don't reserve any low addresses for
72-
* use with I/O ports.
73-
*/
74-
75-
#define HAVE_ARCH_PIO_SIZE
76-
#define PIO_OFFSET mips_io_port_base
77-
#define PIO_MASK IO_SPACE_LIMIT
78-
#define PIO_RESERVED 0x0UL
79-
8069
/*
8170
* Enforce in-order execution of data I/O. In the MIPS architecture
8271
* these are equivalent to corresponding platform-specific memory
@@ -397,8 +386,8 @@ static inline void writes##bwlq(volatile void __iomem *mem, \
397386
} \
398387
} \
399388
\
400-
static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \
401-
unsigned int count) \
389+
static inline void reads##bwlq(const volatile void __iomem *mem, \
390+
void *addr, unsigned int count) \
402391
{ \
403392
volatile type *__addr = addr; \
404393
\
@@ -555,6 +544,16 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
555544

556545
void __ioread64_copy(void *to, const void __iomem *from, size_t count);
557546

547+
#if defined(CONFIG_PCI) && defined(CONFIG_PCI_DRIVERS_LEGACY)
548+
struct pci_dev;
549+
void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
550+
#define pci_iounmap pci_iounmap
551+
#endif
552+
553+
#ifndef PCI_IOBASE
554+
#define PCI_IOBASE ((void __iomem *)mips_io_port_base)
555+
#endif
556+
558557
#include <asm-generic/io.h>
559558

560559
static inline void *isa_bus_to_virt(unsigned long address)

arch/mips/include/asm/mach-loongson64/spaces.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#endif /* CONFIG_64BIT */
88

99
/* Skip 128k to trap NULL pointer dereferences */
10-
#define PCI_IOBASE _AC(0xc000000000000000 + SZ_128K, UL)
10+
#define PCI_PORT_BASE _AC(0xc000000000000000 + SZ_128K, UL)
11+
#define PCI_IOBASE (void __iomem *)PCI_PORT_BASE
1112
#define PCI_IOSIZE SZ_16M
12-
#define MAP_BASE (PCI_IOBASE + PCI_IOSIZE)
13+
#define MAP_BASE (PCI_PORT_BASE + PCI_IOSIZE)
1314

1415
#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
1516

arch/mips/include/asm/mach-ralink/spaces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef __ASM_MACH_RALINK_SPACES_H_
33
#define __ASM_MACH_RALINK_SPACES_H_
44

5-
#define PCI_IOBASE mips_io_port_base
5+
#define PCI_IOBASE (void __iomem *)mips_io_port_base
66
#define PCI_IOSIZE SZ_64K
77
#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
88

arch/mips/lib/iomap-pci.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
4343
return (void __iomem *) (ctrl->io_map_base + port);
4444
}
4545

46+
void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
47+
{
48+
struct pci_controller *ctrl = dev->bus->sysdata;
49+
void __iomem *base = (void __iomem *)ctrl->io_map_base;
50+
51+
if (addr < base || addr > (base + resource_size(ctrl->io_resource)))
52+
iounmap(addr);
53+
}
54+
EXPORT_SYMBOL(pci_iounmap);
55+
4656
#endif /* CONFIG_PCI_DRIVERS_LEGACY */

arch/mips/loongson64/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void __init prom_init(void)
128128
}
129129

130130
/* init base address of io space */
131-
set_io_port_base(PCI_IOBASE);
131+
set_io_port_base((unsigned long)PCI_IOBASE);
132132

133133
if (loongson_sysconf.early_config)
134134
loongson_sysconf.early_config();
@@ -178,7 +178,7 @@ static int __init add_legacy_isa_io(struct fwnode_handle *fwnode, resource_size_
178178
return -EINVAL;
179179
}
180180

181-
vaddr = PCI_IOBASE + range->io_start;
181+
vaddr = (unsigned long)PCI_IOBASE + range->io_start;
182182

183183
vmap_page_range(vaddr, vaddr + size, hw_start, pgprot_device(PAGE_KERNEL));
184184

arch/parisc/include/asm/io.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,36 +227,54 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
227227
#define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))
228228

229229
#ifdef CONFIG_64BIT
230-
#define ioread64 ioread64
231-
#define ioread64be ioread64be
232-
#define iowrite64 iowrite64
233-
#define iowrite64be iowrite64be
234230
extern u64 ioread64(const void __iomem *addr);
235231
extern u64 ioread64be(const void __iomem *addr);
232+
#define ioread64 ioread64
233+
#define ioread64be ioread64be
234+
236235
extern void iowrite64(u64 val, void __iomem *addr);
237236
extern void iowrite64be(u64 val, void __iomem *addr);
237+
#define iowrite64 iowrite64
238+
#define iowrite64be iowrite64be
238239
#endif
239240

240-
#include <asm-generic/iomap.h>
241-
/*
242-
* These get provided from <asm-generic/iomap.h> since parisc does not
243-
* select GENERIC_IOMAP.
244-
*/
241+
extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
242+
extern void ioport_unmap(void __iomem *);
245243
#define ioport_map ioport_map
246244
#define ioport_unmap ioport_unmap
245+
246+
extern unsigned int ioread8(const void __iomem *);
247+
extern unsigned int ioread16(const void __iomem *);
248+
extern unsigned int ioread16be(const void __iomem *);
249+
extern unsigned int ioread32(const void __iomem *);
250+
extern unsigned int ioread32be(const void __iomem *);
247251
#define ioread8 ioread8
248252
#define ioread16 ioread16
249253
#define ioread32 ioread32
250254
#define ioread16be ioread16be
251255
#define ioread32be ioread32be
256+
257+
extern void iowrite8(u8, void __iomem *);
258+
extern void iowrite16(u16, void __iomem *);
259+
extern void iowrite16be(u16, void __iomem *);
260+
extern void iowrite32(u32, void __iomem *);
261+
extern void iowrite32be(u32, void __iomem *);
252262
#define iowrite8 iowrite8
253263
#define iowrite16 iowrite16
254264
#define iowrite32 iowrite32
255265
#define iowrite16be iowrite16be
256266
#define iowrite32be iowrite32be
267+
268+
extern void ioread8_rep(const void __iomem *port, void *buf, unsigned long count);
269+
extern void ioread16_rep(const void __iomem *port, void *buf, unsigned long count);
270+
extern void ioread32_rep(const void __iomem *port, void *buf, unsigned long count);
257271
#define ioread8_rep ioread8_rep
258272
#define ioread16_rep ioread16_rep
259273
#define ioread32_rep ioread32_rep
274+
275+
extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
276+
extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
277+
extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
260278
#define iowrite8_rep iowrite8_rep
261279
#define iowrite16_rep iowrite16_rep
262280
#define iowrite32_rep iowrite32_rep

0 commit comments

Comments
 (0)