Skip to contentSkip to conversation

arch/*/io.h: remove ioremap_uc in some architectures

RFC PATCH Superseded Baoquan He 2 participants 5 messages Feb 21, 2023

Subsystems (9)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Baoquan He

author
#0 lore raw

cover arch/*/io.h: remove ioremap_uc in some architectures

In a patchset reviewing, Arnd suggested removing arch specific ioremap_uc() and using default one defined in asm-generic/io.h instead, other than x86 and ia64. Please see below link for more details:

https://lore.kernel.org/all/[email protected]/T/#u

And Arnd also provided an old link where people earlier discussed this.

https://lore.kernel.org/all/[email protected]/

So in this patchset, I firstly add including asm-generic/io.h for mips, then remove all arch specific ioremap_uc() definitions, except of x86 ans ia64. With the removing, those ARCH-es will have default ioremap_uc() defined in asm-generic/io.h.

Baoquan He (2):
mips: add <asm-generic/io.h> including arch/*/io.h: remove ioremap_uc in some architectures

 arch/alpha/include/asm/io.h    |  1 -
 arch/hexagon/include/asm/io.h  |  3 ---
 arch/m68k/include/asm/kmap.h   |  1 -
 arch/mips/include/asm/io.h     | 47 +++++++++++++++++++++++++++++++++-
 arch/mips/include/asm/mmiowb.h |  2 --
 arch/parisc/include/asm/io.h   |  2 --
 arch/powerpc/include/asm/io.h  |  1 -
 arch/sh/include/asm/io.h       |  2 --
 arch/sparc/include/asm/io_64.h |  1 -
 9 files changed, 46 insertions(+), 14 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

RFC PATCH 1/2 mips: add <asm-generic/io.h> including

With the adding, some default ioremap_xx methods defined in asm-generic/io.h can be used. E.g the default ioremap_uc() returning NULL.

Cc Thomas Bogendoerfer <[email protected]>
Cc Huacai Chen <[email protected]>
Cc Jiaxun Yang <[email protected]>
---
 arch/mips/include/asm/io.h     | 46 ++++++++++++++++++++++++++++++++++
 arch/mips/include/asm/mmiowb.h |  2 --
 2 files changed, 46 insertions(+), 2 deletions(-)
arch/mips/include/asm/io.h +46 -0
index e6d5ccaa309e..c89804a5802a 100644
@@ -129,6 +129,7 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
  *     almost all conceivable cases a device driver should not be using
  *     this function
  */
+#define phys_to_virt phys_to_virt
 static inline void * phys_to_virt(unsigned long address)
 {
 	return __va(address);
@@ -481,14 +482,17 @@ BUILDSTRING(l, u32)
 BUILDSTRING(q, u64)
 #endif
 
+#define memset_io memset_io
 static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
 {
 	memset((void __force *) addr, val, count);
 }
+#define memcpy_fromio memcpy_fromio
 static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
 {
 	memcpy(dst, (void __force *) src, count);
 }
+#define memcpy_toio memcpy_toio
 static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
 {
 	memcpy((void __force *) dst, src, count);
@@ -549,6 +553,46 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
 #define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
 #define csr_in32(a)    (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
 
+
+#define inb_p inb_p
+#define inw_p inw_p
+#define inl_p inl_p
+#define insb insb
+#define insw insw
+#define insl insl
+
+#define outb_p outb_p
+#define outw_p outw_p
+#define outl_p outl_p
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+
+#define readb readb
+#define readw readw
+#define readl readl
+#define writeb writeb
+#define writew writew
+#define writel writel
+
+#define readsb readsb
+#define readsw readsw
+#define readsl readsl
+#define readsq readsq
+#define writesb writesb
+#define writesw writesw
+#define writesl writesl
+#define writesq writesq
+
+#define __raw_readb __raw_readb
+#define __raw_readw __raw_readw
+#define __raw_readl __raw_readl
+#define __raw_readq __raw_readq
+#define __raw_writeb __raw_writeb
+#define __raw_writew __raw_writew
+#define __raw_writel __raw_writel
+#define __raw_writeq __raw_writeq
+
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
@@ -557,4 +601,6 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
 
 void __ioread64_copy(void *to, const void __iomem *from, size_t count);
 
+#include <asm-generic/io.h>
+
 #endif /* _ASM_IO_H */
arch/mips/include/asm/mmiowb.h +0 -2
index a40824e3ef8e..007fe55bc7d1 100644
@@ -2,8 +2,6 @@
 #ifndef _ASM_MMIOWB_H
 #define _ASM_MMIOWB_H
 
-#include <asm/io.h>
-
 #define mmiowb()	iobarrier_w()
 
 #include <asm-generic/mmiowb.h>
Signature · 1 line
2.34.1
author
#2 lore raw

RFC PATCH 2/2 arch/*/io.h: remove ioremap_uc in some architectures

In reply to Baoquan He

ioremap_uc() is only meaningful on old x86-32 systems with the PAT extension, and on ia64 with its slightly unconventional ioremap() behavior, everywhere else this is the same as ioremap() anyway.

So here, remove the ioremap_uc() definition in architecutures other than x86 and ia64. These architectures all have asm-generic/io.h included and will have the default ioremap_uc() definition which returns NULL. If any ARCH really needs a specific ioremap_uc() for its own usage, one ioremap_uc() can be added in the ARH.

---
 arch/alpha/include/asm/io.h    | 1 -
 arch/hexagon/include/asm/io.h  | 3 ---
 arch/m68k/include/asm/kmap.h   | 1 -
 arch/mips/include/asm/io.h     | 1 -
 arch/parisc/include/asm/io.h   | 2 --
 arch/powerpc/include/asm/io.h  | 1 -
 arch/sh/include/asm/io.h       | 2 --
 arch/sparc/include/asm/io_64.h | 1 -
 8 files changed, 12 deletions(-)
arch/alpha/include/asm/io.h +0 -1
index 1c3605d874e9..0d519f96a20e 100644
@@ -312,7 +312,6 @@ static inline void __iomem *ioremap(unsigned long port, unsigned long size)
 }
 
 #define ioremap_wc ioremap
-#define ioremap_uc ioremap
 
 static inline void iounmap(volatile void __iomem *addr)
 {
arch/hexagon/include/asm/io.h +0 -3
index dcd9cbbf5934..b9847472f25c 100644
@@ -176,9 +176,6 @@ static inline void writel(u32 data, volatile void __iomem *addr)
 #define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
 		       (__HEXAGON_C_DEV << 6))
 
-#define ioremap_uc(addr, size) ioremap((addr), (size))
-
-
 #define __raw_writel writel
 
 static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
arch/m68k/include/asm/kmap.h +0 -1
index dec05743d426..d3c9934b9475 100644
@@ -27,7 +27,6 @@ static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
 }
 
-#define ioremap_uc ioremap
 #define ioremap_wt ioremap_wt
 static inline void __iomem *ioremap_wt(unsigned long physaddr,
 				       unsigned long size)
arch/mips/include/asm/io.h +0 -1
index c89804a5802a..aa6c55d6cb6c 100644
@@ -170,7 +170,6 @@ void iounmap(const volatile void __iomem *addr);
  */
 #define ioremap(offset, size)						\
 	ioremap_prot((offset), (size), _CACHE_UNCACHED)
-#define ioremap_uc		ioremap
 
 /*
  * ioremap_cache -	map bus memory into CPU space
arch/parisc/include/asm/io.h +0 -2
index 4c386b0cee08..8aaa79017131 100644
@@ -134,8 +134,6 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)
 
 #define ioremap_wc(addr, size)  \
 	ioremap_prot((addr), (size), _PAGE_IOREMAP)
-#define ioremap_uc(addr, size)  \
-	ioremap_prot((addr), (size), _PAGE_IOREMAP)
 
 #define pci_iounmap			pci_iounmap
 
arch/powerpc/include/asm/io.h +0 -1
index 127d8300b40b..cfbb6df9f55f 100644
@@ -870,7 +870,6 @@ void __iomem *ioremap_wt(phys_addr_t address, unsigned long size);
 #endif
 
 void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size);
-#define ioremap_uc(addr, size)		ioremap((addr), (size))
 #define ioremap_cache(addr, size) \
 	ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL))
 
arch/sh/include/asm/io.h +0 -2
index b3a26b405c8d..12a892804082 100644
@@ -278,8 +278,6 @@ unsigned long long poke_real_address_q(unsigned long long addr,
 	ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL))
 #endif /* CONFIG_MMU */
 
-#define ioremap_uc	ioremap
-
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
arch/sparc/include/asm/io_64.h +0 -1
index 9303270b22f3..d8ee1442f303 100644
@@ -423,7 +423,6 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
 	return (void __iomem *)offset;
 }
 
-#define ioremap_uc(X,Y)			ioremap((X),(Y))
 #define ioremap_wc(X,Y)			ioremap((X),(Y))
 #define ioremap_wt(X,Y)			ioremap((X),(Y))
 static inline void __iomem *ioremap_np(unsigned long offset, unsigned long size)
Signature · 1 line
2.34.1
maintainer Acked-by on v1 2/2
#3 lore raw

Hi Baoquan,

Thanks for your patch!

Quoted 8 lines · Baoquan He

ioremap_uc() is only meaningful on old x86-32 systems with the PAT extension, and on ia64 with its slightly unconventional ioremap() behavior, everywhere else this is the same as ioremap() anyway.

So here, remove the ioremap_uc() definition in architecutures other than x86 and ia64. These architectures all have asm-generic/io.h included and will have the default ioremap_uc() definition which returns NULL. If any ARCH really needs a specific ioremap_uc() for

Please make it very clear that this changes existing behavior. At first, I had completely missed that.

And of course the documentation should be updated to reflect that.

Quoted 1 line

its own usage, one ioremap_uc() can be added in the ARH.

s/ARH/ARCH/

Quoted 1 line
 arch/m68k/include/asm/kmap.h   | 1 -

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author
#4 lore raw
Quoted 9 lines · Geert Uytterhoeven

Hi Baoquan,

Thanks for your patch!

Quoted 4 lines · Baoquan He

ioremap_uc() is only meaningful on old x86-32 systems with the PAT extension, and on ia64 with its slightly unconventional ioremap() behavior, everywhere else this is the same as ioremap() anyway.

Quoted 7 lines
Quoted 4 lines

So here, remove the ioremap_uc() definition in architecutures other than x86 and ia64. These architectures all have asm-generic/io.h included and will have the default ioremap_uc() definition which returns NULL. If any ARCH really needs a specific ioremap_uc() for

Please make it very clear that this changes existing behavior. At first, I had completely missed that.

Sure, I will update log.

Quoted 2 lines

And of course the documentation should be updated to reflect that.

Makes sense, will do.

Quoted 4 lines
Quoted 2 lines

its own usage, one ioremap_uc() can be added in the ARH.

s/ARH/ARCH/

Will update.

Quoted 4 lines
Quoted 2 lines
 arch/m68k/include/asm/kmap.h   | 1 -

Thanks for reviewing.