Re: [PATCH v4 12/16] parisc: mm: Convert to GENERIC_IOREMAP

From: Baoquan He
Date: Wed Feb 22 2023 - 03:36:35 EST


Hi Christophe, Arnd,

On 02/17/23 at 01:46pm, Christophe Leroy wrote:
>
>
> Le 17/02/2023 à 14:31, Baoquan He a écrit :
> > On 02/16/23 at 04:18pm, Arnd Bergmann wrote:
> >> On Thu, Feb 16, 2023, at 16:02, Baoquan He wrote:
> >>> On 02/16/23 at 01:50pm, Matthew Wilcox wrote:
> >>> It's not if including asm-generic/iomap.h. The ARCH_HAS_IOREMAP_xx is to
> >>> avoid redefinition there.
> >>>
> >>> include/asm-generic/iomap.h:
> >>> ----
> >>> #ifndef ARCH_HAS_IOREMAP_WC
> >>> #define ioremap_wc ioremap
> >>> #endif
> >>
> >> I'd change that to the usual '#ifndef ioremap_wc' in that case.
> >
> > Not sure if I got you. Kill all ARCH_HAS_IOREMAP_xxx in kernel? If yes,
> > sounds like a good idea.
> >
>
> At least kill that one at the first place in your series, and then the
> other ones in a follow-up series maybe.

I made a patch to remove all ARCH_HAS_IOREMAP_xx macros in architectures
and the ifdeffery of ARCH_HAS_IOREMAP_xx in asm-generic/iomap.h.
But the change will cause building error as below. Becuase we usually
have '#include <asm-generic/iomap.h>' at the beginning of
arch/xx/include/asm/io.h, and have '#include <asm-generic/io.h>' at the
end of arch/xx/include/asm/io.h. For architecutres which has
ARCH_HAS_IOREMAP_xx defining, we need move ''#include <asm-generic/iomap.h>
dowe to below '#include <asm-generic/io.h>'. Please help check if it's
still worth doing.


***move '#include <asm-generic/iomap.h>' below '#include <asm-generic/io.h>'
***
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 8ab68cde1f13..a8d55fc62959 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -209,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t);
#define memcpy_toio memcpy_toio
#define memset_io memset_io

-#include <asm-generic/iomap.h>
-
/*
* ISA space is 'always mapped' on a typical x86 system, no need to
* explicitly ioremap() it. The fact that the ISA IO space is mapped
@@ -329,6 +327,8 @@ extern bool is_early_ioremap_ptep(pte_t *ptep);
#include <asm-generic/io.h>
#undef PCI_IOBASE

+#include <asm-generic/iomap.h>
+
#ifdef CONFIG_MTRR
extern int __must_check arch_phys_wc_index(int handle);
#define arch_phys_wc_index arch_phys_wc_index


***Building error after removing ARCH_HAS_IOREMAP_xx
***
In file included from ./include/linux/io.h:13,
from ./include/linux/irq.h:20,
from ./include/xen/events.h:6,
from arch/x86/entry/common.c:25:
./arch/x86/include/asm/io.h:321: warning: "ioremap_wc" redefined
321 | #define ioremap_wc ioremap_wc
|
In file included from ./arch/x86/include/asm/io.h:212:
./include/asm-generic/iomap.h:97: note: this is the location of the previous definition
97 | #define ioremap_wc ioremap
|
./arch/x86/include/asm/io.h:323: warning: "ioremap_wt" redefined
323 | #define ioremap_wt ioremap_wt
|
./include/asm-generic/iomap.h:101: note: this is the location of the previous definition
101 | #define ioremap_wt ioremap