2023-06-20 13:27:56

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 00/19] mm: ioremap: Convert architectures to take GENERIC_IOREMAP way

Motivation and implementation:
==============================
Currently, many architecutres have't taken the standard GENERIC_IOREMAP
way to implement ioremap_prot(), iounmap(), and ioremap_xx(), but make
these functions specifically under each arch's folder. Those cause many
duplicated codes of ioremap() and iounmap().

In this patchset, firstly introduce generic_ioremap_prot() and
generic_iounmap() to extract the generic codes for GENERIC_IOREMAP.
By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic version if there's
arch specific handling in its corresponding ioremap_prot(), ioremap()
or iounmap(). With these changes, duplicated ioremap/iounmap() code uder
ARCH-es are removed, and the equivalent functioality is kept as before.

Background info:
================
1)
The converting more architectures to take GENERIC_IOREMAP way is
suggested by Christoph in below discussion:
https://lore.kernel.org/all/[email protected]/T/#u

2)
In the previous v1 to v3, it's basically further action after arm64
has converted to GENERIC_IOREMAP way in below patchset. It's done by
adding hook ioremap_allowed() and iounmap_allowed() in ARCH to add
ARCH specific handling the middle of ioremap_prot() and iounmap().

[PATCH v5 0/6] arm64: Cleanup ioremap() and support ioremap_prot()
https://lore.kernel.org/all/[email protected]/T/#u

Later, during v3 reviewing, Christophe Leroy suggested to introduce
generic_ioremap_prot() and generic_iounmap() to generic codes, and ARCH
can provide wrapper function ioremap_prot(), ioremap() or iounmap() if
needed. Christophe made a RFC patchset as below to specially demonstrate
his idea. This is what v4 and now v5 is doing.

[RFC PATCH 0/8] mm: ioremap: Convert architectures to take GENERIC_IOREMAP way
https://lore.kernel.org/all/[email protected]/T/#u

Testing:
========
In v7, I only built and run on arm64 and s390, and pass the cross
compilig on hexagon following lkp's steps.

History:
=======
v6->v7:
- Fix the building error on s390 and hexagon reported by lkp test robot.
- Add Christoph, Mike, Catalin and Helge's ack.

v5->v6:
- Remove stale descriptions in log - Mike
- Remove the early unmapping handling from fixmap pool in iounmap() in
openrisc; Based on that, iounmap() in openrisc ARCH can be removed - Mike
- Add WARN_ON_ONCE to aid debugging in generic_ioremap_prot() - Christoph
- Split the inclusion of include/asm-generic/io.h and redefining of the
helpers from the old patch 11 into a prep patch; The following patch
can only contain code converting to GENERIC_IOREMAP for SuperH - Christoph
- Add header file linux/ioremap.h and move is_ioremap_addr() over
there - Christoph

v4->v5:
- Ard and Christophe suggested adding a preparation patch to remove
ARCH_HAS_IOREMAP_xx macros, this is done in newly added patch 1.
- In the current patch 13 ("parisc: mm: Convert to GENERIC_IOREMAP"),
so we don't need to add ARCH_HAS_IOREMAP_WC.

v3->v4:
- Change to contain arch specific handling in wrapper function
ioremap(), ioremap_prot() or iounmap() to replace the old hook
ioremap|iounmap_allowed() hook way for each arch.
- Add two patches to convert powerpc to GENERIC_IOREMAP. They are
picked from above Christophe's RFC patchset, I made some changes
to make them formal.

v2->v3:
- Rewrite log of all patches to add more details as Christoph suggested.

- Merge the old patch 1 and 2 which adjusts return values and
parameters of arch_ioremap() into one patch, namely the current
patch 3. Christoph suggested this.

- Change the return value of arch_iounmap() to bool type since we only
do arch specific address filtering or address checking, bool value
can reflect the checking better. This is pointed out by Niklas when
he reviewed the s390 patch.

- Put hexagon patch at the beginning of patchset since hexagon has the
same ioremap() and iounmap() as standard ones, no arch_ioremap() and
arch_iounmap() hooks need be introduced. So the later arch_ioremap
and arch_iounmap() adjustment are not related in hexagon. Christophe
suggested this.

- Remove the early ioremap code from openrisc ioremap() firstly since
openrisc doesn't have early ioremap handling in openrisc arch code.
This simplifies the later converting to GENERIC_IOREMAP method.
Christoph and Stafford suggersted this.

- Fix compiling erorrs reported by lkp in parisc and sh patches.
Adding macro defintions for those port|mem io functions in
<asm/io.h> to avoid repeated definition in <asm-generic/io.h>.

v1->v2:
- Rename io[re|un]map_allowed() to arch_io[re|un]map() and made
some minor changes in patch 1~2 as per Alexander and Kefeng's
suggestions. Accordingly, adjust patches~4~11 because of the renaming
arch_io[re|un]map().

Baoquan He (16):
asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros
hexagon: mm: Convert to GENERIC_IOREMAP
openrisc: mm: remove unneeded early ioremap code
mm: ioremap: allow ARCH to have its own ioremap method definition
mm/ioremap: add slab availability checking in ioremap_prot
arc: mm: Convert to GENERIC_IOREMAP
ia64: mm: Convert to GENERIC_IOREMAP
openrisc: mm: Convert to GENERIC_IOREMAP
s390: mm: Convert to GENERIC_IOREMAP
sh: add <asm-generic/io.h> including
sh: mm: Convert to GENERIC_IOREMAP
xtensa: mm: Convert to GENERIC_IOREMAP
parisc: mm: Convert to GENERIC_IOREMAP
mm: move is_ioremap_addr() into new header file
arm64 : mm: add wrapper function ioremap_prot()
mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed

Christophe Leroy (3):
mm/ioremap: Define generic_ioremap_prot() and generic_iounmap()
mm/ioremap: Consider IOREMAP space in generic ioremap
powerpc: mm: Convert to GENERIC_IOREMAP

arch/arc/Kconfig | 1 +
arch/arc/include/asm/io.h | 7 ++-
arch/arc/mm/ioremap.c | 49 ++---------------
arch/arm64/include/asm/io.h | 3 +-
arch/arm64/mm/ioremap.c | 10 ++--
arch/hexagon/Kconfig | 1 +
arch/hexagon/include/asm/io.h | 11 ++--
arch/hexagon/mm/ioremap.c | 44 ----------------
arch/ia64/Kconfig | 1 +
arch/ia64/include/asm/io.h | 13 ++---
arch/ia64/mm/ioremap.c | 41 +++------------
arch/loongarch/include/asm/io.h | 2 -
arch/m68k/include/asm/io_mm.h | 2 -
arch/m68k/include/asm/kmap.h | 2 -
arch/mips/include/asm/io.h | 5 +-
arch/openrisc/Kconfig | 1 +
arch/openrisc/include/asm/io.h | 11 ++--
arch/openrisc/mm/ioremap.c | 82 -----------------------------
arch/parisc/Kconfig | 1 +
arch/parisc/include/asm/io.h | 15 ++++--
arch/parisc/mm/ioremap.c | 62 ++--------------------
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/io.h | 17 ++----
arch/powerpc/include/asm/pgtable.h | 8 ---
arch/powerpc/mm/ioremap.c | 26 +--------
arch/powerpc/mm/ioremap_32.c | 19 ++++---
arch/powerpc/mm/ioremap_64.c | 12 +----
arch/s390/Kconfig | 1 +
arch/s390/include/asm/io.h | 21 ++++----
arch/s390/kernel/perf_cpum_sf.c | 2 +-
arch/s390/pci/pci.c | 57 ++++----------------
arch/sh/Kconfig | 1 +
arch/sh/include/asm/io.h | 65 ++++++++++++-----------
arch/sh/include/asm/io_noioport.h | 7 +++
arch/sh/mm/ioremap.c | 65 ++++-------------------
arch/x86/include/asm/io.h | 5 --
arch/xtensa/Kconfig | 1 +
arch/xtensa/include/asm/io.h | 32 +++++------
arch/xtensa/mm/ioremap.c | 58 +++++---------------
drivers/net/ethernet/sfc/io.h | 2 +-
drivers/net/ethernet/sfc/siena/io.h | 2 +-
include/asm-generic/io.h | 31 +++--------
include/asm-generic/iomap.h | 6 +--
include/linux/ioremap.h | 30 +++++++++++
include/linux/mm.h | 5 --
kernel/iomem.c | 1 +
mm/ioremap.c | 41 ++++++++++-----
47 files changed, 248 insertions(+), 632 deletions(-)
delete mode 100644 arch/hexagon/mm/ioremap.c
create mode 100644 include/linux/ioremap.h

--
2.34.1



2023-06-20 13:30:12

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic versions if there's
arch specific handling in its ioremap_prot(), ioremap() or iounmap().
This change will simplify implementation by removing duplicated codes
with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
functioality as before.

Here, add wrapper functions ioremap_prot() and iounmap() for s390's
special operation when ioremap() and iounmap().

And also replace including <asm-generic/io.h> with <asm/io.h> in
arch/s390/kernel/perf_cpum_sf.c, otherwise building error will be seen
because macro defined in <asm/io.h> can't be seen in perf_cpum_sf.c.

Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Niklas Schnelle <[email protected]>
Tested-by: Niklas Schnelle <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: Gerald Schaefer <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Sven Schnelle <[email protected]>
Cc: [email protected]
---
v6->v7:
- Fix building error reported by lkp test robot.
https://lore.kernel.org/oe-kbuild-all/[email protected]/

arch/s390/Kconfig | 1 +
arch/s390/include/asm/io.h | 21 ++++++------
arch/s390/kernel/perf_cpum_sf.c | 2 +-
arch/s390/pci/pci.c | 57 ++++++---------------------------
4 files changed, 24 insertions(+), 57 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 6dab9c1be508..e625bb0cc6c7 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -142,6 +142,7 @@ config S390
select GENERIC_SMP_IDLE_THREAD
select GENERIC_TIME_VSYSCALL
select GENERIC_VDSO_TIME_NS
+ select GENERIC_IOREMAP if PCI
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_JUMP_LABEL
diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h
index e3882b012bfa..4453ad7c11ac 100644
--- a/arch/s390/include/asm/io.h
+++ b/arch/s390/include/asm/io.h
@@ -22,11 +22,18 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);

#define IO_SPACE_LIMIT 0

-void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
-void __iomem *ioremap(phys_addr_t addr, size_t size);
-void __iomem *ioremap_wc(phys_addr_t addr, size_t size);
-void __iomem *ioremap_wt(phys_addr_t addr, size_t size);
-void iounmap(volatile void __iomem *addr);
+/*
+ * I/O memory mapping functions.
+ */
+#define ioremap_prot ioremap_prot
+#define iounmap iounmap
+
+#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL)
+
+#define ioremap_wc(addr, size) \
+ ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL)))
+#define ioremap_wt(addr, size) \
+ ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL)))

static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
{
@@ -51,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p)
#define pci_iomap_wc pci_iomap_wc
#define pci_iomap_wc_range pci_iomap_wc_range

-#define ioremap ioremap
-#define ioremap_wt ioremap_wt
-#define ioremap_wc ioremap_wc
-
#define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count)
#define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count)
#define memset_io(dst, val, count) zpci_memset_io(dst, val, count)
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index 7ef72f5ff52e..b0269f3881aa 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -22,7 +22,7 @@
#include <asm/irq.h>
#include <asm/debug.h>
#include <asm/timex.h>
-#include <asm-generic/io.h>
+#include <asm/io.h>

/* Minimum number of sample-data-block-tables:
* At least one table is required for the sampling buffer structure.
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index afc3f33788da..d34d5813d006 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -244,62 +244,25 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
zpci_memcpy_toio(to, from, count);
}

-static void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot)
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
+ unsigned long prot)
{
- unsigned long offset, vaddr;
- struct vm_struct *area;
- phys_addr_t last_addr;
-
- last_addr = addr + size - 1;
- if (!size || last_addr < addr)
- return NULL;
-
+ /*
+ * When PCI MIO instructions are unavailable the "physical" address
+ * encodes a hint for accessing the PCI memory space it represents.
+ * Just pass it unchanged such that ioread/iowrite can decode it.
+ */
if (!static_branch_unlikely(&have_mio))
- return (void __iomem *) addr;
+ return (void __iomem *)phys_addr;

- offset = addr & ~PAGE_MASK;
- addr &= PAGE_MASK;
- size = PAGE_ALIGN(size + offset);
- area = get_vm_area(size, VM_IOREMAP);
- if (!area)
- return NULL;
-
- vaddr = (unsigned long) area->addr;
- if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) {
- free_vm_area(area);
- return NULL;
- }
- return (void __iomem *) ((unsigned long) area->addr + offset);
-}
-
-void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
-{
- return __ioremap(addr, size, __pgprot(prot));
+ return generic_ioremap_prot(phys_addr, size, __pgprot(prot));
}
EXPORT_SYMBOL(ioremap_prot);

-void __iomem *ioremap(phys_addr_t addr, size_t size)
-{
- return __ioremap(addr, size, PAGE_KERNEL);
-}
-EXPORT_SYMBOL(ioremap);
-
-void __iomem *ioremap_wc(phys_addr_t addr, size_t size)
-{
- return __ioremap(addr, size, pgprot_writecombine(PAGE_KERNEL));
-}
-EXPORT_SYMBOL(ioremap_wc);
-
-void __iomem *ioremap_wt(phys_addr_t addr, size_t size)
-{
- return __ioremap(addr, size, pgprot_writethrough(PAGE_KERNEL));
-}
-EXPORT_SYMBOL(ioremap_wt);
-
void iounmap(volatile void __iomem *addr)
{
if (static_branch_likely(&have_mio))
- vunmap((__force void *) ((unsigned long) addr & PAGE_MASK));
+ generic_iounmap(addr);
}
EXPORT_SYMBOL(iounmap);

--
2.34.1


2023-06-20 13:30:14

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 05/19] mm: ioremap: allow ARCH to have its own ioremap method definition

Architectures can be converted to GENERIC_IOREMAP, to take standard
ioremap_xxx() and iounmap() way. But some ARCH-es could have specific
handling for ioremap_prot(), ioremap() and iounmap(), than standard
methods.

In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow
these architecutres to have their own ioremap_prot(), ioremap() and
iounmap() definitions.

Signed-off-by: Baoquan He <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Kefeng Wang <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: [email protected]
---
include/asm-generic/io.h | 3 +++
mm/ioremap.c | 4 ++++
2 files changed, 7 insertions(+)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index a7ca2099ba19..39244c3ee797 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -1081,11 +1081,14 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
void iounmap(volatile void __iomem *addr);
void generic_iounmap(volatile void __iomem *addr);

+#ifndef ioremap
+#define ioremap ioremap
static inline void __iomem *ioremap(phys_addr_t addr, size_t size)
{
/* _PAGE_IOREMAP needs to be supplied by the architecture */
return ioremap_prot(addr, size, _PAGE_IOREMAP);
}
+#endif
#endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */

#ifndef ioremap_wc
diff --git a/mm/ioremap.c b/mm/ioremap.c
index db6234b9db59..9f34a8f90b58 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,
return (void __iomem *)(vaddr + offset);
}

+#ifndef ioremap_prot
void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
unsigned long prot)
{
return generic_ioremap_prot(phys_addr, size, __pgprot(prot));
}
EXPORT_SYMBOL(ioremap_prot);
+#endif

void generic_iounmap(volatile void __iomem *addr)
{
@@ -64,8 +66,10 @@ void generic_iounmap(volatile void __iomem *addr)
vunmap(vaddr);
}

+#ifndef iounmap
void iounmap(volatile void __iomem *addr)
{
generic_iounmap(addr);
}
EXPORT_SYMBOL(iounmap);
+#endif
--
2.34.1


2023-06-20 13:34:47

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 13/19] xtensa: mm: Convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic versions if there's
arch specific handling in its ioremap_prot(), ioremap() or iounmap().
This change will simplify implementation by removing duplicated codes
with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
functioality as before.

Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for
xtensa's special operation when ioremap() and iounmap().

Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/Kconfig | 1 +
arch/xtensa/include/asm/io.h | 32 ++++++++------------
arch/xtensa/mm/ioremap.c | 58 +++++++++---------------------------
3 files changed, 27 insertions(+), 64 deletions(-)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 3c6e5471f025..474cbbff3e6c 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -29,6 +29,7 @@ config XTENSA
select GENERIC_LIB_UCMPDI2
select GENERIC_PCI_IOMAP
select GENERIC_SCHED_CLOCK
+ select GENERIC_IOREMAP if MMU
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h
index a5b707e1c0f4..934e58399c8c 100644
--- a/arch/xtensa/include/asm/io.h
+++ b/arch/xtensa/include/asm/io.h
@@ -16,6 +16,7 @@
#include <asm/vectors.h>
#include <linux/bug.h>
#include <linux/kernel.h>
+#include <linux/pgtable.h>

#include <linux/types.h>

@@ -24,22 +25,24 @@
#define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR)

#ifdef CONFIG_MMU
-
-void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size);
-void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size);
-void xtensa_iounmap(volatile void __iomem *addr);
-
/*
- * Return the virtual address for the specified bus memory.
+ * I/O memory mapping functions.
*/
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
+ unsigned long prot);
+#define ioremap_prot ioremap_prot
+#define iounmap iounmap
+
static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
{
if (offset >= XCHAL_KIO_PADDR
&& offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
else
- return xtensa_ioremap_nocache(offset, size);
+ return ioremap_prot(offset, size,
+ pgprot_val(pgprot_noncached(PAGE_KERNEL)));
}
+#define ioremap ioremap

static inline void __iomem *ioremap_cache(unsigned long offset,
unsigned long size)
@@ -48,21 +51,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset,
&& offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
else
- return xtensa_ioremap_cache(offset, size);
-}
-#define ioremap_cache ioremap_cache
+ return ioremap_prot(offset, size, pgprot_val(PAGE_KERNEL));

-static inline void iounmap(volatile void __iomem *addr)
-{
- unsigned long va = (unsigned long) addr;
-
- if (!(va >= XCHAL_KIO_CACHED_VADDR &&
- va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
- !(va >= XCHAL_KIO_BYPASS_VADDR &&
- va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
- xtensa_iounmap(addr);
}
-
+#define ioremap_cache ioremap_cache
#endif /* CONFIG_MMU */

#include <asm-generic/io.h>
diff --git a/arch/xtensa/mm/ioremap.c b/arch/xtensa/mm/ioremap.c
index a400188c16b9..8ca660b7ab49 100644
--- a/arch/xtensa/mm/ioremap.c
+++ b/arch/xtensa/mm/ioremap.c
@@ -6,60 +6,30 @@
*/

#include <linux/io.h>
-#include <linux/vmalloc.h>
#include <linux/pgtable.h>
#include <asm/cacheflush.h>
#include <asm/io.h>

-static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size,
- pgprot_t prot)
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
+ unsigned long prot)
{
- unsigned long offset = paddr & ~PAGE_MASK;
- unsigned long pfn = __phys_to_pfn(paddr);
- struct vm_struct *area;
- unsigned long vaddr;
- int err;
-
- paddr &= PAGE_MASK;
-
+ unsigned long pfn = __phys_to_pfn((phys_addr));
WARN_ON(pfn_valid(pfn));

- size = PAGE_ALIGN(offset + size);
-
- area = get_vm_area(size, VM_IOREMAP);
- if (!area)
- return NULL;
-
- vaddr = (unsigned long)area->addr;
- area->phys_addr = paddr;
-
- err = ioremap_page_range(vaddr, vaddr + size, paddr, prot);
-
- if (err) {
- vunmap((void *)vaddr);
- return NULL;
- }
-
- flush_cache_vmap(vaddr, vaddr + size);
- return (void __iomem *)(offset + vaddr);
-}
-
-void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size)
-{
- return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL));
+ return generic_ioremap_prot(phys_addr, size, __pgprot(prot));
}
-EXPORT_SYMBOL(xtensa_ioremap_nocache);
+EXPORT_SYMBOL(ioremap_prot);

-void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size)
+void iounmap(volatile void __iomem *addr)
{
- return xtensa_ioremap(addr, size, PAGE_KERNEL);
-}
-EXPORT_SYMBOL(xtensa_ioremap_cache);
+ unsigned long va = (unsigned long) addr;

-void xtensa_iounmap(volatile void __iomem *io_addr)
-{
- void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr);
+ if ((va >= XCHAL_KIO_CACHED_VADDR &&
+ va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) ||
+ (va >= XCHAL_KIO_BYPASS_VADDR &&
+ va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
+ return;

- vunmap(addr);
+ generic_iounmap(addr);
}
-EXPORT_SYMBOL(xtensa_iounmap);
+EXPORT_SYMBOL(iounmap);
--
2.34.1


2023-06-20 13:37:39

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic ioremap_prot() and
iounmap() are visible and available to arch. This change will
simplify implementation by removing duplicated codes with generic
ioremap_prot() and iounmap(), and has the equivalent functioality.

For hexagon, the current ioremap() and iounmap() are the same as
generic version. After taking GENERIC_IOREMAP way, the old ioremap()
and iounmap() can be completely removed.

Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: Brian Cain <[email protected]>
Cc: [email protected]
---
v6->v7:
- Fix building error reported by lkp test robot. Here I only fixed the
redefinition of iounmap(), ignored the PCI_IOBASE warnings since
Nathan kindly reminded me the warning is a generic issue, and Niklas
is working on that within below patchset.
https://lore.kernel.org/all/[email protected]/T/#u

arch/hexagon/Kconfig | 1 +
arch/hexagon/include/asm/io.h | 11 +++++----
arch/hexagon/mm/ioremap.c | 44 -----------------------------------
3 files changed, 8 insertions(+), 48 deletions(-)
delete mode 100644 arch/hexagon/mm/ioremap.c

diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 54eadf265178..17afffde1a7f 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -25,6 +25,7 @@ config HEXAGON
select NEED_SG_DMA_LENGTH
select NO_IOPORT_MAP
select GENERIC_IOMAP
+ select GENERIC_IOREMAP
select GENERIC_SMP_IDLE_THREAD
select STACKTRACE_SUPPORT
select GENERIC_CLOCKEVENTS_BROADCAST
diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h
index 46a099de85b7..e2b308e32a37 100644
--- a/arch/hexagon/include/asm/io.h
+++ b/arch/hexagon/include/asm/io.h
@@ -27,8 +27,6 @@
extern int remap_area_pages(unsigned long start, unsigned long phys_addr,
unsigned long end, unsigned long flags);

-extern void iounmap(const volatile void __iomem *addr);
-
/* Defined in lib/io.c, needed for smc91x driver. */
extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen);
extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
@@ -170,8 +168,13 @@ static inline void writel(u32 data, volatile void __iomem *addr)
#define writew_relaxed __raw_writew
#define writel_relaxed __raw_writel

-void __iomem *ioremap(unsigned long phys_addr, unsigned long size);
-#define ioremap_uc(X, Y) ioremap((X), (Y))
+/*
+ * I/O memory mapping functions.
+ */
+#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
diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c
deleted file mode 100644
index 255c5b1ee1a7..000000000000
--- a/arch/hexagon/mm/ioremap.c
+++ /dev/null
@@ -1,44 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * I/O remap functions for Hexagon
- *
- * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
- */
-
-#include <linux/io.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-
-void __iomem *ioremap(unsigned long phys_addr, unsigned long size)
-{
- unsigned long last_addr, addr;
- unsigned long offset = phys_addr & ~PAGE_MASK;
- struct vm_struct *area;
-
- pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE
- |(__HEXAGON_C_DEV << 6));
-
- last_addr = phys_addr + size - 1;
-
- /* Wrapping not allowed */
- if (!size || (last_addr < phys_addr))
- return NULL;
-
- /* Rounds up to next page size, including whole-page offset */
- size = PAGE_ALIGN(offset + size);
-
- area = get_vm_area(size, VM_IOREMAP);
- addr = (unsigned long)area->addr;
-
- if (ioremap_page_range(addr, addr+size, phys_addr, prot)) {
- vunmap((void *)addr);
- return NULL;
- }
-
- return (void __iomem *) (offset + addr);
-}
-
-void iounmap(const volatile void __iomem *addr)
-{
- vunmap((void *) ((unsigned long) addr & PAGE_MASK));
-}
--
2.34.1


2023-06-20 13:37:41

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 17/19] powerpc: mm: Convert to GENERIC_IOREMAP

From: Christophe Leroy <[email protected]>

By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic versions if there's
arch specific handling in its ioremap_prot(), ioremap() or iounmap().
This change will simplify implementation by removing duplicated codes
with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
functioality as before.

Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's
special operation when ioremap() and iounmap().

Signed-off-by: Christophe Leroy <[email protected]>
Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: [email protected]
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/io.h | 8 +++-----
arch/powerpc/mm/ioremap.c | 26 +-------------------------
arch/powerpc/mm/ioremap_32.c | 19 +++++++++----------
arch/powerpc/mm/ioremap_64.c | 12 ++----------
5 files changed, 16 insertions(+), 50 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index bff5820b7cda..aadb280a539e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -194,6 +194,7 @@ config PPC
select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC
select GENERIC_EARLY_IOREMAP
select GENERIC_GETTIMEOFDAY
+ select GENERIC_IOREMAP
select GENERIC_IRQ_SHOW
select GENERIC_IRQ_SHOW_LEVEL
select GENERIC_PCI_IOMAP if PCI
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 67a3fb6de498..0732b743e099 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -889,8 +889,8 @@ static inline void iosync(void)
*
*/
extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
-extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size,
- unsigned long flags);
+#define ioremap ioremap
+#define ioremap_prot ioremap_prot
extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
#define ioremap_wc ioremap_wc

@@ -904,14 +904,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size);
#define ioremap_cache(addr, size) \
ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL))

-extern void iounmap(volatile void __iomem *addr);
+#define iounmap iounmap

void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size);

int early_ioremap_range(unsigned long ea, phys_addr_t pa,
unsigned long size, pgprot_t prot);
-void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size,
- pgprot_t prot, void *caller);

extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size,
pgprot_t prot, void *caller);
diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c
index 4f12504fb405..705e8e8ffde4 100644
--- a/arch/powerpc/mm/ioremap.c
+++ b/arch/powerpc/mm/ioremap.c
@@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size)
return __ioremap_caller(addr, size, prot, caller);
}

-void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags)
+void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags)
{
pte_t pte = __pte(flags);
void *caller = __builtin_return_address(0);
@@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa,

return 0;
}
-
-void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size,
- pgprot_t prot, void *caller)
-{
- struct vm_struct *area;
- int ret;
- unsigned long va;
-
- area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller);
- if (area == NULL)
- return NULL;
-
- area->phys_addr = pa;
- va = (unsigned long)area->addr;
-
- ret = ioremap_page_range(va, va + size, pa, prot);
- if (!ret)
- return (void __iomem *)area->addr + offset;
-
- vunmap_range(va, va + size);
- free_vm_area(area);
-
- return NULL;
-}
diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c
index 9d13143b8be4..ca5bc6be3e6f 100644
--- a/arch/powerpc/mm/ioremap_32.c
+++ b/arch/powerpc/mm/ioremap_32.c
@@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call
phys_addr_t p, offset;
int err;

+ /*
+ * If the address lies within the first 16 MB, assume it's in ISA
+ * memory space
+ */
+ if (addr < SZ_16M)
+ addr += _ISA_MEM_BASE;
+
/*
* Choose an address to map it to.
* Once the vmalloc system is running, we use it.
@@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call
offset = addr & ~PAGE_MASK;
size = PAGE_ALIGN(addr + size) - p;

- /*
- * If the address lies within the first 16 MB, assume it's in ISA
- * memory space
- */
- if (p < 16 * 1024 * 1024)
- p += _ISA_MEM_BASE;
-
#ifndef CONFIG_CRASH_DUMP
/*
* Don't allow anybody to remap normal RAM that we're using.
@@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call
return (void __iomem *)v + offset;

if (slab_is_available())
- return do_ioremap(p, offset, size, prot, caller);
+ return generic_ioremap_prot(addr, size, prot);

/*
* Should check if it is a candidate for a BAT mapping
@@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr)
if (v_block_mapped((unsigned long)addr))
return;

- if (addr > high_memory && (unsigned long)addr < ioremap_bot)
- vunmap((void *)(PAGE_MASK & (unsigned long)addr));
+ generic_iounmap(addr);
}
EXPORT_SYMBOL(iounmap);
diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c
index 3acece00b33e..d24e5f166723 100644
--- a/arch/powerpc/mm/ioremap_64.c
+++ b/arch/powerpc/mm/ioremap_64.c
@@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size,
return NULL;

if (slab_is_available())
- return do_ioremap(paligned, offset, size, prot, caller);
+ return generic_ioremap_prot(addr, size, prot);

pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller);

@@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size,
*/
void iounmap(volatile void __iomem *token)
{
- void *addr;
-
if (!slab_is_available())
return;

- addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK);
-
- if ((unsigned long)addr < ioremap_bot) {
- pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr);
- return;
- }
- vunmap(addr);
+ generic_iounmap(PCI_FIX_ADDR(token));
}
EXPORT_SYMBOL(iounmap);
--
2.34.1


2023-06-20 13:39:03

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap

From: Christophe Leroy <[email protected]>

Architectures like powerpc have a dedicated space for IOREMAP mappings.

If so, use it in generic_ioremap_prot().

Signed-off-by: Christophe Leroy <[email protected]>
Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
mm/ioremap.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/mm/ioremap.c b/mm/ioremap.c
index 86b82ec27d2b..68d9895144ad 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -11,6 +11,15 @@
#include <linux/io.h>
#include <linux/export.h>

+/*
+ * Ioremap often, but not always uses the generic vmalloc area. E.g on
+ * Power ARCH, it could have different ioremap space.
+ */
+#ifndef IOREMAP_START
+#define IOREMAP_START VMALLOC_START
+#define IOREMAP_END VMALLOC_END
+#endif
+
void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,
pgprot_t prot)
{
@@ -35,8 +44,8 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,
if (!ioremap_allowed(phys_addr, size, pgprot_val(prot)))
return NULL;

- area = get_vm_area_caller(size, VM_IOREMAP,
- __builtin_return_address(0));
+ area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START,
+ IOREMAP_END, __builtin_return_address(0));
if (!area)
return NULL;
vaddr = (unsigned long)area->addr;
@@ -66,7 +75,7 @@ void generic_iounmap(volatile void __iomem *addr)
if (!iounmap_allowed(vaddr))
return;

- if (is_vmalloc_addr(vaddr))
+ if (is_ioremap_addr(vaddr))
vunmap(vaddr);
}

--
2.34.1


2023-06-20 13:40:11

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 06/19] mm/ioremap: add slab availability checking in ioremap_prot

Several architectures has done checking if slab if available in
ioremap_prot(). In fact it should be done in generic ioremap_prot()
since on any architecutre, slab allocator must be available before
get_vm_area_caller() and vunmap() are used.

Add the checking into generic_ioremap_prot().

Suggested-by: Christophe Leroy <[email protected]>
Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Kefeng Wang <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
---
mm/ioremap.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/mm/ioremap.c b/mm/ioremap.c
index 9f34a8f90b58..86b82ec27d2b 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,
phys_addr_t last_addr;
struct vm_struct *area;

+ /* An early platform driver might end up here */
+ if (WARN_ON_ONCE(!slab_is_available()))
+ return NULL;
+
/* Disallow wrap-around or zero size */
last_addr = phys_addr + size - 1;
if (!size || last_addr < phys_addr)
--
2.34.1


2023-06-20 13:40:37

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 16/19] mm: move is_ioremap_addr() into new header file

Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used
in mm/ioremap.c. Move it into its own new header file linux/ioremap.h.

Signed-off-by: Baoquan He <[email protected]>
Suggested-by: Christoph Hellwig <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
arch/powerpc/include/asm/pgtable.h | 8 --------
include/linux/ioremap.h | 30 ++++++++++++++++++++++++++++++
include/linux/mm.h | 5 -----
kernel/iomem.c | 1 +
mm/ioremap.c | 10 +---------
5 files changed, 32 insertions(+), 22 deletions(-)
create mode 100644 include/linux/ioremap.h

diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index 9972626ddaf6..d252323a753f 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -158,14 +158,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd)
}

#ifdef CONFIG_PPC64
-#define is_ioremap_addr is_ioremap_addr
-static inline bool is_ioremap_addr(const void *x)
-{
- unsigned long addr = (unsigned long)x;
-
- return addr >= IOREMAP_BASE && addr < IOREMAP_END;
-}
-
struct seq_file;
void arch_report_meminfo(struct seq_file *m);
#endif /* CONFIG_PPC64 */
diff --git a/include/linux/ioremap.h b/include/linux/ioremap.h
new file mode 100644
index 000000000000..f0e99fc7dd8b
--- /dev/null
+++ b/include/linux/ioremap.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_IOREMAP_H
+#define _LINUX_IOREMAP_H
+
+#include <linux/kasan.h>
+#include <asm/pgtable.h>
+
+#if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP)
+/*
+ * Ioremap often, but not always uses the generic vmalloc area. E.g on
+ * Power ARCH, it could have different ioremap space.
+ */
+#ifndef IOREMAP_START
+#define IOREMAP_START VMALLOC_START
+#define IOREMAP_END VMALLOC_END
+#endif
+static inline bool is_ioremap_addr(const void *x)
+{
+ unsigned long addr = (unsigned long)kasan_reset_tag(x);
+
+ return addr >= IOREMAP_START && addr < IOREMAP_END;
+}
+#else
+static inline bool is_ioremap_addr(const void *x)
+{
+ return false;
+}
+#endif
+
+#endif /* _LINUX_IOREMAP_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 27ce77080c79..7379f19768b4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1041,11 +1041,6 @@ unsigned long vmalloc_to_pfn(const void *addr);
* On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there
* is no special casing required.
*/
-
-#ifndef is_ioremap_addr
-#define is_ioremap_addr(x) is_vmalloc_addr(x)
-#endif
-
#ifdef CONFIG_MMU
extern bool is_vmalloc_addr(const void *x);
extern int is_vmalloc_or_module_addr(const void *x);
diff --git a/kernel/iomem.c b/kernel/iomem.c
index 62c92e43aa0d..9682471e6471 100644
--- a/kernel/iomem.c
+++ b/kernel/iomem.c
@@ -3,6 +3,7 @@
#include <linux/types.h>
#include <linux/io.h>
#include <linux/mm.h>
+#include <linux/ioremap.h>

#ifndef ioremap_cache
/* temporary while we convert existing ioremap_cache users to memremap */
diff --git a/mm/ioremap.c b/mm/ioremap.c
index 68d9895144ad..a21a6c9fa5ab 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -10,15 +10,7 @@
#include <linux/mm.h>
#include <linux/io.h>
#include <linux/export.h>
-
-/*
- * Ioremap often, but not always uses the generic vmalloc area. E.g on
- * Power ARCH, it could have different ioremap space.
- */
-#ifndef IOREMAP_START
-#define IOREMAP_START VMALLOC_START
-#define IOREMAP_END VMALLOC_END
-#endif
+#include <linux/ioremap.h>

void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,
pgprot_t prot)
--
2.34.1


2023-06-20 13:41:03

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 08/19] ia64: mm: Convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic versions if there's
arch specific handling in its ioremap_prot(), ioremap() or iounmap().
This change will simplify implementation by removing duplicated codes
with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
functioality as before.

Here, add wrapper functions ioremap_prot() and iounmap() for ia64's
special operation when ioremap() and iounmap().

Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: [email protected]
---
arch/ia64/Kconfig | 1 +
arch/ia64/include/asm/io.h | 13 +++++-------
arch/ia64/mm/ioremap.c | 41 ++++++--------------------------------
3 files changed, 12 insertions(+), 43 deletions(-)

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 21fa63ce5ffc..4f970b6d8032 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -46,6 +46,7 @@ config IA64
select GENERIC_IRQ_LEGACY
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select GENERIC_IOMAP
+ select GENERIC_IOREMAP
select GENERIC_SMP_IDLE_THREAD
select ARCH_TASK_STRUCT_ON_STACK
select ARCH_TASK_STRUCT_ALLOCATOR
diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h
index 83a492c8d298..eedc0afa8cad 100644
--- a/arch/ia64/include/asm/io.h
+++ b/arch/ia64/include/asm/io.h
@@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src,

# ifdef __KERNEL__

-extern void __iomem * ioremap(unsigned long offset, unsigned long size);
+#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL)
+
extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size);
-extern void iounmap (volatile void __iomem *addr);
-static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size)
-{
- return ioremap(phys_addr, size);
-}
-#define ioremap ioremap
-#define ioremap_cache ioremap_cache
+
+#define ioremap_prot ioremap_prot
+#define ioremap_cache ioremap
#define ioremap_uc ioremap_uc
#define iounmap iounmap

diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c
index 92b81bc91397..711b6abc822e 100644
--- a/arch/ia64/mm/ioremap.c
+++ b/arch/ia64/mm/ioremap.c
@@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size)
return __ioremap_uc(phys_addr);
}

-void __iomem *
-ioremap (unsigned long phys_addr, unsigned long size)
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
+ unsigned long flags)
{
- void __iomem *addr;
- struct vm_struct *area;
- unsigned long offset;
- pgprot_t prot;
u64 attr;
unsigned long gran_base, gran_size;
unsigned long page_base;
@@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size)
*/
page_base = phys_addr & PAGE_MASK;
size = PAGE_ALIGN(phys_addr + size) - page_base;
- if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) {
- prot = PAGE_KERNEL;
-
- /*
- * Mappings have to be page-aligned
- */
- offset = phys_addr & ~PAGE_MASK;
- phys_addr &= PAGE_MASK;
-
- /*
- * Ok, go for it..
- */
- area = get_vm_area(size, VM_IOREMAP);
- if (!area)
- return NULL;
-
- area->phys_addr = phys_addr;
- addr = (void __iomem *) area->addr;
- if (ioremap_page_range((unsigned long) addr,
- (unsigned long) addr + size, phys_addr, prot)) {
- vunmap((void __force *) addr);
- return NULL;
- }
-
- return (void __iomem *) (offset + (char __iomem *)addr);
- }
+ if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB)
+ return generic_ioremap_prot(phys_addr, size, __pgprot(flags));

return __ioremap_uc(phys_addr);
}
-EXPORT_SYMBOL(ioremap);
+EXPORT_SYMBOL(ioremap_prot);

void __iomem *
ioremap_uc(unsigned long phys_addr, unsigned long size)
@@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size)
{
}

-void
-iounmap (volatile void __iomem *addr)
+void iounmap(volatile void __iomem *addr)
{
if (REGION_NUMBER(addr) == RGN_GATE)
vunmap((void *) ((unsigned long) addr & PAGE_MASK));
--
2.34.1


2023-06-20 13:41:04

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 09/19] openrisc: mm: Convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic versions if there's
arch specific handling in its ioremap_prot(), ioremap() or iounmap().
This change will simplify implementation by removing duplicated codes
with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
functioality as before.

For openrisc, the current ioremap() and iounmap() are the same as
generic version. After taking GENERIC_IOREMAP way, the old ioremap()
and iounmap() can be completely removed.

Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Stefan Kristiansson <[email protected]>
Cc: [email protected]
---
arch/openrisc/Kconfig | 1 +
arch/openrisc/include/asm/io.h | 11 ++++----
arch/openrisc/mm/ioremap.c | 49 ----------------------------------
3 files changed, 7 insertions(+), 54 deletions(-)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index c7f282f60f64..fd9bb76a610b 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -21,6 +21,7 @@ config OPENRISC
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
select GENERIC_PCI_IOMAP
+ select GENERIC_IOREMAP
select GENERIC_CPU_DEVICES
select HAVE_PCI
select HAVE_UID16
diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h
index ee6043a03173..5a6f0f16a5ce 100644
--- a/arch/openrisc/include/asm/io.h
+++ b/arch/openrisc/include/asm/io.h
@@ -15,6 +15,8 @@
#define __ASM_OPENRISC_IO_H

#include <linux/types.h>
+#include <asm/pgalloc.h>
+#include <asm/pgtable.h>

/*
* PCI: We do not use IO ports in OpenRISC
@@ -27,11 +29,10 @@
#define PIO_OFFSET 0
#define PIO_MASK 0

-#define ioremap ioremap
-void __iomem *ioremap(phys_addr_t offset, unsigned long size);
-
-#define iounmap iounmap
-extern void iounmap(volatile void __iomem *addr);
+/*
+ * I/O memory mapping functions.
+ */
+#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI)

#include <asm-generic/io.h>

diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c
index cdbcc7e73684..91c8259d4b7e 100644
--- a/arch/openrisc/mm/ioremap.c
+++ b/arch/openrisc/mm/ioremap.c
@@ -22,55 +22,6 @@

extern int mem_init_done;

-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- *
- * NOTE! We need to allow non-page-aligned mappings too: we will obviously
- * have to convert them into an offset in a page-aligned mapping, but the
- * caller shouldn't need to know that small detail.
- */
-void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size)
-{
- phys_addr_t p;
- unsigned long v;
- unsigned long offset, last_addr;
- struct vm_struct *area = NULL;
-
- /* Don't allow wraparound or zero size */
- last_addr = addr + size - 1;
- if (!size || last_addr < addr)
- return NULL;
-
- /*
- * Mappings have to be page-aligned
- */
- offset = addr & ~PAGE_MASK;
- p = addr & PAGE_MASK;
- size = PAGE_ALIGN(last_addr + 1) - p;
-
- area = get_vm_area(size, VM_IOREMAP);
- if (!area)
- return NULL;
- v = (unsigned long)area->addr;
-
- if (ioremap_page_range(v, v + size, p,
- __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) {
- vfree(area->addr);
- return NULL;
- }
-
- return (void __iomem *)(offset + (char *)v);
-}
-EXPORT_SYMBOL(ioremap);
-
-void iounmap(volatile void __iomem *addr)
-{
- return vfree((void *)(PAGE_MASK & (unsigned long)addr));
-}
-EXPORT_SYMBOL(iounmap);
-
/**
* OK, this one's a bit tricky... ioremap can get called before memory is
* initialized (early serial console does this) and will want to alloc a page
--
2.34.1


2023-06-20 13:42:36

by Baoquan He

[permalink] [raw]
Subject: [PATCH v7 07/19] arc: mm: Convert to GENERIC_IOREMAP

By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
and iounmap() are all visible and available to arch. Arch needs to
provide wrapper functions to override the generic versions if there's
arch specific handling in its ioremap_prot(), ioremap() or iounmap().
This change will simplify implementation by removing duplicated codes
with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
functioality as before.

Here, add wrapper functions ioremap_prot() and iounmap() for arc's
special operation when ioremap_prot() and iounmap().

Signed-off-by: Baoquan He <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Rapoport (IBM) <[email protected]>
Cc: Vineet Gupta <[email protected]>
Cc: [email protected]
---
arch/arc/Kconfig | 1 +
arch/arc/include/asm/io.h | 7 +++---
arch/arc/mm/ioremap.c | 49 ++++-----------------------------------
3 files changed, 8 insertions(+), 49 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index ab6d701365bb..3a666ee0c0bc 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -26,6 +26,7 @@ config ARC
select GENERIC_PENDING_IRQ if SMP
select GENERIC_SCHED_CLOCK
select GENERIC_SMP_IDLE_THREAD
+ select GENERIC_IOREMAP
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index 80347382a380..4fdb7350636c 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -21,8 +21,9 @@
#endif

extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size);
-extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size,
- unsigned long flags);
+#define ioremap ioremap
+#define ioremap_prot ioremap_prot
+#define iounmap iounmap
static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
{
return (void __iomem *)port;
@@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr)
{
}

-extern void iounmap(const volatile void __iomem *addr);
-
/*
* io{read,write}{16,32}be() macros
*/
diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c
index 712c2311daef..b07004d53267 100644
--- a/arch/arc/mm/ioremap.c
+++ b/arch/arc/mm/ioremap.c
@@ -8,7 +8,6 @@
#include <linux/module.h>
#include <linux/io.h>
#include <linux/mm.h>
-#include <linux/slab.h>
#include <linux/cache.h>

static inline bool arc_uncached_addr_space(phys_addr_t paddr)
@@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr)

void __iomem *ioremap(phys_addr_t paddr, unsigned long size)
{
- phys_addr_t end;
-
- /* Don't allow wraparound or zero size */
- end = paddr + size - 1;
- if (!size || (end < paddr))
- return NULL;
-
/*
* If the region is h/w uncached, MMU mapping can be elided as optim
* The cast to u32 is fine as this region can only be inside 4GB
@@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap);
* ARC hardware uncached region, this one still goes thru the MMU as caller
* might need finer access control (R/W/X)
*/
-void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size,
+void __iomem *ioremap_prot(phys_addr_t paddr, size_t size,
unsigned long flags)
{
- unsigned int off;
- unsigned long vaddr;
- struct vm_struct *area;
- phys_addr_t end;
pgprot_t prot = __pgprot(flags);

- /* Don't allow wraparound, zero size */
- end = paddr + size - 1;
- if ((!size) || (end < paddr))
- return NULL;
-
- /* An early platform driver might end up here */
- if (!slab_is_available())
- return NULL;
-
/* force uncached */
- prot = pgprot_noncached(prot);
-
- /* Mappings have to be page-aligned */
- off = paddr & ~PAGE_MASK;
- paddr &= PAGE_MASK_PHYS;
- size = PAGE_ALIGN(end + 1) - paddr;
-
- /*
- * Ok, go for it..
- */
- area = get_vm_area(size, VM_IOREMAP);
- if (!area)
- return NULL;
- area->phys_addr = paddr;
- vaddr = (unsigned long)area->addr;
- if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) {
- vunmap((void __force *)vaddr);
- return NULL;
- }
- return (void __iomem *)(off + (char __iomem *)vaddr);
+ return generic_ioremap_prot(paddr, size, pgprot_noncached(prot));
}
EXPORT_SYMBOL(ioremap_prot);

-
-void iounmap(const volatile void __iomem *addr)
+void iounmap(volatile void __iomem *addr)
{
/* weird double cast to handle phys_addr_t > 32 bits */
if (arc_uncached_addr_space((phys_addr_t)(u32)addr))
return;

- vfree((void *)(PAGE_MASK & (unsigned long __force)addr));
+ generic_iounmap(addr);
}
EXPORT_SYMBOL(iounmap);
--
2.34.1


2023-06-21 02:31:19

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP

Hi Baoquan,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20230620131356.25440-3-bhe%40redhat.com
patch subject: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP
config: hexagon-randconfig-r041-20230620 (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> arch/hexagon/kernel/hexagon_ksyms.o: error: local symbol ioremap was exported

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-06-21 05:50:52

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

Hi Baoquan,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
compiler: s390-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

drivers/tty/ipwireless/main.c: In function 'ipwireless_probe':
drivers/tty/ipwireless/main.c:115:30: error: implicit declaration of function 'ioremap'; did you mean 'iounmap'? [-Werror=implicit-function-declaration]
115 | ipw->common_memory = ioremap(p_dev->resource[2]->start,
| ^~~~~~~
| iounmap
>> drivers/tty/ipwireless/main.c:115:28: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
115 | ipw->common_memory = ioremap(p_dev->resource[2]->start,
| ^
drivers/tty/ipwireless/main.c:139:26: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
139 | ipw->attr_memory = ioremap(p_dev->resource[3]->start,
| ^
In file included from include/linux/io.h:13,
from drivers/tty/ipwireless/main.c:26:
arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
29 | #define iounmap iounmap
| ^~~~~~~
drivers/tty/ipwireless/main.c:155:9: note: in expansion of macro 'iounmap'
155 | iounmap(ipw->attr_memory);
| ^~~~~~~
cc1: some warnings being treated as errors
--
drivers/net/ethernet/smsc/smc91c92_cs.c: In function 'mhz_mfc_config':
>> drivers/net/ethernet/smsc/smc91c92_cs.c:447:17: error: implicit declaration of function 'ioremap'; did you mean 'ifr_map'? [-Werror=implicit-function-declaration]
447 | smc->base = ioremap(link->resource[2]->start,
| ^~~~~~~
| ifr_map
>> drivers/net/ethernet/smsc/smc91c92_cs.c:447:15: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
447 | smc->base = ioremap(link->resource[2]->start,
| ^
In file included from include/linux/scatterlist.h:9,
from include/linux/dma-mapping.h:11,
from include/linux/skbuff.h:28,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from drivers/net/ethernet/smsc/smc91c92_cs.c:38:
drivers/net/ethernet/smsc/smc91c92_cs.c: In function 'smc91c92_release':
arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
29 | #define iounmap iounmap
| ^~~~~~~
drivers/net/ethernet/smsc/smc91c92_cs.c:962:17: note: in expansion of macro 'iounmap'
962 | iounmap(smc->base);
| ^~~~~~~
cc1: some warnings being treated as errors
--
drivers/net/ethernet/xircom/xirc2ps_cs.c: In function 'xirc2ps_config':
drivers/net/ethernet/xircom/xirc2ps_cs.c:843:28: error: implicit declaration of function 'ioremap'; did you mean 'iounmap'? [-Werror=implicit-function-declaration]
843 | local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
| ^~~~~~~
| iounmap
>> drivers/net/ethernet/xircom/xirc2ps_cs.c:843:26: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
843 | local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
| ^
In file included from include/linux/scatterlist.h:9,
from include/linux/dma-mapping.h:11,
from include/linux/skbuff.h:28,
from include/linux/if_ether.h:19,
from include/linux/ethtool.h:18,
from drivers/net/ethernet/xircom/xirc2ps_cs.c:77:
drivers/net/ethernet/xircom/xirc2ps_cs.c: In function 'xirc2ps_release':
arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
29 | #define iounmap iounmap
| ^~~~~~~
drivers/net/ethernet/xircom/xirc2ps_cs.c:934:25: note: in expansion of macro 'iounmap'
934 | iounmap(local->dingo_ccr - 0x0800);
| ^~~~~~~
cc1: some warnings being treated as errors


vim +447 drivers/net/ethernet/smsc/smc91c92_cs.c

b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 422
fba395eee7d3f3 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2006-03-31 423 static int mhz_mfc_config(struct pcmcia_device *link)
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 424 {
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 425 struct net_device *dev = link->priv;
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 426 struct smc_private *smc = netdev_priv(dev);
b5cb259e7fac55 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-24 427 unsigned int offset;
b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 428 int i;
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 429
00990e7ce0b0e5 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-30 430 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
00990e7ce0b0e5 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-30 431 CONF_AUTO_SET_IO;
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 432
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 433 /* The Megahertz combo cards have modem-like CIS entries, so
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 434 we have to explicitly try a bunch of port combinations. */
b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 435 if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL))
dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 436 return -ENODEV;
dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 437
9a017a910346af drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-24 438 dev->base_addr = link->resource[0]->start;
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 439
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 440 /* Allocate a memory window, for accessing the ISR */
cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 441 link->resource[2]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 442 link->resource[2]->start = link->resource[2]->end = 0;
cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 443 i = pcmcia_request_window(link, link->resource[2], 0);
4c89e88bfde6a3 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-03 444 if (i != 0)
dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 445 return -ENODEV;
dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 446
cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 @447 smc->base = ioremap(link->resource[2]->start,
cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 448 resource_size(link->resource[2]));
7feabb6412ea23 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-29 449 offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 450 i = pcmcia_map_mem_page(link, link->resource[2], offset);
8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 451 if ((i == 0) &&
8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 452 (smc->manfid == MANFID_MEGAHERTZ) &&
8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 453 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 454 mhz_3288_power(link);
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 455
dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 456 return 0;
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 457 }
^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 458

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-06-21 08:57:13

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP

Hi,

On 06/21/23 at 10:15am, kernel test robot wrote:
> Hi Baoquan,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on akpm-mm/mm-everything]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/20230620131356.25440-3-bhe%40redhat.com
> patch subject: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP
> config: hexagon-randconfig-r041-20230620 (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All errors (new ones prefixed by >>):
>
> >> arch/hexagon/kernel/hexagon_ksyms.o: error: local symbol ioremap was exported

I followed steps in your reproduce link, didn't reproduce the error as
above line reported. I can still see those PCI_IOMAP warning, however
they will disappear when rebuilding. The clone3 warning can always ben
seen. I didn't see the symbol ioremap error. Could you double check if
anything missed in steps?

[root@dell-pem620-01 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash
Compiler will be installed in /root/0day
make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=48 W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash
make[1]: Entering directory '/root/linux/build_dir'
GEN Makefile
ld.lld: /lib64/libtinfo.so.6: no version information available (required by ld.lld)
tools/testing/selftests/arm64/tags/.gitignore: warning: ignored by one of the .gitignore files
tools/testing/selftests/arm64/tags/Makefile: warning: ignored by one of the .gitignore files
tools/testing/selftests/arm64/tags/run_tags_test.sh: warning: ignored by one of the .gitignore files
tools/testing/selftests/arm64/tags/tags_test.c: warning: ignored by one of the .gitignore files
tools/testing/selftests/kvm/.gitignore: warning: ignored by one of the .gitignore files
tools/testing/selftests/kvm/Makefile: warning: ignored by one of the .gitignore files
tools/testing/selftests/kvm/config: warning: ignored by one of the .gitignore files
tools/testing/selftests/kvm/settings: warning: ignored by one of the .gitignore files
CALL ../scripts/checksyscalls.sh
clang: /lib64/libtinfo.so.6: no version information available (required by clang)
<stdin>:1519:2: warning: syscall clone3 not implemented [-W#warnings]
1519 | #warning syscall clone3 not implemented
| ^
1 warning generated.
make[1]: Leaving directory '/root/linux/build_dir'
[root@dell-pem620-01 linux]#



2023-06-21 11:06:05

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

Hi,

On 06/21/23 at 01:43pm, kernel test robot wrote:
> Hi Baoquan,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on akpm-mm/mm-everything]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
> patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
> config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> compiler: s390-linux-gcc (GCC) 12.3.0
> reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)

Thanks for reporting this.

I followed steps in above reproduce link, it failed as below. Please
help check if anything is missing.

[root@intel-knightslanding-lb-02 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=s390 olddefconfig
Compiler will be installed in /root/0day
lftpget -c https://download.01.org/0day-ci/cross-package/./gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz
/root/linux
tar Jxf /root/0day/gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz -C /root/0day
Please update: libc6 or glibc
ldd /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc
/root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc: /lib64/libc.so.6: version `GLIBC_2.36' not found (required by /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc)
setup_crosstool failed


>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All error/warnings (new ones prefixed by >>):
>
> drivers/tty/ipwireless/main.c: In function 'ipwireless_probe':
> drivers/tty/ipwireless/main.c:115:30: error: implicit declaration of function 'ioremap'; did you mean 'iounmap'? [-Werror=implicit-function-declaration]
> 115 | ipw->common_memory = ioremap(p_dev->resource[2]->start,
> | ^~~~~~~
> | iounmap
> >> drivers/tty/ipwireless/main.c:115:28: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> 115 | ipw->common_memory = ioremap(p_dev->resource[2]->start,
> | ^
> drivers/tty/ipwireless/main.c:139:26: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> 139 | ipw->attr_memory = ioremap(p_dev->resource[3]->start,
> | ^
> In file included from include/linux/io.h:13,
> from drivers/tty/ipwireless/main.c:26:
> arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
> 29 | #define iounmap iounmap
> | ^~~~~~~
> drivers/tty/ipwireless/main.c:155:9: note: in expansion of macro 'iounmap'
> 155 | iounmap(ipw->attr_memory);
> | ^~~~~~~
> cc1: some warnings being treated as errors
> --
> drivers/net/ethernet/smsc/smc91c92_cs.c: In function 'mhz_mfc_config':
> >> drivers/net/ethernet/smsc/smc91c92_cs.c:447:17: error: implicit declaration of function 'ioremap'; did you mean 'ifr_map'? [-Werror=implicit-function-declaration]
> 447 | smc->base = ioremap(link->resource[2]->start,
> | ^~~~~~~
> | ifr_map
> >> drivers/net/ethernet/smsc/smc91c92_cs.c:447:15: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> 447 | smc->base = ioremap(link->resource[2]->start,
> | ^
> In file included from include/linux/scatterlist.h:9,
> from include/linux/dma-mapping.h:11,
> from include/linux/skbuff.h:28,
> from include/net/net_namespace.h:43,
> from include/linux/netdevice.h:38,
> from drivers/net/ethernet/smsc/smc91c92_cs.c:38:
> drivers/net/ethernet/smsc/smc91c92_cs.c: In function 'smc91c92_release':
> arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
> 29 | #define iounmap iounmap
> | ^~~~~~~
> drivers/net/ethernet/smsc/smc91c92_cs.c:962:17: note: in expansion of macro 'iounmap'
> 962 | iounmap(smc->base);
> | ^~~~~~~
> cc1: some warnings being treated as errors
> --
> drivers/net/ethernet/xircom/xirc2ps_cs.c: In function 'xirc2ps_config':
> drivers/net/ethernet/xircom/xirc2ps_cs.c:843:28: error: implicit declaration of function 'ioremap'; did you mean 'iounmap'? [-Werror=implicit-function-declaration]
> 843 | local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
> | ^~~~~~~
> | iounmap
> >> drivers/net/ethernet/xircom/xirc2ps_cs.c:843:26: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> 843 | local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
> | ^
> In file included from include/linux/scatterlist.h:9,
> from include/linux/dma-mapping.h:11,
> from include/linux/skbuff.h:28,
> from include/linux/if_ether.h:19,
> from include/linux/ethtool.h:18,
> from drivers/net/ethernet/xircom/xirc2ps_cs.c:77:
> drivers/net/ethernet/xircom/xirc2ps_cs.c: In function 'xirc2ps_release':
> arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
> 29 | #define iounmap iounmap
> | ^~~~~~~
> drivers/net/ethernet/xircom/xirc2ps_cs.c:934:25: note: in expansion of macro 'iounmap'
> 934 | iounmap(local->dingo_ccr - 0x0800);
> | ^~~~~~~
> cc1: some warnings being treated as errors
>
>
> vim +447 drivers/net/ethernet/smsc/smc91c92_cs.c
>
> b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 422
> fba395eee7d3f3 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2006-03-31 423 static int mhz_mfc_config(struct pcmcia_device *link)
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 424 {
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 425 struct net_device *dev = link->priv;
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 426 struct smc_private *smc = netdev_priv(dev);
> b5cb259e7fac55 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-24 427 unsigned int offset;
> b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 428 int i;
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 429
> 00990e7ce0b0e5 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-30 430 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
> 00990e7ce0b0e5 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-30 431 CONF_AUTO_SET_IO;
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 432
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 433 /* The Megahertz combo cards have modem-like CIS entries, so
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 434 we have to explicitly try a bunch of port combinations. */
> b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 435 if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL))
> dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 436 return -ENODEV;
> dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 437
> 9a017a910346af drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-24 438 dev->base_addr = link->resource[0]->start;
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 439
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 440 /* Allocate a memory window, for accessing the ISR */
> cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 441 link->resource[2]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
> cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 442 link->resource[2]->start = link->resource[2]->end = 0;
> cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 443 i = pcmcia_request_window(link, link->resource[2], 0);
> 4c89e88bfde6a3 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-03 444 if (i != 0)
> dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 445 return -ENODEV;
> dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 446
> cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 @447 smc->base = ioremap(link->resource[2]->start,
> cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 448 resource_size(link->resource[2]));
> 7feabb6412ea23 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-29 449 offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
> cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 450 i = pcmcia_map_mem_page(link, link->resource[2], offset);
> 8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 451 if ((i == 0) &&
> 8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 452 (smc->manfid == MANFID_MEGAHERTZ) &&
> 8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 453 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 454 mhz_3288_power(link);
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 455
> dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 456 return 0;
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 457 }
> ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 458
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>


2023-06-21 11:14:23

by Alexander Gordeev

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

On Wed, Jun 21, 2023 at 06:41:09PM +0800, Baoquan He wrote:

Hi Baoquan,

> > [auto build test ERROR on akpm-mm/mm-everything]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
> > patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
> > config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> > compiler: s390-linux-gcc (GCC) 12.3.0
> > reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
>
> Thanks for reporting this.
>
> I followed steps in above reproduce link, it failed as below. Please
> help check if anything is missing.

Could it be because you locally have the fix you posted aganst v6?

Thansk!

2023-06-21 14:02:32

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

On 06/21/23 at 12:46pm, Alexander Gordeev wrote:
> On Wed, Jun 21, 2023 at 06:41:09PM +0800, Baoquan He wrote:
>
> Hi Baoquan,
>
> > > [auto build test ERROR on akpm-mm/mm-everything]
> > >
> > > url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > > patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
> > > patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
> > > config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> > > compiler: s390-linux-gcc (GCC) 12.3.0
> > > reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
> >
> > Thanks for reporting this.
> >
> > I followed steps in above reproduce link, it failed as below. Please
> > help check if anything is missing.
>
> Could it be because you locally have the fix you posted aganst v6?

I am not sure. I failed to setup the cross compiling environment
accoridng to steps of lkp. I borrowed a s390x machine, will build with
the config of lkp test robot to see if I can reproduce it.


2023-06-21 19:15:55

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP

On Wed, Jun 21, 2023 at 04:50:53PM +0800, Baoquan He wrote:
> Hi,
>
> On 06/21/23 at 10:15am, kernel test robot wrote:
> > Hi Baoquan,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on akpm-mm/mm-everything]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > patch link: https://lore.kernel.org/r/20230620131356.25440-3-bhe%40redhat.com
> > patch subject: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP
> > config: hexagon-randconfig-r041-20230620 (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> > reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <[email protected]>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> >
> > All errors (new ones prefixed by >>):
> >
> > >> arch/hexagon/kernel/hexagon_ksyms.o: error: local symbol ioremap was exported
>
> I followed steps in your reproduce link, didn't reproduce the error as
> above line reported. I can still see those PCI_IOMAP warning, however
> they will disappear when rebuilding. The clone3 warning can always ben
> seen. I didn't see the symbol ioremap error. Could you double check if
> anything missed in steps?
>
> [root@dell-pem620-01 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash
> Compiler will be installed in /root/0day
> make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=48 W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash
> make[1]: Entering directory '/root/linux/build_dir'
> GEN Makefile
> ld.lld: /lib64/libtinfo.so.6: no version information available (required by ld.lld)

Hmmm, seems like a dynamic linking issue, likely because either libtinfo
is not available or the version on your system is older or newer than
the one that the compiler was built with.

Intel folks, you can opt out of this particular library dependency with
'-DLLVM_ENABLE_TERMINFO=OFF' to cmake, which will make it easier for
others to use it; the compiler can still output color on most terminals
even without libtinfo.

> tools/testing/selftests/arm64/tags/.gitignore: warning: ignored by one of the .gitignore files
> tools/testing/selftests/arm64/tags/Makefile: warning: ignored by one of the .gitignore files
> tools/testing/selftests/arm64/tags/run_tags_test.sh: warning: ignored by one of the .gitignore files
> tools/testing/selftests/arm64/tags/tags_test.c: warning: ignored by one of the .gitignore files
> tools/testing/selftests/kvm/.gitignore: warning: ignored by one of the .gitignore files
> tools/testing/selftests/kvm/Makefile: warning: ignored by one of the .gitignore files
> tools/testing/selftests/kvm/config: warning: ignored by one of the .gitignore files
> tools/testing/selftests/kvm/settings: warning: ignored by one of the .gitignore files
> CALL ../scripts/checksyscalls.sh
> clang: /lib64/libtinfo.so.6: no version information available (required by clang)
> <stdin>:1519:2: warning: syscall clone3 not implemented [-W#warnings]
> 1519 | #warning syscall clone3 not implemented
> | ^
> 1 warning generated.
> make[1]: Leaving directory '/root/linux/build_dir'
> [root@dell-pem620-01 linux]#
>
>

I am able to reproduce this with the kernel.org LLVM builds that I do,
which should not have that library dependency:

https://mirrors.edge.kernel.org/pub/tools/llvm/

$ curl -LSso .config https://download.01.org/0day-ci/archive/20230621/[email protected]/config

$ make -skj"$(nproc)" ARCH=hexagon LLVM=$(realpath llvm-16.0.6-x86_64/bin)/ olddefconfig all
...
make[5]: *** No rule to make target 'arch/hexagon/mm/ioremap.o', needed by 'arch/hexagon/mm/built-in.a'.
...
arch/hexagon/kernel/hexagon_ksyms.o: error: local symbol ioremap was exported
...

The first issue is resolved with:

diff --git a/arch/hexagon/mm/Makefile b/arch/hexagon/mm/Makefile
index 49911a906fd0..ba4b04d962d6 100644
--- a/arch/hexagon/mm/Makefile
+++ b/arch/hexagon/mm/Makefile
@@ -3,5 +3,5 @@
# Makefile for Hexagon memory management subsystem
#

-obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o
+obj-y := init.o uaccess.o vm_fault.o cache.o
obj-y += copy_to_user.o copy_from_user.o vm_tlb.o

For the second issue, it seems that ioremap is exported in
arch/hexagon/kernel/hexagon_ksyms.c but ioremap() is a static inline
function with CONFIG_GENERIC_IOREMAP. I think we can just remove the
ioremap and iounmap exports now, as ioremap() calls ioremap_prot(),
which is exported, and iounmap() is exported in mm/ioremap.c.

diff --git a/arch/hexagon/kernel/hexagon_ksyms.c b/arch/hexagon/kernel/hexagon_ksyms.c
index ec56ce2d92a2..36a80e31d187 100644
--- a/arch/hexagon/kernel/hexagon_ksyms.c
+++ b/arch/hexagon/kernel/hexagon_ksyms.c
@@ -14,12 +14,10 @@
EXPORT_SYMBOL(__clear_user_hexagon);
EXPORT_SYMBOL(raw_copy_from_user);
EXPORT_SYMBOL(raw_copy_to_user);
-EXPORT_SYMBOL(iounmap);
EXPORT_SYMBOL(__vmgetie);
EXPORT_SYMBOL(__vmsetie);
EXPORT_SYMBOL(__vmyield);
EXPORT_SYMBOL(empty_zero_page);
-EXPORT_SYMBOL(ioremap);
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memset);


With those two diffs, the randconfig the robot provides builds and links
without any errors.

Cheers,
Nathan

2023-06-21 19:33:04

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

On Wed, Jun 21, 2023 at 06:41:09PM +0800, Baoquan He wrote:
> Hi,
>
> On 06/21/23 at 01:43pm, kernel test robot wrote:
> > Hi Baoquan,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on akpm-mm/mm-everything]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
> > patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
> > config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> > compiler: s390-linux-gcc (GCC) 12.3.0
> > reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
>
> Thanks for reporting this.
>
> I followed steps in above reproduce link, it failed as below. Please
> help check if anything is missing.
>
> [root@intel-knightslanding-lb-02 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=s390 olddefconfig
> Compiler will be installed in /root/0day
> lftpget -c https://download.01.org/0day-ci/cross-package/./gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz
> /root/linux
> tar Jxf /root/0day/gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz -C /root/0day
> Please update: libc6 or glibc
> ldd /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc
> /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc: /lib64/libc.so.6: version `GLIBC_2.36' not found (required by /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc)
> setup_crosstool failed

Certain recent versions of the kernel.org crosstool toolchains were
built against a pretty recent glibc so attempting to run it on a system
with an older glibc will result in the error above:

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

Arnd resolved this and reuploaded the binaries, I suspect the Intel
folks need to mirror the updated tarballs to 01.org:

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

According to make.cross, you can override the URL it uses with a
variable, you could try removing these files

/root/0day/gcc-12.3.0-nolibc/s390-linux
/root/0day/gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz

and running

$ COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 URL=https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64 ~/bin/make.cross W=1 O=build_dir ARCH=s390 olddefconfig

to see if that works now.

Cheers,
Nathan

> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <[email protected]>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> >
> > All error/warnings (new ones prefixed by >>):
> >
> > drivers/tty/ipwireless/main.c: In function 'ipwireless_probe':
> > drivers/tty/ipwireless/main.c:115:30: error: implicit declaration of function 'ioremap'; did you mean 'iounmap'? [-Werror=implicit-function-declaration]
> > 115 | ipw->common_memory = ioremap(p_dev->resource[2]->start,
> > | ^~~~~~~
> > | iounmap
> > >> drivers/tty/ipwireless/main.c:115:28: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> > 115 | ipw->common_memory = ioremap(p_dev->resource[2]->start,
> > | ^
> > drivers/tty/ipwireless/main.c:139:26: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> > 139 | ipw->attr_memory = ioremap(p_dev->resource[3]->start,
> > | ^
> > In file included from include/linux/io.h:13,
> > from drivers/tty/ipwireless/main.c:26:
> > arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
> > 29 | #define iounmap iounmap
> > | ^~~~~~~
> > drivers/tty/ipwireless/main.c:155:9: note: in expansion of macro 'iounmap'
> > 155 | iounmap(ipw->attr_memory);
> > | ^~~~~~~
> > cc1: some warnings being treated as errors
> > --
> > drivers/net/ethernet/smsc/smc91c92_cs.c: In function 'mhz_mfc_config':
> > >> drivers/net/ethernet/smsc/smc91c92_cs.c:447:17: error: implicit declaration of function 'ioremap'; did you mean 'ifr_map'? [-Werror=implicit-function-declaration]
> > 447 | smc->base = ioremap(link->resource[2]->start,
> > | ^~~~~~~
> > | ifr_map
> > >> drivers/net/ethernet/smsc/smc91c92_cs.c:447:15: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> > 447 | smc->base = ioremap(link->resource[2]->start,
> > | ^
> > In file included from include/linux/scatterlist.h:9,
> > from include/linux/dma-mapping.h:11,
> > from include/linux/skbuff.h:28,
> > from include/net/net_namespace.h:43,
> > from include/linux/netdevice.h:38,
> > from drivers/net/ethernet/smsc/smc91c92_cs.c:38:
> > drivers/net/ethernet/smsc/smc91c92_cs.c: In function 'smc91c92_release':
> > arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
> > 29 | #define iounmap iounmap
> > | ^~~~~~~
> > drivers/net/ethernet/smsc/smc91c92_cs.c:962:17: note: in expansion of macro 'iounmap'
> > 962 | iounmap(smc->base);
> > | ^~~~~~~
> > cc1: some warnings being treated as errors
> > --
> > drivers/net/ethernet/xircom/xirc2ps_cs.c: In function 'xirc2ps_config':
> > drivers/net/ethernet/xircom/xirc2ps_cs.c:843:28: error: implicit declaration of function 'ioremap'; did you mean 'iounmap'? [-Werror=implicit-function-declaration]
> > 843 | local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
> > | ^~~~~~~
> > | iounmap
> > >> drivers/net/ethernet/xircom/xirc2ps_cs.c:843:26: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> > 843 | local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
> > | ^
> > In file included from include/linux/scatterlist.h:9,
> > from include/linux/dma-mapping.h:11,
> > from include/linux/skbuff.h:28,
> > from include/linux/if_ether.h:19,
> > from include/linux/ethtool.h:18,
> > from drivers/net/ethernet/xircom/xirc2ps_cs.c:77:
> > drivers/net/ethernet/xircom/xirc2ps_cs.c: In function 'xirc2ps_release':
> > arch/s390/include/asm/io.h:29:17: error: implicit declaration of function 'iounmap'; did you mean 'vunmap'? [-Werror=implicit-function-declaration]
> > 29 | #define iounmap iounmap
> > | ^~~~~~~
> > drivers/net/ethernet/xircom/xirc2ps_cs.c:934:25: note: in expansion of macro 'iounmap'
> > 934 | iounmap(local->dingo_ccr - 0x0800);
> > | ^~~~~~~
> > cc1: some warnings being treated as errors
> >
> >
> > vim +447 drivers/net/ethernet/smsc/smc91c92_cs.c
> >
> > b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 422
> > fba395eee7d3f3 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2006-03-31 423 static int mhz_mfc_config(struct pcmcia_device *link)
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 424 {
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 425 struct net_device *dev = link->priv;
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 426 struct smc_private *smc = netdev_priv(dev);
> > b5cb259e7fac55 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-24 427 unsigned int offset;
> > b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 428 int i;
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 429
> > 00990e7ce0b0e5 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-30 430 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
> > 00990e7ce0b0e5 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-30 431 CONF_AUTO_SET_IO;
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 432
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 433 /* The Megahertz combo cards have modem-like CIS entries, so
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 434 we have to explicitly try a bunch of port combinations. */
> > b54bf94bf91e4c drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-02 435 if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL))
> > dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 436 return -ENODEV;
> > dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 437
> > 9a017a910346af drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-24 438 dev->base_addr = link->resource[0]->start;
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 439
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 440 /* Allocate a memory window, for accessing the ISR */
> > cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 441 link->resource[2]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
> > cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 442 link->resource[2]->start = link->resource[2]->end = 0;
> > cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 443 i = pcmcia_request_window(link, link->resource[2], 0);
> > 4c89e88bfde6a3 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2008-08-03 444 if (i != 0)
> > dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 445 return -ENODEV;
> > dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 446
> > cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 @447 smc->base = ioremap(link->resource[2]->start,
> > cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 448 resource_size(link->resource[2]));
> > 7feabb6412ea23 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-29 449 offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
> > cdb138080b7814 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2010-07-28 450 i = pcmcia_map_mem_page(link, link->resource[2], offset);
> > 8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 451 if ((i == 0) &&
> > 8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 452 (smc->manfid == MANFID_MEGAHERTZ) &&
> > 8e95a2026f3b43 drivers/net/pcmcia/smc91c92_cs.c Joe Perches 2009-12-03 453 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 454 mhz_3288_power(link);
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 455
> > dddfbd824b96a2 drivers/net/pcmcia/smc91c92_cs.c Dominik Brodowski 2009-10-18 456 return 0;
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 457 }
> > ^1da177e4c3f41 drivers/net/pcmcia/smc91c92_cs.c Linus Torvalds 2005-04-16 458
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
> >
>

2023-06-24 13:03:42

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

On 06/21/23 at 07:21pm, Nathan Chancellor wrote:
> On Wed, Jun 21, 2023 at 06:41:09PM +0800, Baoquan He wrote:
> > Hi,
> >
> > On 06/21/23 at 01:43pm, kernel test robot wrote:
> > > Hi Baoquan,
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > > [auto build test ERROR on akpm-mm/mm-everything]
> > >
> > > url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > > patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
> > > patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
> > > config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> > > compiler: s390-linux-gcc (GCC) 12.3.0
> > > reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
> >
> > Thanks for reporting this.
> >
> > I followed steps in above reproduce link, it failed as below. Please
> > help check if anything is missing.
> >
> > [root@intel-knightslanding-lb-02 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=s390 olddefconfig
> > Compiler will be installed in /root/0day
> > lftpget -c https://download.01.org/0day-ci/cross-package/./gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz
> > /root/linux
> > tar Jxf /root/0day/gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz -C /root/0day
> > Please update: libc6 or glibc
> > ldd /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc
> > /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc: /lib64/libc.so.6: version `GLIBC_2.36' not found (required by /root/0day/gcc-12.3.0-nolibc/s390-linux/bin/s390-linux-gcc)
> > setup_crosstool failed
>
> Certain recent versions of the kernel.org crosstool toolchains were
> built against a pretty recent glibc so attempting to run it on a system
> with an older glibc will result in the error above:
>
> https://lore.kernel.org/[email protected]/
>
> Arnd resolved this and reuploaded the binaries, I suspect the Intel
> folks need to mirror the updated tarballs to 01.org:
>
> https://lore.kernel.org/[email protected]/
>
> According to make.cross, you can override the URL it uses with a
> variable, you could try removing these files
>
> /root/0day/gcc-12.3.0-nolibc/s390-linux
> /root/0day/gcc-12.3.0-nolibc/x86_64-gcc-12.3.0-nolibc_s390-linux.tar.xz
>
> and running
>
> $ COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 URL=https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64 ~/bin/make.cross W=1 O=build_dir ARCH=s390 olddefconfig
>
> to see if that works now.

Thanks a lot for your help, Nathan. Really appreciated.

Above make olddefconfig command works well, however the building failed
either becuase of lack of gmp.h. I am not familiar with the manipulation
of lkp building, so I gave up after attempt.

======
I finally got a s390x kvm guest from redhat lab, fetched the config file
lkp provided and build, I can reproduce those errors and more similar
errors are catched.

CONFIG_MMU=y
# CONFIG_PCI is not set

From investigation, I see the lkp config enabled MMU, but disabled PCI.
So those drivers which call ioremap()/iounmap() or their devm_xxxx
wrappers will fail building because s390's iomem operations rely on
pci support enabling. So I just change to make these drivers depend on
HAS_IOMEM so that it won't be built. The draft change is pasted at
below.

Hi Niklas,

I remember you ever entioned you would work out patches to solve those
those drivers relying on devm_xxx(), not sure if they are related to the
compiling error I met here. If I said the right thing, do you have plan
to post them? If what you ever said is different thing, or do you have
suggestion for below change, should I post them like this or need some
adjustment? Look forward to your comments, thanks in advance.

diff --git a/drivers/char/xillybus/Kconfig b/drivers/char/xillybus/Kconfig
index a8036dad437e..f51d533390a9 100644
--- a/drivers/char/xillybus/Kconfig
+++ b/drivers/char/xillybus/Kconfig
@@ -29,7 +29,7 @@ config XILLYBUS_PCIE

config XILLYBUS_OF
tristate "Xillybus over Device Tree"
- depends on OF && HAS_DMA
+ depends on OF && HAS_DMA && HAS_IOMEM
help
Set to M if you want Xillybus to find its resources from the
Open Firmware Flattened Device Tree. If the target is an embedded
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 016814e15536..52dfbae4f361 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -444,6 +444,7 @@ config COMMON_CLK_BD718XX
config COMMON_CLK_FIXED_MMIO
bool "Clock driver for Memory Mapped Fixed values"
depends on COMMON_CLK && OF
+ depends on HAS_IOMEM
help
Support for Memory Mapped IO Fixed clocks

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index f5f422f9b850..b6221b4432fd 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -211,6 +211,7 @@ config FSL_DMA
config FSL_EDMA
tristate "Freescale eDMA engine support"
depends on OF
+ depends on HAS_IOMEM
select DMA_ENGINE
select DMA_VIRTUAL_CHANNELS
help
@@ -280,6 +281,7 @@ config IMX_SDMA

config INTEL_IDMA64
tristate "Intel integrated DMA 64-bit support"
+ depends on HAS_IOMEM
select DMA_ENGINE
select DMA_VIRTUAL_CHANNELS
help
diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig
index 3f926a653bd8..ace75d7b835a 100644
--- a/drivers/dma/qcom/Kconfig
+++ b/drivers/dma/qcom/Kconfig
@@ -45,6 +45,7 @@ config QCOM_HIDMA_MGMT

config QCOM_HIDMA
tristate "Qualcomm Technologies HIDMA Channel support"
+ depends on HAS_IOMEM
select DMA_ENGINE
help
Enable support for the Qualcomm Technologies HIDMA controller.
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 09e422da482f..4b9036c6d45b 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -89,6 +89,7 @@ config ALPINE_MSI
config AL_FIC
bool "Amazon's Annapurna Labs Fabric Interrupt Controller"
depends on OF
+ depends on HAS_IOMEM
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
help
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 433aa4197785..1d2b176a0594 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -496,6 +496,7 @@ config HISI_HIKEY_USB
config OPEN_DICE
tristate "Open Profile for DICE driver"
depends on OF_RESERVED_MEM
+ depends on HAS_IOMEM
help
This driver exposes a DICE reserved memory region to userspace via
a character device. The memory region contains Compound Device
diff --git a/drivers/net/ethernet/altera/Kconfig b/drivers/net/ethernet/altera/Kconfig
index dd7fd41ccde5..33927fdfff28 100644
--- a/drivers/net/ethernet/altera/Kconfig
+++ b/drivers/net/ethernet/altera/Kconfig
@@ -2,6 +2,7 @@
config ALTERA_TSE
tristate "Altera Triple-Speed Ethernet MAC support"
depends on HAS_DMA
+ depends on HAS_IOMEM
select PHYLIB
select PHYLINK
select PCS_ALTERA_TSE
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index e40f10bf2ba4..da9826accb1b 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -55,7 +55,7 @@ config OF_FLATTREE

config OF_EARLY_FLATTREE
bool
- select DMA_DECLARE_COHERENT if HAS_DMA
+ select DMA_DECLARE_COHERENT if HAS_DMA && HAS_IOMEM
select OF_FLATTREE

config OF_PROMTREE


2023-06-25 01:51:11

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP

On 06/21/23 at 07:08pm, Nathan Chancellor wrote:
> On Wed, Jun 21, 2023 at 04:50:53PM +0800, Baoquan He wrote:
> > Hi,
> >
> > On 06/21/23 at 10:15am, kernel test robot wrote:
> > > Hi Baoquan,
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > > [auto build test ERROR on akpm-mm/mm-everything]
> > >
> > > url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > > patch link: https://lore.kernel.org/r/20230620131356.25440-3-bhe%40redhat.com
> > > patch subject: [PATCH v7 02/19] hexagon: mm: Convert to GENERIC_IOREMAP
> > > config: hexagon-randconfig-r041-20230620 (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)
> > > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> > > reproduce: (https://download.01.org/0day-ci/archive/20230621/[email protected]/reproduce)
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <[email protected]>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > > >> arch/hexagon/kernel/hexagon_ksyms.o: error: local symbol ioremap was exported
> >
> > I followed steps in your reproduce link, didn't reproduce the error as
> > above line reported. I can still see those PCI_IOMAP warning, however
> > they will disappear when rebuilding. The clone3 warning can always ben
> > seen. I didn't see the symbol ioremap error. Could you double check if
> > anything missed in steps?
> >
> > [root@dell-pem620-01 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash
> > Compiler will be installed in /root/0day
> > make --keep-going LLVM=1 CROSS_COMPILE=hexagon-linux- LLVM_IAS=1 --jobs=48 W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash
> > make[1]: Entering directory '/root/linux/build_dir'
> > GEN Makefile
> > ld.lld: /lib64/libtinfo.so.6: no version information available (required by ld.lld)
>
> Hmmm, seems like a dynamic linking issue, likely because either libtinfo
> is not available or the version on your system is older or newer than
> the one that the compiler was built with.
>
> Intel folks, you can opt out of this particular library dependency with
> '-DLLVM_ENABLE_TERMINFO=OFF' to cmake, which will make it easier for
> others to use it; the compiler can still output color on most terminals
> even without libtinfo.
>
> > tools/testing/selftests/arm64/tags/.gitignore: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/arm64/tags/Makefile: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/arm64/tags/run_tags_test.sh: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/arm64/tags/tags_test.c: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/kvm/.gitignore: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/kvm/Makefile: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/kvm/config: warning: ignored by one of the .gitignore files
> > tools/testing/selftests/kvm/settings: warning: ignored by one of the .gitignore files
> > CALL ../scripts/checksyscalls.sh
> > clang: /lib64/libtinfo.so.6: no version information available (required by clang)
> > <stdin>:1519:2: warning: syscall clone3 not implemented [-W#warnings]
> > 1519 | #warning syscall clone3 not implemented
> > | ^
> > 1 warning generated.
> > make[1]: Leaving directory '/root/linux/build_dir'
> > [root@dell-pem620-01 linux]#
> >
> >
>
> I am able to reproduce this with the kernel.org LLVM builds that I do,
> which should not have that library dependency:
>
> https://mirrors.edge.kernel.org/pub/tools/llvm/
>
> $ curl -LSso .config https://download.01.org/0day-ci/archive/20230621/[email protected]/config
>
> $ make -skj"$(nproc)" ARCH=hexagon LLVM=$(realpath llvm-16.0.6-x86_64/bin)/ olddefconfig all
> ...
> make[5]: *** No rule to make target 'arch/hexagon/mm/ioremap.o', needed by 'arch/hexagon/mm/built-in.a'.
> ...
> arch/hexagon/kernel/hexagon_ksyms.o: error: local symbol ioremap was exported
> ...
>
> The first issue is resolved with:
>
> diff --git a/arch/hexagon/mm/Makefile b/arch/hexagon/mm/Makefile
> index 49911a906fd0..ba4b04d962d6 100644
> --- a/arch/hexagon/mm/Makefile
> +++ b/arch/hexagon/mm/Makefile
> @@ -3,5 +3,5 @@
> # Makefile for Hexagon memory management subsystem
> #
>
> -obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o
> +obj-y := init.o uaccess.o vm_fault.o cache.o
> obj-y += copy_to_user.o copy_from_user.o vm_tlb.o

Ah, right, arch/hexagon/mm/ioremap.c is removed, I forgot change that in
Makefile. Thanks.

>
> For the second issue, it seems that ioremap is exported in
> arch/hexagon/kernel/hexagon_ksyms.c but ioremap() is a static inline
> function with CONFIG_GENERIC_IOREMAP. I think we can just remove the
> ioremap and iounmap exports now, as ioremap() calls ioremap_prot(),
> which is exported, and iounmap() is exported in mm/ioremap.c.
>
> diff --git a/arch/hexagon/kernel/hexagon_ksyms.c b/arch/hexagon/kernel/hexagon_ksyms.c
> index ec56ce2d92a2..36a80e31d187 100644
> --- a/arch/hexagon/kernel/hexagon_ksyms.c
> +++ b/arch/hexagon/kernel/hexagon_ksyms.c
> @@ -14,12 +14,10 @@
> EXPORT_SYMBOL(__clear_user_hexagon);
> EXPORT_SYMBOL(raw_copy_from_user);
> EXPORT_SYMBOL(raw_copy_to_user);
> -EXPORT_SYMBOL(iounmap);
> EXPORT_SYMBOL(__vmgetie);
> EXPORT_SYMBOL(__vmsetie);
> EXPORT_SYMBOL(__vmyield);
> EXPORT_SYMBOL(empty_zero_page);
> -EXPORT_SYMBOL(ioremap);
> EXPORT_SYMBOL(memcpy);
> EXPORT_SYMBOL(memset);
>
>
> With those two diffs, the randconfig the robot provides builds and links
> without any errors.

Thanks a lot, I will add this into patch 02/19 of v8 post.


2023-07-06 16:15:33

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP

Hi,

On 06/21/23 at 01:43pm, kernel test robot wrote:
> Hi Baoquan,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on akpm-mm/mm-everything]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/asm-generic-iomap-h-remove-ARCH_HAS_IOREMAP_xx-macros/20230620-212135
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/20230620131356.25440-11-bhe%40redhat.com
> patch subject: [PATCH v7 10/19] s390: mm: Convert to GENERIC_IOREMAP
> config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230621/[email protected]/config)

I can confirm these reproted errors have nothing to do with my patch. I
got a s390 system and build the latest kernel from linus's master branch
with above config, all these failures have been existing there. I have
made patches to fix them by adding dependency on HAS_IOMEM for drivers.

I would suggest lkp adjusts script to test the base firstly so that a
reliable base is provided to avoid confusion.

Thanks
Baoquan


2023-07-08 01:05:23

by Stafford Horne

[permalink] [raw]
Subject: Re: [PATCH v7 09/19] openrisc: mm: Convert to GENERIC_IOREMAP

On Tue, Jun 20, 2023 at 09:13:46PM +0800, Baoquan He wrote:
> By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
> generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
> and iounmap() are all visible and available to arch. Arch needs to
> provide wrapper functions to override the generic versions if there's
> arch specific handling in its ioremap_prot(), ioremap() or iounmap().
> This change will simplify implementation by removing duplicated codes
> with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
> functioality as before.
>
> For openrisc, the current ioremap() and iounmap() are the same as
> generic version. After taking GENERIC_IOREMAP way, the old ioremap()
> and iounmap() can be completely removed.
>
> Signed-off-by: Baoquan He <[email protected]>
> Reviewed-by: Christoph Hellwig <[email protected]>
> Reviewed-by: Mike Rapoport (IBM) <[email protected]>
> Cc: Stafford Horne <[email protected]>
> Cc: Jonas Bonn <[email protected]>
> Cc: Stefan Kristiansson <[email protected]>
> Cc: [email protected]
> ---
> arch/openrisc/Kconfig | 1 +
> arch/openrisc/include/asm/io.h | 11 ++++----
> arch/openrisc/mm/ioremap.c | 49 ----------------------------------
> 3 files changed, 7 insertions(+), 54 deletions(-)
>
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index c7f282f60f64..fd9bb76a610b 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -21,6 +21,7 @@ config OPENRISC
> select GENERIC_IRQ_PROBE
> select GENERIC_IRQ_SHOW
> select GENERIC_PCI_IOMAP
> + select GENERIC_IOREMAP
> select GENERIC_CPU_DEVICES
> select HAVE_PCI
> select HAVE_UID16
> diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h
> index ee6043a03173..5a6f0f16a5ce 100644
> --- a/arch/openrisc/include/asm/io.h
> +++ b/arch/openrisc/include/asm/io.h
> @@ -15,6 +15,8 @@
> #define __ASM_OPENRISC_IO_H
>
> #include <linux/types.h>
> +#include <asm/pgalloc.h>
> +#include <asm/pgtable.h>
>
> /*
> * PCI: We do not use IO ports in OpenRISC
> @@ -27,11 +29,10 @@
> #define PIO_OFFSET 0
> #define PIO_MASK 0
>
> -#define ioremap ioremap
> -void __iomem *ioremap(phys_addr_t offset, unsigned long size);
> -
> -#define iounmap iounmap
> -extern void iounmap(volatile void __iomem *addr);
> +/*
> + * I/O memory mapping functions.
> + */
> +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI)
>
> #include <asm-generic/io.h>
>
> diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c
> index cdbcc7e73684..91c8259d4b7e 100644
> --- a/arch/openrisc/mm/ioremap.c
> +++ b/arch/openrisc/mm/ioremap.c
> @@ -22,55 +22,6 @@
>
> extern int mem_init_done;
>
> -/*
> - * Remap an arbitrary physical address space into the kernel virtual
> - * address space. Needed when the kernel wants to access high addresses
> - * directly.
> - *
> - * NOTE! We need to allow non-page-aligned mappings too: we will obviously
> - * have to convert them into an offset in a page-aligned mapping, but the
> - * caller shouldn't need to know that small detail.
> - */
> -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size)
> -{
> - phys_addr_t p;
> - unsigned long v;
> - unsigned long offset, last_addr;
> - struct vm_struct *area = NULL;
> -
> - /* Don't allow wraparound or zero size */
> - last_addr = addr + size - 1;
> - if (!size || last_addr < addr)
> - return NULL;
> -
> - /*
> - * Mappings have to be page-aligned
> - */
> - offset = addr & ~PAGE_MASK;
> - p = addr & PAGE_MASK;
> - size = PAGE_ALIGN(last_addr + 1) - p;
> -
> - area = get_vm_area(size, VM_IOREMAP);
> - if (!area)
> - return NULL;
> - v = (unsigned long)area->addr;
> -
> - if (ioremap_page_range(v, v + size, p,
> - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) {
> - vfree(area->addr);
> - return NULL;
> - }
> -
> - return (void __iomem *)(offset + (char *)v);
> -}
> -EXPORT_SYMBOL(ioremap);
> -
> -void iounmap(volatile void __iomem *addr)
> -{
> - return vfree((void *)(PAGE_MASK & (unsigned long)addr));
> -}
> -EXPORT_SYMBOL(iounmap);
> -

Hello,

Thanks for the patch, I was able to test this booting openrisc and running a few
glibc tests and see no issues. Also the code cleanup looks good to me.

Acked-by: Stafford Horne <[email protected]>

> /**
> * OK, this one's a bit tricky... ioremap can get called before memory is
> * initialized (early serial console does this) and will want to alloc a page
> --
> 2.34.1
>

2023-07-09 11:33:52

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH v7 09/19] openrisc: mm: Convert to GENERIC_IOREMAP

On 07/08/23 at 01:33am, Stafford Horne wrote:
> On Tue, Jun 20, 2023 at 09:13:46PM +0800, Baoquan He wrote:
> > By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
> > generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
> > and iounmap() are all visible and available to arch. Arch needs to
> > provide wrapper functions to override the generic versions if there's
> > arch specific handling in its ioremap_prot(), ioremap() or iounmap().
> > This change will simplify implementation by removing duplicated codes
> > with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
> > functioality as before.
> >
> > For openrisc, the current ioremap() and iounmap() are the same as
> > generic version. After taking GENERIC_IOREMAP way, the old ioremap()
> > and iounmap() can be completely removed.
> >
> > Signed-off-by: Baoquan He <[email protected]>
> > Reviewed-by: Christoph Hellwig <[email protected]>
> > Reviewed-by: Mike Rapoport (IBM) <[email protected]>
> > Cc: Stafford Horne <[email protected]>
> > Cc: Jonas Bonn <[email protected]>
> > Cc: Stefan Kristiansson <[email protected]>
> > Cc: [email protected]
> > ---
> > arch/openrisc/Kconfig | 1 +
> > arch/openrisc/include/asm/io.h | 11 ++++----
> > arch/openrisc/mm/ioremap.c | 49 ----------------------------------
> > 3 files changed, 7 insertions(+), 54 deletions(-)
> >
> > diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> > index c7f282f60f64..fd9bb76a610b 100644
> > --- a/arch/openrisc/Kconfig
> > +++ b/arch/openrisc/Kconfig
> > @@ -21,6 +21,7 @@ config OPENRISC
> > select GENERIC_IRQ_PROBE
> > select GENERIC_IRQ_SHOW
> > select GENERIC_PCI_IOMAP
> > + select GENERIC_IOREMAP
> > select GENERIC_CPU_DEVICES
> > select HAVE_PCI
> > select HAVE_UID16
> > diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h
> > index ee6043a03173..5a6f0f16a5ce 100644
> > --- a/arch/openrisc/include/asm/io.h
> > +++ b/arch/openrisc/include/asm/io.h
> > @@ -15,6 +15,8 @@
> > #define __ASM_OPENRISC_IO_H
> >
> > #include <linux/types.h>
> > +#include <asm/pgalloc.h>
> > +#include <asm/pgtable.h>
> >
> > /*
> > * PCI: We do not use IO ports in OpenRISC
> > @@ -27,11 +29,10 @@
> > #define PIO_OFFSET 0
> > #define PIO_MASK 0
> >
> > -#define ioremap ioremap
> > -void __iomem *ioremap(phys_addr_t offset, unsigned long size);
> > -
> > -#define iounmap iounmap
> > -extern void iounmap(volatile void __iomem *addr);
> > +/*
> > + * I/O memory mapping functions.
> > + */
> > +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI)
> >
> > #include <asm-generic/io.h>
> >
> > diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c
> > index cdbcc7e73684..91c8259d4b7e 100644
> > --- a/arch/openrisc/mm/ioremap.c
> > +++ b/arch/openrisc/mm/ioremap.c
> > @@ -22,55 +22,6 @@
> >
> > extern int mem_init_done;
> >
> > -/*
> > - * Remap an arbitrary physical address space into the kernel virtual
> > - * address space. Needed when the kernel wants to access high addresses
> > - * directly.
> > - *
> > - * NOTE! We need to allow non-page-aligned mappings too: we will obviously
> > - * have to convert them into an offset in a page-aligned mapping, but the
> > - * caller shouldn't need to know that small detail.
> > - */
> > -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size)
> > -{
> > - phys_addr_t p;
> > - unsigned long v;
> > - unsigned long offset, last_addr;
> > - struct vm_struct *area = NULL;
> > -
> > - /* Don't allow wraparound or zero size */
> > - last_addr = addr + size - 1;
> > - if (!size || last_addr < addr)
> > - return NULL;
> > -
> > - /*
> > - * Mappings have to be page-aligned
> > - */
> > - offset = addr & ~PAGE_MASK;
> > - p = addr & PAGE_MASK;
> > - size = PAGE_ALIGN(last_addr + 1) - p;
> > -
> > - area = get_vm_area(size, VM_IOREMAP);
> > - if (!area)
> > - return NULL;
> > - v = (unsigned long)area->addr;
> > -
> > - if (ioremap_page_range(v, v + size, p,
> > - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) {
> > - vfree(area->addr);
> > - return NULL;
> > - }
> > -
> > - return (void __iomem *)(offset + (char *)v);
> > -}
> > -EXPORT_SYMBOL(ioremap);
> > -
> > -void iounmap(volatile void __iomem *addr)
> > -{
> > - return vfree((void *)(PAGE_MASK & (unsigned long)addr));
> > -}
> > -EXPORT_SYMBOL(iounmap);
> > -
>
> Hello,
>
> Thanks for the patch, I was able to test this booting openrisc and running a few
> glibc tests and see no issues. Also the code cleanup looks good to me.
>
> Acked-by: Stafford Horne <[email protected]>

Thanks a lot, Stafford.

I later posted v8 to add update for hexagon and s390, this is the link:
https://lore.kernel.org/all/[email protected]/T/#u

Thanks