mm: ioremap: Convert architectures to take GENERIC_IOREMAP way
Subsystems (21)
v5 cover mm: ioremap: Convert architectures to take GENERIC_IOREMAP way
This resends v5 series based on the latest linus's master branch. There are conflicts:
- on patch 1 ("asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros")
because of commit 7b76ab837522fd ("MIPS: Loongson64: Opt-out war_io_reorder_wmb"):
in arch/mips/include/asm/io.h - on patch 11 ("sh: mm: Convert to GENERIC_IOREMAP") because of
commit fcbfe8121a45 ("Kconfig: introduce HAS_IOPORT option and select it as necessary"):
in arch/sh/Kconfig.
Other than above two conflicts and resolving, no other change. I have tried cross compiling mips64 and superH specifically, both passed. And building and running on arm64 bare metal machine, passed too.
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:
========
Old v4 has done below test. In v5, patch 1 is newly added to remove ARCH_HAS_IOREMAP_xx, and patch 13 ("parisc: mm: Convert to GENERIC_IOREMAP") is impacted, so I only built related x86_64, m68K, mips64, ppc64le, parisc and all passed.
------Old v4 testing
- It's running well on arm64, s390x, ppc64le with this patchset applied
on the latest upstream kernel 6.2-rc8+.
- Cross compiling passed on arc, ia64, parisc, sh, xtensa.
- cross compiling is not tried on hexagon, openrisc and powerpc 32bit
because:
- Didn't find cross compiling tools for hexagon, ppc 32bit;
- there's error with openrisc compiling, while I have no idea how to
fix it. Please see below pasted log:
---------------------------------------------------------------------
[root@intel-knightslanding-lb-02 linux]# make ARCH=openrisc defconfig
*** Default configuration is based on 'or1ksim_defconfig'
#
# configuration written to .config
#
[root@intel-knightslanding-lb-02 linux]# make ARCH=openrisc -j320 CROSS_COMPILE=/usr/bin/openrisc-linux-gnu-
SYNC include/config/auto.conf.cmd
CC scripts/mod/empty.o
./scripts/check-local-export: /usr/bin/openrisc-linux-gnu-nm failed
make[1]: *** [scripts/Makefile.build:250: scripts/mod/empty.o] Error 1
make[1]: *** Deleting file 'scripts/mod/empty.o'
make: *** [Makefile:1275: prepare0] Error 2
----------------------------------------------------------------------
History:
=======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 (14):
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: mm: Convert to GENERIC_IOREMAP
xtensa: mm: Convert to GENERIC_IOREMAP
parisc: mm: Convert to GENERIC_IOREMAP
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 | 9 +++- 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 | 58 +------------------------ 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/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/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 +-- mm/ioremap.c | 41 ++++++++++++------ 42 files changed, 220 insertions(+), 588 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c
Signature · 1 line
2.34.1
PATCH RESEND v5 1/17 asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros
Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead.
For each architecture to remove defined ARCH_HAS_IOREMAP_xx macros in To remove defined ARCH_HAS_IOREMAP_xx macros in <asm/io.h> of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include <asm-generic/iomap.h>. Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error:
loongarch:
- doesn't include <asm-generic/iomap.h>, defining ARCH_HAS_IOREMAP_WC is redundant, so simply remove it.
m68k:
- selected GENERIC_IOMAP, <asm-generic/iomap.h> has been added in <asm-generic/io.h>, and <asm/kmap.h> is included above <asm-generic/iomap.h>, so simply remove ARCH_HAS_IOREMAP_WT defining.
mips:
- move "#include <asm-generic/iomap.h>" below ioremap_wc definition
in <asm/io.h>
powerpc:
- remove "#include <asm-generic/iomap.h>" in <asm/io.h> because it's duplicated with the one in <asm-generic/io.h>, let's rely on the latter.
x86:
- selected GENERIC_IOMAP, remove #include <asm-generic/iomap.h> in the middle of <asm/io.h>. Let's rely on <asm-generic/io.h>.
--- 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/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-)
arch/loongarch/include/asm/io.h +0 -2
@@ -5,8 +5,6 @@#ifndef _ASM_IO_H#define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC -#include <linux/kernel.h> #include <linux/types.h>
arch/m68k/include/asm/io_mm.h +0 -2
@@ -26,8 +26,6 @@#include <asm/virtconvert.h> #include <asm/kmap.h> -#include <asm-generic/iomap.h> -#ifdef CONFIG_ATARI #define atari_readb raw_inb#define atari_writeb raw_outb
arch/m68k/include/asm/kmap.h +0 -2
@@ -4,8 +4,6 @@#ifdef CONFIG_MMU -#define ARCH_HAS_IOREMAP_WT -/* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0#define IOMAP_NOCACHE_SER 1
arch/mips/include/asm/io.h +2 -3
@@ -12,8 +12,6 @@#ifndef _ASM_IO_H#define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC -#include <linux/compiler.h> #include <linux/kernel.h> #include <linux/types.h>
@@ -25,7 +23,6 @@#include <asm/byteorder.h> #include <asm/cpu.h> #include <asm/cpu-features.h> -#include <asm-generic/iomap.h> #include <asm/page.h> #include <asm/pgtable-bits.h> #include <asm/processor.h>
@@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr);#define ioremap_wc (offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include <asm-generic/iomap.h> +#if defined(CONFIG_CPU_CAVIUM_OCTEON )#define war_io_reorder_wmb () wmb()#else
arch/powerpc/include/asm/io.h +1 -8
@@ -3,11 +3,6 @@#define _ASM_POWERPC_IO_H#ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif -/* */
@@ -732,9 +727,7 @@ static inline void name at \#define writel_relaxed (v, addr) writel(v, addr)#define writeq_relaxed (v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include <asm-generic/iomap.h> -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */
arch/x86/include/asm/io.h +0 -5
@@ -35,9 +35,6 @@* - Arnaldo Carvalho de Melo <[email protected]> */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT -#include <linux/string.h> #include <linux/compiler.h> #include <linux/cc_platform.h>
@@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t);#define memcpy_toio memcpy_toio#define memset_io memset_io -#include <asm-generic/iomap.h> -/* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped
drivers/net/ethernet/sfc/io.h +1 -1
@@ -70,7 +70,7 @@*/ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc#define EFX_USE_PIO 1#endif #endif
drivers/net/ethernet/sfc/siena/io.h +1 -1
@@ -70,7 +70,7 @@*/ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc#define EFX_USE_PIO 1#endif #endif
include/asm-generic/iomap.h +3 -3
@@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr);extern void ioport_unmap (void __iomem *);#endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc#define ioremap_wc ioremap#endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt#define ioremap_wt ioremap#endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np/* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_npstatic inline void __iomem *ioremap_np (phys_addr_t offset,size_t size)
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 01/17] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros
Hi,
Quoted 3 lines · Baoquan He
Let's use '#define
ioremap_xx' and "#ifdefioremap_xx" instead.For each architecture to remove defined
ARCH_HAS_IOREMAP_xxmacros in
This sentence seems to be stale.
Quoted 28 lines
To remove defined
ARCH_HAS_IOREMAP_xxmacros in <asm/io.h> of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include <asm-generic/iomap.h>. Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error:loongarch:
- doesn't include <asm-generic/iomap.h>, definingARCH_HAS_IOREMAP_WCis redundant, so simply remove it.m68k:
- selectedGENERIC_IOMAP, <asm-generic/iomap.h> has been added in <asm-generic/io.h>, and <asm/kmap.h> is included above <asm-generic/iomap.h>, so simply removeARCH_HAS_IOREMAP_WTdefining.mips:
- move "#include <asm-generic/iomap.h>" belowioremap_wcdefinitionin <asm/io.h>powerpc:
- remove "#include <asm-generic/iomap.h>" in <asm/io.h> because it's duplicated with the one in <asm-generic/io.h>, let's rely on the latter.x86:
- selectedGENERIC_IOMAP, remove #include <asm-generic/iomap.h> in the middle of <asm/io.h>. Let's rely on <asm-generic/io.h>.
Quoted 8 lines
Quoted 184 lines
--- 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/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-)arch/loongarch/include/asm/io.h +0
-2@@ -5,8 +5,6 @@#ifndef _ASM_IO_H#define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC -#include <linux/kernel.h> #include <linux/types.h> arch/m68k/include/asm/io_mm.h +0
-2@@ -26,8 +26,6 @@#include <asm/virtconvert.h> #include <asm/kmap.h> -#include <asm-generic/iomap.h> -#ifdef CONFIG_ATARI #define atari_readb raw_inb#define atari_writeb raw_outbarch/m68k/include/asm/kmap.h +0
-2@@ -4,8 +4,6 @@#ifdef CONFIG_MMU -#define ARCH_HAS_IOREMAP_WT -/* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0#define IOMAP_NOCACHE_SER 1arch/mips/include/asm/io.h +2
-3@@ -12,8 +12,6 @@#ifndef _ASM_IO_H#define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC -#include <linux/compiler.h> #include <linux/kernel.h> #include <linux/types.h> @@ -25,7 +23,6 @@#include <asm/byteorder.h> #include <asm/cpu.h> #include <asm/cpu-features.h> -#include <asm-generic/iomap.h> #include <asm/page.h> #include <asm/pgtable-bits.h> #include <asm/processor.h> @@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr);#define ioremap_wc (offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include <asm-generic/iomap.h> +#if defined(CONFIG_CPU_CAVIUM_OCTEON )#define war_io_reorder_wmb () wmb()#else arch/powerpc/include/asm/io.h +1
-8@@ -3,11 +3,6 @@#define _ASM_POWERPC_IO_H#ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif -/* */ @@ -732,9 +727,7 @@ static inline void name at \#define writel_relaxed (v, addr) writel(v, addr)#define writeq_relaxed (v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include <asm-generic/iomap.h> -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */ arch/x86/include/asm/io.h +0
-5@@ -35,9 +35,6 @@* - Arnaldo Carvalho de Melo <[email protected]> */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT -#include <linux/string.h> #include <linux/compiler.h> #include <linux/cc_platform.h> @@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t);#define memcpy_toio memcpy_toio#define memset_io memset_io -#include <asm-generic/iomap.h> -/* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped drivers/net/ethernet/sfc/io.h +1
-1@@ -70,7 +70,7 @@*/ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc#define EFX_USE_PIO 1#endif #endif drivers/net/ethernet/sfc/siena/io.h +1
-1@@ -70,7 +70,7 @@*/ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc#define EFX_USE_PIO 1#endif #endif include/asm-generic/iomap.h +3
-3@@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr);extern void ioport_unmap (void __iomem *);#endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc#define ioremap_wc ioremap#endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt#define ioremap_wt ioremap#endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np/* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_npstatic inline void __iomem *ioremap_np (phys_addr_t offset,size_t size)Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 01/17] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros
Quoted 8 lines · Mike Rapoport
Hi,
Quoted 3 lines · Baoquan He
Let's use '#define
ioremap_xx' and "#ifdefioremap_xx" instead.For each architecture to remove defined
ARCH_HAS_IOREMAP_xxmacros inThis sentence seems to be stale.
Right, will remove this, thanks a lot for careful reviewing.
Quoted 229 lines
Quoted 29 lines
To remove defined
ARCH_HAS_IOREMAP_xxmacros in <asm/io.h> of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include <asm-generic/iomap.h>. Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error:loongarch:
- doesn't include <asm-generic/iomap.h>, definingARCH_HAS_IOREMAP_WCis redundant, so simply remove it.m68k:
- selectedGENERIC_IOMAP, <asm-generic/iomap.h> has been added in <asm-generic/io.h>, and <asm/kmap.h> is included above <asm-generic/iomap.h>, so simply removeARCH_HAS_IOREMAP_WTdefining.mips:
- move "#include <asm-generic/iomap.h>" belowioremap_wcdefinitionin <asm/io.h>powerpc:
- remove "#include <asm-generic/iomap.h>" in <asm/io.h> because it's duplicated with the one in <asm-generic/io.h>, let's rely on the latter.x86:
- selectedGENERIC_IOMAP, remove #include <asm-generic/iomap.h> in the middle of <asm/io.h>. Let's rely on <asm-generic/io.h>.Quoted 8 lines
Reviewed-by Mike Rapoport (IBM) <[email protected]>Quoted 184 lines
--- 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/powerpc/include/asm/io.h | 9 +-------- arch/x86/include/asm/io.h | 5 ----- drivers/net/ethernet/sfc/io.h | 2 +- drivers/net/ethernet/sfc/siena/io.h | 2 +- include/asm-generic/iomap.h | 6 +++--- 9 files changed, 8 insertions(+), 27 deletions(-)arch/loongarch/include/asm/io.h +0
-2@@ -5,8 +5,6 @@#ifndef _ASM_IO_H#define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC -#include <linux/kernel.h> #include <linux/types.h> arch/m68k/include/asm/io_mm.h +0
-2@@ -26,8 +26,6 @@#include <asm/virtconvert.h> #include <asm/kmap.h> -#include <asm-generic/iomap.h> -#ifdef CONFIG_ATARI #define atari_readb raw_inb#define atari_writeb raw_outbarch/m68k/include/asm/kmap.h +0
-2@@ -4,8 +4,6 @@#ifdef CONFIG_MMU -#define ARCH_HAS_IOREMAP_WT -/* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0#define IOMAP_NOCACHE_SER 1arch/mips/include/asm/io.h +2
-3@@ -12,8 +12,6 @@#ifndef _ASM_IO_H#define _ASM_IO_H -#define ARCH_HAS_IOREMAP_WC -#include <linux/compiler.h> #include <linux/kernel.h> #include <linux/types.h> @@ -25,7 +23,6 @@#include <asm/byteorder.h> #include <asm/cpu.h> #include <asm/cpu-features.h> -#include <asm-generic/iomap.h> #include <asm/page.h> #include <asm/pgtable-bits.h> #include <asm/processor.h> @@ -210,6 +207,8 @@ void iounmap(const volatile void __iomem *addr);#define ioremap_wc (offset, size) \ ioremap_prot((offset), (size), boot_cpu_data.writecombine) +#include <asm-generic/iomap.h> +#if defined(CONFIG_CPU_CAVIUM_OCTEON )#define war_io_reorder_wmb () wmb()#else arch/powerpc/include/asm/io.h +1
-8@@ -3,11 +3,6 @@#define _ASM_POWERPC_IO_H#ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WC -#ifdef CONFIG_PPC32 -#define ARCH_HAS_IOREMAP_WT -#endif -/* */ @@ -732,9 +727,7 @@ static inline void name at \#define writel_relaxed (v, addr) writel(v, addr)#define writeq_relaxed (v, addr) writeq(v, addr) -#ifdef CONFIG_GENERIC_IOMAP -#include <asm-generic/iomap.h> -#else +#ifndef CONFIG_GENERIC_IOMAP /* * Here comes the implementation of the IOMAP interfaces. */ arch/x86/include/asm/io.h +0
-5@@ -35,9 +35,6 @@* - Arnaldo Carvalho de Melo <[email protected]> */ -#define ARCH_HAS_IOREMAP_WC -#define ARCH_HAS_IOREMAP_WT -#include <linux/string.h> #include <linux/compiler.h> #include <linux/cc_platform.h> @@ -212,8 +209,6 @@ void memset_io(volatile void __iomem *, int, size_t);#define memcpy_toio memcpy_toio#define memset_io memset_io -#include <asm-generic/iomap.h> -/* * ISA space is 'always mapped' on a typical x86 system, no need to * explicitly ioremap() it. The fact that the ISA IO space is mapped drivers/net/ethernet/sfc/io.h +1
-1@@ -70,7 +70,7 @@*/ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc#define EFX_USE_PIO 1#endif #endif drivers/net/ethernet/sfc/siena/io.h +1
-1@@ -70,7 +70,7 @@*/ #ifdef CONFIG_X86_64 /* PIO is a win only if write-combining is possible */ -#ifdef ARCH_HAS_IOREMAP_WC +#ifdef ioremap_wc#define EFX_USE_PIO 1#endif #endif include/asm-generic/iomap.h +3
-3@@ -93,15 +93,15 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr);extern void ioport_unmap (void __iomem *);#endif -#ifndef ARCH_HAS_IOREMAP_WC +#ifndef ioremap_wc#define ioremap_wc ioremap#endif -#ifndef ARCH_HAS_IOREMAP_WT +#ifndef ioremap_wt#define ioremap_wt ioremap#endif -#ifndef ARCH_HAS_IOREMAP_NP +#ifndef ioremap_np/* See the comment in asm-generic/io.h about ioremap_np(). */ #define ioremap_np ioremap_npstatic inline void __iomem *ioremap_np (phys_addr_t offset,size_t size)Signature · 1 line
2.34.1Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 01/17] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros
In reply to Baoquan HeQuoted 27 lines · Baoquan He
Let's use '#define
ioremap_xx' and "#ifdefioremap_xx" instead.For each architecture to remove defined
ARCH_HAS_IOREMAP_xxmacros in To remove definedARCH_HAS_IOREMAP_xxmacros in <asm/io.h> of each ARCH, the ARCH's own ioremap_wc|wt|np definition need be above "#include <asm-generic/iomap.h>. Otherwise the redefinition error would be seen during compiling. So the relevant adjustments are made to avoid compiling error:loongarch:
- doesn't include <asm-generic/iomap.h>, definingARCH_HAS_IOREMAP_WCis redundant, so simply remove it.m68k:
- selectedGENERIC_IOMAP, <asm-generic/iomap.h> has been added in <asm-generic/io.h>, and <asm/kmap.h> is included above <asm-generic/iomap.h>, so simply removeARCH_HAS_IOREMAP_WTdefining.mips:
- move "#include <asm-generic/iomap.h>" belowioremap_wcdefinitionin <asm/io.h>powerpc:
- remove "#include <asm-generic/iomap.h>" in <asm/io.h> because it's duplicated with the one in <asm-generic/io.h>, let's rely on the latter.
Quoted 8 lines
x86:
- selectedGENERIC_IOMAP, remove #include <asm-generic/iomap.h> in the middle of <asm/io.h>. Let's rely on <asm-generic/io.h>.Signed-off-by Baoquan He <[email protected]>arch/m68k/include/asm/io_mm.h | 2 -- arch/m68k/include/asm/kmap.h | 2 --
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v5 RESEND 01/17] asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros
In reply to Baoquan HeLooks good:
PATCH RESEND v5 2/17 hexagon: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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.
--- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c
arch/hexagon/Kconfig +1 -0
@@ -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
arch/hexagon/include/asm/io.h +7 -2
@@ -170,8 +170,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
arch/hexagon/mm/ioremap.c deleted +0 -44
44 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 02/17] hexagon: mm: Convert to GENERIC_IOREMAP
Quoted 5 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericioremap_prot()andiounmap()are visible and available to arch. This change will simplify implementation by removing duplicated codes with genericioremap_prot()andiounmap(), and has the equivalent functioality.
Quoted 7 lines
For hexagon, the current
ioremap()andiounmap()are the same as generic version. After takingGENERIC_IOREMAPway, the oldioremap()andiounmap()can be completely removed.
Quoted 93 lines
--- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.carch/hexagon/Kconfig +1
-0@@ -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_BROADCASTarch/hexagon/include/asm/io.h +7
-2@@ -170,8 +170,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 writelarch/hexagon/mm/ioremap.c deleted +0
-44@@ -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 )); -}Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 02/17] hexagon: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeLooks good:
PATCH RESEND v5 3/17 openrisc: mm: remove unneeded early ioremap code
In reply to Baoquan HeUnder arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed.
--- arch/openrisc/mm/ioremap.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
arch/openrisc/mm/ioremap.c +5 -17
@@ -22,8 +22,6 @@extern int mem_init_done; -static unsigned int fixmaps_used__initdata ; -/* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses
@@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr &PAGE_MASK ; size =PAGE_ALIGN (last_addr +1 ) - p; -if (likely (mem_init_done)) { - area =get_vm_area (size,VM_IOREMAP ); -if (!area) -return NULL ; - v = (unsigned long )area->addr; - }else { -if ((fixmaps_used + (size >>PAGE_SHIFT )) >FIX_N_IOREMAPS ) -return NULL ; - v =fix_to_virt (FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >>PAGE_SHIFT ); - } + 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))) { -if (likely (mem_init_done)) -vfree (area->addr); -else - fixmaps_used -= (size >>PAGE_SHIFT ); +vfree (area->addr);return NULL ; }
Signature · 1 line
2.34.1
Mike Rapoport
reviewerRe: [PATCH v5 RESEND 03/17] openrisc: mm: remove unneeded early ioremap code
Quoted 4 lines · Baoquan He
Under
arch/openrisc, there isn't any place whereioremap()is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code inioremap()ofarch/openrisc/mm/ioremap.cis unnecessary and can be removed.
It looks like early ioremap was the only user of fixmap on openrisc, so it can be removed as well.
Quoted 58 lines
Signed-off-by Baoquan He <[email protected]>Acked-by Stafford Horne <[email protected]>Cc Jonas Bonn <[email protected]>Cc Stefan Kristiansson <[email protected]>Cc Stafford Horne <[email protected]>--- arch/openrisc/mm/ioremap.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)arch/openrisc/mm/ioremap.c +5
-17@@ -22,8 +22,6 @@extern int mem_init_done; -static unsigned int fixmaps_used__initdata ; -/* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr &PAGE_MASK ; size =PAGE_ALIGN (last_addr +1 ) - p; -if (likely (mem_init_done)) { - area =get_vm_area (size,VM_IOREMAP ); -if (!area) -return NULL ; - v = (unsigned long )area->addr; - }else { -if ((fixmaps_used + (size >>PAGE_SHIFT )) >FIX_N_IOREMAPS ) -return NULL ; - v =fix_to_virt (FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >>PAGE_SHIFT ); - } + 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))) { -if (likely (mem_init_done)) -vfree (area->addr); -else - fixmaps_used -= (size >>PAGE_SHIFT ); +vfree (area->addr);return NULL ; }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 03/17] openrisc: mm: remove unneeded early ioremap code
Quoted 8 lines · Mike Rapoport
Quoted 4 lines · Baoquan He
Under
arch/openrisc, there isn't any place whereioremap()is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code inioremap()ofarch/openrisc/mm/ioremap.cis unnecessary and can be removed.It looks like early ioremap was the only user of fixmap on openrisc, so it can be removed as well.
You are right, and you are saying the relic in iounmap() about fixmap handling, hope I got it right. I will remove it, the code will be more cleaner. Thanks.
Quoted 64 lines
Quoted 59 lines
Signed-off-by Baoquan He <[email protected]>Acked-by Stafford Horne <[email protected]>Cc Jonas Bonn <[email protected]>Cc Stefan Kristiansson <[email protected]>Cc Stafford Horne <[email protected]>--- arch/openrisc/mm/ioremap.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)arch/openrisc/mm/ioremap.c +5
-17@@ -22,8 +22,6 @@extern int mem_init_done; -static unsigned int fixmaps_used__initdata ; -/* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr &PAGE_MASK ; size =PAGE_ALIGN (last_addr +1 ) - p; -if (likely (mem_init_done)) { - area =get_vm_area (size,VM_IOREMAP ); -if (!area) -return NULL ; - v = (unsigned long )area->addr; - }else { -if ((fixmaps_used + (size >>PAGE_SHIFT )) >FIX_N_IOREMAPS ) -return NULL ; - v =fix_to_virt (FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >>PAGE_SHIFT ); - } + 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))) { -if (likely (mem_init_done)) -vfree (area->addr); -else - fixmaps_used -= (size >>PAGE_SHIFT ); +vfree (area->addr);return NULL ; }Signature · 1 line
2.34.1Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 03/17] openrisc: mm: remove unneeded early ioremap code
In reply to Baoquan HeLooks good:
PATCH RESEND v5 4/17 mm/ioremap: Define generic_ioremap_prot() and generic_iounmap()
In reply to Baoquan HeFrom: Christophe Leroy <[email protected]>
Define a generic version of ioremap_prot() and iounmap() that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications.
--- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-)
include/asm-generic/io.h +4 -0
@@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) }#endif +void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size, +pgprot_t prot); +void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size,unsigned long prot);void iounmap (volatile void __iomem *addr); +void generic_iounmap (volatile void __iomem *addr);static inline void __iomem *ioremap (phys_addr_t addr,size_t size) {
mm/ioremap.c +16 -6
@@ -11,8 +11,8 @@#include <linux/io.h> #include <linux/export.h> -void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size, -unsigned long prot) +void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size, +pgprot_t prot) {unsigned long offset, vaddr;phys_addr_t last_addr;
@@ -28,7 +28,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size =PAGE_ALIGN (size + offset); -if (!ioremap_allowed (phys_addr, size, prot)) +if (!ioremap_allowed (phys_addr, size,pgprot_val (prot)))return NULL ; area = get_vm_area_caller(size, VM_IOREMAP,
@@ -38,17 +38,22 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, vaddr = (unsigned long )area->addr; area->phys_addr = phys_addr; -if (ioremap_page_range (vaddr, vaddr + size, phys_addr, -__pgprot (prot))) { +if (ioremap_page_range (vaddr, vaddr + size, phys_addr, prot)) {free_vm_area (area);return NULL ; }return (void __iomem *)(vaddr + offset); } + +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); -void iounmap (volatile void __iomem *addr) +void generic_iounmap (volatile void __iomem *addr) {void *vaddr = (void *)((unsigned long )addr &PAGE_MASK );
@@ -58,4 +63,9 @@ void iounmap(volatile void __iomem *addr)if (is_vmalloc_addr (vaddr))vunmap (vaddr); } + +void iounmap (volatile void __iomem *addr) +{ +generic_iounmap (addr); +}EXPORT_SYMBOL (iounmap);
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 04/17] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap()
Quoted 8 lines · Baoquan He
From: Christophe Leroy <[email protected]>
Define a generic version of
ioremap_prot()andiounmap()that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications.Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>
Quoted 87 lines
--- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-)include/asm-generic/io.h +4
-0@@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) }#endif +void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size, +pgprot_t prot); +void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size,unsigned long prot);void iounmap (volatile void __iomem *addr); +void generic_iounmap (volatile void __iomem *addr);static inline void __iomem *ioremap (phys_addr_t addr,size_t size) {mm/ioremap.c +16
-6@@ -11,8 +11,8 @@#include <linux/io.h> #include <linux/export.h> -void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size, -unsigned long prot) +void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size, +pgprot_t prot) {unsigned long offset, vaddr;phys_addr_t last_addr;@@ -28,7 +28,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size =PAGE_ALIGN (size + offset); -if (!ioremap_allowed (phys_addr, size, prot)) +if (!ioremap_allowed (phys_addr, size,pgprot_val (prot)))return NULL ; area = get_vm_area_caller(size, VM_IOREMAP,@@ -38,17 +38,22 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, vaddr = (unsigned long )area->addr; area->phys_addr = phys_addr; -if (ioremap_page_range (vaddr, vaddr + size, phys_addr, -__pgprot (prot))) { +if (ioremap_page_range (vaddr, vaddr + size, phys_addr, prot)) {free_vm_area (area);return NULL ; }return (void __iomem *)(vaddr + offset); } + +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); -void iounmap (volatile void __iomem *addr) +void generic_iounmap (volatile void __iomem *addr) {void *vaddr = (void *)((unsigned long )addr &PAGE_MASK );@@ -58,4 +63,9 @@ void iounmap(volatile void __iomem *addr)if (is_vmalloc_addr (vaddr))vunmap (vaddr); } + +void iounmap (volatile void __iomem *addr) +{ +generic_iounmap (addr); +}EXPORT_SYMBOL (iounmap);Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 04/17] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap()
In reply to Baoquan HeQuoted 18 lines · Baoquan He
From: Christophe Leroy <[email protected]>
Define a generic version of
ioremap_prot()andiounmap()that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications.Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>--- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-)include/asm-generic/io.h +0
-0
include/asm-generic/io.h static inline bool iounmap_allowed(void *addr) · line 1078
Quoted 6 lines
include/asm-generic/io.h +3
-0@@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) }#endif +void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size, +pgprot_t prot); +
Formatting looks a bit weird here. The normal styles are either to indent with two tabs (my preference) or after the opening brace.
Otherwise looks good:
Re: [PATCH v5 RESEND 04/17] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap()
Quoted 22 lines · Christoph Hellwig
Quoted 21 lines · Baoquan He
From: Christophe Leroy <[email protected]>
Define a generic version of
ioremap_prot()andiounmap()that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications.Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>--- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-)include/asm-generic/io.h +0
-0@@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) }#endif
Quoted 6 lines
include/asm-generic/io.h static inline bool iounmap_allowed(void *addr) · line 1078
Quoted 3 lines
include/asm-generic/io.h +3
-0+void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size, +pgprot_t prot); +Formatting looks a bit weird here. The normal styles are either to indent with two tabs (my preference) or after the opening brace.
Thanks a lot for careful reviewing on this series.
I check this place again, strange it looks good in code with identing after the opening brace, while in patch it looks messy. Will try again to see if I can fix it in patch too.
Re: [PATCH v5 RESEND 04/17] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap()
In reply to Baoquan HeQuoted 8 lines · Baoquan He
From: Christophe Leroy <[email protected]>
Define a generic version of
ioremap_prot()andiounmap()that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications.Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>
PATCH RESEND v5 5/17 mm: ioremap: allow ARCH to have its own ioremap method definition
In reply to Baoquan HeArchitectures 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.
--- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+)
include/asm-generic/io.h +3 -0
@@ -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 ioremapstatic 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
mm/ioremap.c +4 -0
@@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_protvoid __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 iounmapvoid iounmap (volatile void __iomem *addr) {generic_iounmap (addr); }EXPORT_SYMBOL (iounmap); +#endif
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 05/17] mm: ioremap: allow ARCH to have its own ioremap method definition
Quoted 5 lines · Baoquan He
Architectures can be converted to
GENERIC_IOREMAP, to take standardioremap_xxx()andiounmap()way. But some ARCH-es could have specific handling forioremap_prot(),ioremap()andiounmap(), than standard methods.
Quoted 8 lines
In oder to convert these ARCH-es to take
GENERIC_IOREMAPmethod, allow these architecutres to have their ownioremap_prot(),ioremap()andiounmap()definitions.Signed-off-by Baoquan He <[email protected]>Acked-by Arnd Bergmann <[email protected]>Cc Kefeng Wang <[email protected]>
Quoted 58 lines
--- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+)include/asm-generic/io.h +3
-0@@ -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 ioremapstatic 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_wcmm/ioremap.c +4
-0@@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_protvoid __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 iounmapvoid iounmap (volatile void __iomem *addr) {generic_iounmap (addr); }EXPORT_SYMBOL (iounmap); +#endif Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 05/17] mm: ioremap: allow ARCH to have its own ioremap method definition
In reply to Baoquan HeLooks good:
Re: [PATCH v5 RESEND 05/17] mm: ioremap: allow ARCH to have its own ioremap method definition
In reply to Baoquan HeQuoted 9 lines · Baoquan He
Architectures can be converted to
GENERIC_IOREMAP, to take standardioremap_xxx()andiounmap()way. But some ARCH-es could have specific handling forioremap_prot(),ioremap()andiounmap(), than standard methods.In oder to convert these ARCH-es to take
GENERIC_IOREMAPmethod, allow these architecutres to have their ownioremap_prot(),ioremap()andiounmap()definitions.
Quoted 9 lines
Signed-off-by Baoquan He <[email protected]>Acked-by Arnd Bergmann <[email protected]>Cc Kefeng Wang <[email protected]>--- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+)
PATCH RESEND v5 6/17 mm/ioremap: add slab availability checking in ioremap_prot
In reply to Baoquan HeSeveral 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().
--- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/ioremap.c +4 -0
@@ -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 (!slab_is_available ()) +return NULL ; +/* Disallow wrap-around or zero size */ last_addr = phys_addr + size -1 ;if (!size || last_addr < phys_addr)
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot
Quoted 9 lines · Baoquan He
Several architectures has done checking if slab if available in
ioremap_prot(). In fact it should be done in genericioremap_prot()since on any architecutre, slab allocator must be available beforeget_vm_area_caller()andvunmap()are used.Add the checking into
generic_ioremap_prot().Suggested-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>
Quoted 23 lines
--- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+)mm/ioremap.c +4
-0@@ -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 (!slab_is_available ()) +return NULL ; +/* Disallow wrap-around or zero size */ last_addr = phys_addr + size -1 ;if (!size || last_addr < phys_addr)Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot
In reply to Baoquan HeQuoted 6 lines · Baoquan He
Several architectures has done checking if slab if available in
ioremap_prot(). In fact it should be done in genericioremap_prot()since on any architecutre, slab allocator must be available beforeget_vm_area_caller()andvunmap()are used.Add the checking into
generic_ioremap_prot().
Should we add a WARN_ON/WARN_ON_ONCE to aid debugging?
Otherwise looks good:
Re: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · Baoquan He
Several architectures has done checking if slab if available in
ioremap_prot(). In fact it should be done in genericioremap_prot()since on any architecutre, slab allocator must be available beforeget_vm_area_caller()andvunmap()are used.Add the checking into
generic_ioremap_prot().Should we add a WARN_ON/WARN_ON_ONCE to aid debugging?
Sounds like a great idea, will add WARN_ON_ONCE as below. Thanks.
if (WARN_ON_ONCE(!slab_is_available())) return NULL;
Re: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot
In reply to Baoquan HeQuoted 5 lines · Baoquan He
Several architectures has done checking if slab if available in
ioremap_prot(). In fact it should be done in genericioremap_prot()since on any architecutre, slab allocator must be available beforeget_vm_area_caller()andvunmap()are used.
Quoted 8 lines
Add the checking into
generic_ioremap_prot().Suggested-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>--- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+)
PATCH RESEND v5 7/17 arc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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().
--- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-)
arch/arc/Kconfig +1 -0
@@ -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
arch/arc/include/asm/io.h +3 -4
@@ -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 iounmapstatic 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 */
arch/arc/mm/ioremap.c +4 -45
79 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP
Quoted 9 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.
Quoted 6 lines
Here, add wrapper functions
ioremap_prot()andiounmap()for arc's special operation whenioremap_prot()andiounmap().
Quoted 133 lines
--- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-)arch/arc/Kconfig +1
-0@@ -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_V4arch/arc/include/asm/io.h +3
-4@@ -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 iounmapstatic 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 */ arch/arc/mm/ioremap.c +4
-45@@ -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);Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan Hearch/arc/include/asm/io.h line 26
Quoted 3 lines
arch/arc/include/asm/io.h +3
-0+#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmap
Nit: I think it's cleaner to have these #defines right next to the function declaration.
Otherwise looks good:
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP
Quoted 6 lines · Christoph Hellwig
arch/arc/include/asm/io.h line 26
Quoted 3 lines
arch/arc/include/asm/io.h +3
-0+#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmapNit: I think it's cleaner to have these #defines right next to the function declaration.
Makes sense, will do.
Quoted 5 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Re: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP
In reply to Christoph HellwigHi Christoph,
Quoted 6 lines · Christoph Hellwig
arch/arc/include/asm/io.h line 26
Quoted 3 lines
arch/arc/include/asm/io.h +3
-0+#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmapNit: I think it's cleaner to have these #defines right next to the function declaration.
For this one, I didn't add function declaration of ioremap_prot and iounmap in arch/arc/include/asm/io.h and the same to other arch's asm/io.h. Because asm-generic/io.h already has those function declaration, then ARCH's asm/io.h includeasm-generic/io.h. I tried adding function declarations for ioremap_prot() and iounmap(), building passed too. Do you think we need add extra function declarations in ARCH's asm/io.h file?
Thanks
Baoquan
Re: [PATCH v5 RESEND 07/17] arc: mm: Convert to GENERIC_IOREMAP
Quoted 8 lines · Baoquan He
Quoted 6 lines · Christoph Hellwig
arch/arc/include/asm/io.h line 26
Quoted 3 lines
arch/arc/include/asm/io.h +3
-0+#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmapNit: I think it's cleaner to have these #defines right next to the function declaration.
Quoted 7 lines
For this one, I didn't add function declaration of
ioremap_protand iounmap inarch/arc/include/asm/io.hand the same to other arch'sasm/io.h. Becauseasm-generic/io.halready has those function declaration, then ARCH'sasm/io.hincludeasm-generic/io.h. I tried adding function declarations forioremap_prot()andiounmap(), building passed too. Do you think we need add extra function declarations in ARCH'sasm/io.hfile?
No, sorry.
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
PATCH RESEND v5 8/17 ia64: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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().
--- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-)
arch/ia64/Kconfig +1 -0
@@ -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
arch/ia64/include/asm/io.h +5 -8
@@ -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
arch/ia64/mm/ioremap.c +6 -35
63 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 08/17] ia64: mm: Convert to GENERIC_IOREMAP
Quoted 9 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.
Quoted 5 lines
Here, add wrapper functions
ioremap_prot()andiounmap()for ia64's special operation whenioremap()andiounmap().Signed-off-by Baoquan He <[email protected]>
Quoted 117 lines
--- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-)arch/ia64/Kconfig +1
-0@@ -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_ALLOCATORarch/ia64/include/asm/io.h +5
-8@@ -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 iounmaparch/ia64/mm/ioremap.c +6
-35@@ -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 ));Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 08/17] ia64: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan Hearch/ia64/include/asm/io.h static inline void outsl(unsigned long port, const void *src, · line 253
Quoted 4 lines
arch/ia64/include/asm/io.h +2
-0+#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap#define ioremap_uc ioremap_uc#define iounmap iounmap
Same comment about the placement here, I'm not going to repeat it if it shows up in more patches.
Otherwise looks good:
Re: [PATCH v5 RESEND 08/17] ia64: mm: Convert to GENERIC_IOREMAP
Quoted 7 lines · Christoph Hellwig
arch/ia64/include/asm/io.h static inline void outsl(unsigned long port, const void *src, · line 253
Quoted 4 lines
arch/ia64/include/asm/io.h +2
-0+#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap#define ioremap_uc ioremap_uc#define iounmap iounmapSame comment about the placement here, I'm not going to repeat it if it shows up in more patches.
Sure, Will check all of them and change, thanks.
Quoted 5 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
PATCH RESEND v5 9/17 openrisc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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 function iounmap() for openrisc's special operation when iounmap().
--- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 +++++--- arch/openrisc/mm/ioremap.c | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 deletions(-)
arch/openrisc/Kconfig +1 -0
@@ -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
arch/openrisc/include/asm/io.h +7 -4
@@ -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,12 @@#define PIO_OFFSET 0#define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap (phys_addr_t offset,unsigned long size); - +/* +* I/O memory mapping functions. +*/ #define iounmap iounmap -extern void iounmap (volatile void __iomem *addr); + +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI)#include <asm-generic/io.h>
arch/openrisc/mm/ioremap.c +1 -45
59 lines not on this page · raw message
Signature · 1 line
2.34.1
Mike Rapoport
reviewerRe: [PATCH v5 RESEND 09/17] openrisc: mm: Convert to GENERIC_IOREMAP
Hi,
Quoted 109 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.Here, add wrapper function
iounmap()for openrisc's special operation wheniounmap().Signed-off-by Baoquan He <[email protected]>Cc Stafford Horne <[email protected]>Cc Jonas Bonn <[email protected]>Cc Stefan Kristiansson <[email protected]>--- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 +++++--- arch/openrisc/mm/ioremap.c | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 deletions(-)arch/openrisc/Kconfig +1
-0@@ -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_UID16arch/openrisc/include/asm/io.h +7
-4@@ -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,12 @@#define PIO_OFFSET 0#define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap (phys_addr_t offset,unsigned long size); - +/* +* I/O memory mapping functions. +*/ #define iounmap iounmap -extern void iounmap (volatile void __iomem *addr); + +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI)#include <asm-generic/io.h> arch/openrisc/mm/ioremap.c +0
-36@@ -22,49 +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);
arch/openrisc/mm/ioremap.c line 27
Quoted 10 lines
arch/openrisc/mm/ioremap.c +0
-7-return NULL ; - } - -return (void __iomem *)(offset + (char *)v); -} -EXPORT_SYMBOL (ioremap); -void iounmap (volatile void __iomem *addr) {/* If the page is from the fixmap pool then we just clear out
The page cannot be from fixmap pool since we removed fixmap support from ioremap in an earlier patch.
I believe that patch should also remove special casing of fixmap in iounmap() and then openrisc does not need to override any of ioremap methods.
Quoted 15 lines
arch/openrisc/mm/ioremap.c +1
-2@@ -88,9 +45,8 @@ void iounmap(volatile void __iomem *addr)return ; } -return vfree ((void *)(PAGE_MASK & (unsigned long )addr)); +generic_iounmap (addr); } -EXPORT_SYMBOL (iounmap);/** * OK, this one's a bit tricky... ioremap can get called before memory is Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 09/17] openrisc: mm: Convert to GENERIC_IOREMAP
Quoted 120 lines · Mike Rapoport
Hi,
Quoted 117 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.Here, add wrapper function
iounmap()for openrisc's special operation wheniounmap().Signed-off-by Baoquan He <[email protected]>Cc Stafford Horne <[email protected]>Cc Jonas Bonn <[email protected]>Cc Stefan Kristiansson <[email protected]>--- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 +++++--- arch/openrisc/mm/ioremap.c | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 deletions(-)arch/openrisc/Kconfig +1
-0@@ -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_UID16arch/openrisc/include/asm/io.h +7
-4@@ -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,12 @@#define PIO_OFFSET 0#define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap (phys_addr_t offset,unsigned long size); - +/* +* I/O memory mapping functions. +*/ #define iounmap iounmap -extern void iounmap (volatile void __iomem *addr); + +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI)#include <asm-generic/io.h> arch/openrisc/mm/ioremap.c +0
-43@@ -22,49 +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)
Quoted 8 lines
arch/openrisc/mm/ioremap.c line 27
Quoted 2 lines
arch/openrisc/mm/ioremap.c +0
-0{/* If the page is from the fixmap pool then we just clear out The page cannot be from fixmap pool since we removed fixmap support from ioremap in an earlier patch.
I believe that patch should also remove special casing of fixmap iniounmap()and then openrisc does not need to override any of ioremap methods.
Totally agree. I will clean it up in iounmap() in patch 3, and rearrange this patch. Thanks again.
Quoted 21 lines
Quoted 16 lines
arch/openrisc/mm/ioremap.c +1
-2@@ -88,9 +45,8 @@ void iounmap(volatile void __iomem *addr)return ; } -return vfree ((void *)(PAGE_MASK & (unsigned long )addr)); +generic_iounmap (addr); } -EXPORT_SYMBOL (iounmap);/** * OK, this one's a bit tricky... ioremap can get called before memory is Signature · 1 line
2.34.1Signature · 2 lines
Sincerely yours, Mike.
PATCH RESEND v5 10/17 s390: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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().
--- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++++------ arch/s390/pci/pci.c | 57 +++++++------------------------------- 3 files changed, 23 insertions(+), 56 deletions(-)
arch/s390/Kconfig +1 -0
@@ -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
arch/s390/include/asm/io.h +12 -9
@@ -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)
arch/s390/pci/pci.c +10 -47
72 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 10/17] s390: mm: Convert to GENERIC_IOREMAP
Quoted 12 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.Here, add wrapper functions
ioremap_prot()andiounmap()for s390's special operation whenioremap()andiounmap().
Quoted 10 lines
Signed-off-by Baoquan He <[email protected]>Reviewed-by Niklas Schnelle <[email protected]>Tested-by Niklas Schnelle <[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]>
Quoted 138 lines
--- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++++------ arch/s390/pci/pci.c | 57 +++++++------------------------------- 3 files changed, 23 insertions(+), 56 deletions(-)arch/s390/Kconfig +1
-0@@ -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_LABELarch/s390/include/asm/io.h +12
-9@@ -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)arch/s390/pci/pci.c +10
-47@@ -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);Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 10/17] s390: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan Hearch/s390/include/asm/io.h void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); · line 34
Quoted 2 lines · Baoquan He
arch/s390/include/asm/io.h +2
-0+#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL)))
I'd move this out of line and just apply mio_wb_bit_mask directly instead of the unbox/box/unbox/box dance.
arch/s390/include/asm/io.h void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); · line 36
Quoted 2 lines
arch/s390/include/asm/io.h +2
-0+#define ioremap_wt (addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL)))
and just define this to ioremap_wc. Note that defining _wt to _wc is very odd and seems wrong, but comes from the existing code. Maybe the s390 maintainers can chime on on the background and we can add a comment while we're at it.
Otherwise looks good:
Niklas Schnelle
maintainerRe: [PATCH v5 RESEND 10/17] s390: mm: Convert to GENERIC_IOREMAP
Quoted 7 lines · Christoph Hellwig
arch/s390/include/asm/io.h void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); · line 34
Quoted 2 lines · Baoquan He
arch/s390/include/asm/io.h +2
-0+#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL)))I'd move this out of line and just apply
mio_wb_bit_maskdirectly instead of the unbox/box/unbox/box dance.
Quoted 7 lines
arch/s390/include/asm/io.h void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); · line 36
Quoted 2 lines
arch/s390/include/asm/io.h +2
-0+#define ioremap_wt (addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL)))and just define this to
ioremap_wc. Note that defining_wtto_wcis very odd and seems wrong, but comes from the existing code. Maybe the s390 maintainers can chime on on the background and we can add a comment while we're at it.
I'm a bit confused where you see ioremap_wt() defined to ioremap_wc() in the existing code? Our current definitions are:
void __iomem *ioremap_wc(phys_addr_t addr, size_t size) {
return __ioremap(addr, size,pgprot_writecombine(PAGE_KERNEL));
}
void __iomem *ioremap_wt(phys_addr_t addr, size_t size) {
return __ioremap(addr, size,pgprot_writethrough(PAGE_KERNEL));
}
Now if we don't have support for the enhanced PCI load/store instructions (memory I/O aka MIO) then yes this gets ignored and both .._wc() and .._wt() act the same but if we do have them pgprot_writecombine() / pgprot_writethrough() set respectively clear the mio_wb bit in the PTE. It's a bit odd here because the exact position of the bit is read from a firmware interface and could in theory change but other than that it looks fine to me and yes I agree that it would be odd and broken to define _wt to _wc.
Thanks,
Niklas
Re: [PATCH v5 RESEND 10/17] s390: mm: Convert to GENERIC_IOREMAP
Quoted 7 lines · Niklas Schnelle
Quoted 4 lines
and just define this to
ioremap_wc. Note that defining_wtto_wcis very odd and seems wrong, but comes from the existing code. Maybe the s390 maintainers can chime on on the background and we can add a comment while we're at it.I'm a bit confused where you see
ioremap_wt()defined toioremap_wc()in the existing code? Our current definitions are:
No, it's me wo is confused. They clearly are different. But the same comment about just moving ioremap_wc applies to ioremap_wt based on how pgprot_writethrough is implemented then.
PATCH RESEND v5 11/17 sh: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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 SuperH's special operation when ioremap() and iounmap().
Meanwhile, add macro definitions for port|mm io functions since SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions in include/asm-generic/io.h to cause compiling errors like below:
====
CC arch/sh/kernel/asm-offsets.s
In file included from ./arch/sh/include/asm/io.h:294,
from ./include/linux/io.h:13,
......
from arch/sh/kernel/asm-offsets.c:16:
./include/asm-generic/io.h:792:17: error: conflicting types for ‘ioread8’
792 | #define ioread8 ioread8
| ^~~~~~~
./include/asm-generic/io.h:793:18: note: in expansion of macro ‘ioread8’
793 | static inline u8 ioread8(const volatile void __iomem *addr)
| ^~~~~~~
In file included from ./arch/sh/include/asm/io.h:22,
from ./include/linux/io.h:13,
......
from arch/sh/kernel/asm-offsets.c:16:./include/asm-generic/iomap.h:29:21: note: previous declaration of ‘ioread8’ was here
29 | extern unsigned int ioread8(const void __iomem *);
====
--- 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 ++++++------------------------- 4 files changed, 52 insertions(+), 86 deletions(-)
arch/sh/Kconfig +1 -0
@@ -28,6 +28,7 @@ config SUPERH select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB select HAS_IOPORT if HAS_IOPORT_MAP + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER
arch/sh/include/asm/io.h +33 -32
91 lines not on this page · raw message
arch/sh/include/asm/io_noioport.h +7 -0
@@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr)#define outw_p (x, addr) outw((x), (addr))#define outl_p (x, addr) outl((x), (addr)) +#define insb insb +#define insw insw +#define insl insl +#define outsb outsb +#define outsw outsw +#define outsl outsl +static inline void insb (unsigned long port,void *dst,unsigned long count) {BUG ();
arch/sh/mm/ioremap.c +11 -54
109 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 11/17] sh: mm: Convert to GENERIC_IOREMAP
Quoted 5 lines · Baoquan He
Meanwhile, add macro definitions for port|mm io functions since SuperH has its own implementation in
arch/sh/kernel/iomap.candarch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions ininclude/asm-generic/io.hto cause compiling errors like below:
Please split that inclusion of include/asm-generic/io.h and redefining of the helpers into a separate prep patch.
Otherwise looks good:
Re: [PATCH v5 RESEND 11/17] sh: mm: Convert to GENERIC_IOREMAP
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Baoquan He
Meanwhile, add macro definitions for port|mm io functions since SuperH has its own implementation in
arch/sh/kernel/iomap.candarch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions ininclude/asm-generic/io.hto cause compiling errors like below:Please split that inclusion of
include/asm-generic/io.hand redefining of the helpers into a separate prep patch.
Will do.
Quoted 5 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
PATCH RESEND v5 12/17 xtensa: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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().
--- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-)
arch/xtensa/Kconfig +1 -0
@@ -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
arch/xtensa/include/asm/io.h +12 -20
@@ -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 ioremapstatic 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>
arch/xtensa/mm/ioremap.c +14 -44
74 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 12/17] xtensa: mm: Convert to GENERIC_IOREMAP
Quoted 9 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.
Quoted 6 lines
Here, add wrapper functions
ioremap_prot(),ioremap()andiounmap()for xtensa's special operation whenioremap()andiounmap().Signed-off-by Baoquan He <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>
Quoted 169 lines
--- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-)arch/xtensa/Kconfig +1
-0@@ -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_KERNELarch/xtensa/include/asm/io.h +12
-20@@ -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 ioremapstatic 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> arch/xtensa/mm/ioremap.c +14
-44@@ -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);Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 12/17] xtensa: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeLooks good:
PATCH RESEND v5 13/17 parisc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeBy 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 function ioremap_prot() for parisc's special operation when iounmap().
Meanwhile, add macro ARCH_HAS_IOREMAP_WC since the added ioremap_wc() will conflict with the one in include/asm-generic/iomap.h, then an compiling error is seen:
./include/asm-generic/iomap.h:97: warning: "ioremap_wc" redefined
97 | #define ioremap_wc ioremap
And benefit from the commit 437b6b35362b ("parisc: Use the generic IO helpers"), those macros don't need be added any more.
--- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-)
arch/parisc/Kconfig +1 -0
@@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMP
arch/parisc/include/asm/io.h +10 -5
@@ -125,12 +125,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)/* * The standard PCI ioremap interfaces */ -void __iomem *ioremap (unsigned long offset,unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap (const volatile void __iomem *addr); +#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc (addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmapvoid memset_io (volatile void __iomem *addr,unsigned char val,int count);void memcpy_fromio (void *dst,const volatile void __iomem *src,int count);
arch/parisc/mm/ioremap.c +4 -58
79 lines not on this page · raw message
Signature · 1 line
2.34.1
Mike Rapoport
reviewerRe: [PATCH v5 RESEND 13/17] parisc: mm: Convert to GENERIC_IOREMAP
Quoted 9 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.
Quoted 6 lines
Here, add wrapper function
ioremap_prot()for parisc's special operation wheniounmap().Meanwhile, add macro
ARCH_HAS_IOREMAP_WCsince the addedioremap_wc()will conflict with the one ininclude/asm-generic/iomap.h, then an compiling error is seen:
Looks like this paragraph is outdated, as an earlier patch in the series removes use of ARCH_HAS_IOREMAP_WC?
Quoted 145 lines
./include/asm-generic/iomap.h:97: warning: "ioremap_wc" redefined
97 | #defineioremap_wcioremapAnd benefit from the commit
437b6b35362b("parisc: Use the generic IO helpers"), those macros don't need be added any more.Signed-off-by Baoquan He <[email protected]>Acked-by Helge Deller <[email protected]>Cc "James E.J. Bottomley" <[email protected]>--- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-)arch/parisc/Kconfig +1
-0@@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMParch/parisc/include/asm/io.h +10
-5@@ -125,12 +125,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)/* * The standard PCI ioremap interfaces */ -void __iomem *ioremap (unsigned long offset,unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap (const volatile void __iomem *addr); +#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc (addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmapvoid memset_io (volatile void __iomem *addr,unsigned char val,int count);void memcpy_fromio (void *dst,const volatile void __iomem *src,int count);arch/parisc/mm/ioremap.c +4
-58@@ -13,25 +13,9 @@#include <linux/io.h> #include <linux/mm.h> -/* -* Generic mapping function (not visible outside): -*/ - -/* -* Remap an arbitrary physical address space into the kernel virtual -* address space. -* -* 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 *ioremap (unsigned long phys_addr,unsigned long size) +void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size, +unsigned long prot) { -void __iomem *addr; -struct vm_struct *area; -unsigned long offset, last_addr; -pgprot_t pgprot; -#ifdef CONFIG_EISA unsigned long end = phys_addr + size -1 ;/* Support EISA addresses */ @@ -40,11 +24,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) phys_addr |=F_EXTEND (0xfc000000 );#endif -/* Don't allow wraparound or zero size */ - last_addr = phys_addr + size -1 ; -if (!size || last_addr < phys_addr) -return NULL ; -/* * Don't allow anybody to remap normal RAM that we're using.. */ @@ -62,39 +41,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) } } - pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_NO_CACHE); - -/* -* Mappings have to be page-aligned -*/ - offset = phys_addr & ~PAGE_MASK ; - phys_addr &=PAGE_MASK ; - size =PAGE_ALIGN (last_addr +1 ) - phys_addr; - -/* -* Ok, go for it.. -*/ - area =get_vm_area (size,VM_IOREMAP ); -if (!area) -return NULL ; - - addr = (void __iomem *) area->addr; -if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, - phys_addr, pgprot)) { -vunmap (addr); -return NULL ; - } - -return (void __iomem *) (offset + (char __iomem *)addr); -} -EXPORT_SYMBOL (ioremap); - -void iounmap (const volatile void __iomem *io_addr) -{ -unsigned long addr = (unsigned long )io_addr &PAGE_MASK ; - -if (is_vmalloc_addr ((void *)addr)) -vunmap ((void *)addr); +return generic_ioremap_prot (phys_addr, size,__pgprot (prot)); } -EXPORT_SYMBOL (iounmap); +EXPORT_SYMBOL (ioremap_prot);Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 13/17] parisc: mm: Convert to GENERIC_IOREMAP
Quoted 13 lines · Mike Rapoport
Quoted 12 lines · Baoquan He
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.Here, add wrapper function
ioremap_prot()for parisc's special operation wheniounmap().
Quoted 6 lines
Quoted 3 lines
Meanwhile, add macro
ARCH_HAS_IOREMAP_WCsince the addedioremap_wc()will conflict with the one ininclude/asm-generic/iomap.h, then an compiling error is seen:Looks like this paragraph is outdated, as an earlier patch in the series removes use of
ARCH_HAS_IOREMAP_WC?
You are right, I forgot updating this patchlog after removing ARCH_HAS_IOREMAP_WC. Will update in new post. Thanks.
Quoted 151 lines
Quoted 146 lines
./include/asm-generic/iomap.h:97: warning: "ioremap_wc" redefined
97 | #defineioremap_wcioremapAnd benefit from the commit
437b6b35362b("parisc: Use the generic IO helpers"), those macros don't need be added any more.Signed-off-by Baoquan He <[email protected]>Acked-by Helge Deller <[email protected]>Cc "James E.J. Bottomley" <[email protected]>--- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 15 ++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 15 insertions(+), 63 deletions(-)arch/parisc/Kconfig +1
-0@@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMParch/parisc/include/asm/io.h +10
-5@@ -125,12 +125,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)/* * The standard PCI ioremap interfaces */ -void __iomem *ioremap (unsigned long offset,unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap (const volatile void __iomem *addr); +#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc (addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmapvoid memset_io (volatile void __iomem *addr,unsigned char val,int count);void memcpy_fromio (void *dst,const volatile void __iomem *src,int count);arch/parisc/mm/ioremap.c +4
-58@@ -13,25 +13,9 @@#include <linux/io.h> #include <linux/mm.h> -/* -* Generic mapping function (not visible outside): -*/ - -/* -* Remap an arbitrary physical address space into the kernel virtual -* address space. -* -* 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 *ioremap (unsigned long phys_addr,unsigned long size) +void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size, +unsigned long prot) { -void __iomem *addr; -struct vm_struct *area; -unsigned long offset, last_addr; -pgprot_t pgprot; -#ifdef CONFIG_EISA unsigned long end = phys_addr + size -1 ;/* Support EISA addresses */ @@ -40,11 +24,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) phys_addr |=F_EXTEND (0xfc000000 );#endif -/* Don't allow wraparound or zero size */ - last_addr = phys_addr + size -1 ; -if (!size || last_addr < phys_addr) -return NULL ; -/* * Don't allow anybody to remap normal RAM that we're using.. */ @@ -62,39 +41,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) } } - pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_NO_CACHE); - -/* -* Mappings have to be page-aligned -*/ - offset = phys_addr & ~PAGE_MASK ; - phys_addr &=PAGE_MASK ; - size =PAGE_ALIGN (last_addr +1 ) - phys_addr; - -/* -* Ok, go for it.. -*/ - area =get_vm_area (size,VM_IOREMAP ); -if (!area) -return NULL ; - - addr = (void __iomem *) area->addr; -if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, - phys_addr, pgprot)) { -vunmap (addr); -return NULL ; - } - -return (void __iomem *) (offset + (char __iomem *)addr); -} -EXPORT_SYMBOL (ioremap); - -void iounmap (const volatile void __iomem *io_addr) -{ -unsigned long addr = (unsigned long )io_addr &PAGE_MASK ; - -if (is_vmalloc_addr ((void *)addr)) -vunmap ((void *)addr); +return generic_ioremap_prot (phys_addr, size,__pgprot (prot)); } -EXPORT_SYMBOL (iounmap); +EXPORT_SYMBOL (ioremap_prot);Signature · 1 line
2.34.1Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 13/17] parisc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeLooks good:
PATCH RESEND v5 14/17 mm/ioremap: Consider IOREMAP space in generic ioremap
In reply to Baoquan HeFrom: Christophe Leroy <[email protected]>
Architectures like powerpc have a dedicated space for IOREMAP mappings.
If so, use it in generic_ioremap_pro().
--- mm/ioremap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
mm/ioremap.c +6 -1
@@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,if (!ioremap_allowed (phys_addr, size,pgprot_val (prot)))return NULL ; +#ifdef IOREMAP_START + area =__get_vm_area_caller (size,VM_IOREMAP ,IOREMAP_START , +IOREMAP_END ,__builtin_return_address (0 )); +#else area =get_vm_area_caller (size,VM_IOREMAP ,__builtin_return_address (0 )); +#endif if (!area)return NULL ; vaddr = (unsigned long )area->addr;
@@ -66,7 +71,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); }
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 8 lines · Baoquan He
From: Christophe Leroy <[email protected]>
Architectures like powerpc have a dedicated space for IOREMAP mappings.
If so, use it in
generic_ioremap_pro().Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>
Quoted 35 lines
--- mm/ioremap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)mm/ioremap.c +6
-1@@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,if (!ioremap_allowed (phys_addr, size,pgprot_val (prot)))return NULL ; +#ifdef IOREMAP_START + area =__get_vm_area_caller (size,VM_IOREMAP ,IOREMAP_START , +IOREMAP_END ,__builtin_return_address (0 )); +#else area =get_vm_area_caller (size,VM_IOREMAP ,__builtin_return_address (0 )); +#endif if (!area)return NULL ; vaddr = (unsigned long )area->addr;@@ -66,7 +71,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); }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
In reply to Baoquan Hemm/ioremap.c void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, · line 44
Quoted 11 lines · Baoquan He
mm/ioremap.c +5
-0@@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,if (!ioremap_allowed (phys_addr, size,pgprot_val (prot)))return NULL ; +#ifdef IOREMAP_START + area =__get_vm_area_caller (size,VM_IOREMAP ,IOREMAP_START , +IOREMAP_END ,__builtin_return_address (0 )); +#else area =get_vm_area_caller (size,VM_IOREMAP ,__builtin_return_address (0 )); +#endif
I think this would be cleaner if we'd just always use __get_vm_area_caller and at the top of the file add a:
#ifndef IOREMAP_START
#define IOREMAP_START VMALLOC_START
#define IOREMAP_END VMALLOC_END
#endif
Together with a little comment that ioremap often, but not always uses the generic vmalloc area.
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 10 lines · Christoph Hellwig
I think this would be cleaner if we'd just always use
__get_vm_area_callerand at the top of the file add a:#ifndef
IOREMAP_START
#defineIOREMAP_STARTVMALLOC_START
#defineIOREMAP_ENDVMALLOC_END
#endifTogether with a little comment that ioremap often, but not always uses the generic vmalloc area.
.. and with that we can also simply is_ioremap_addr by moving it to ioremap.c and making it always operate on the IOREMAP constants.
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Christoph Hellwig
I think this would be cleaner if we'd just always use
__get_vm_area_callerand at the top of the file add a:#ifndef
IOREMAP_START
#defineIOREMAP_STARTVMALLOC_START
#defineIOREMAP_ENDVMALLOC_END
#endif
Quoted 5 lines
Quoted 2 lines
Together with a little comment that ioremap often, but not always uses the generic vmalloc area.
.. and with that we can also simply
is_ioremap_addrby moving it toioremap.cand making it always operate on the IOREMAP constants.
Great idea too, will do. Put this into a separate patch?
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 7 lines · Baoquan He
Quoted 5 lines
Quoted 2 lines
Together with a little comment that ioremap often, but not always uses the generic vmalloc area.
.. and with that we can also simply
is_ioremap_addrby moving it toioremap.cand making it always operate on the IOREMAP constants.Great idea too, will do. Put this into a separate patch?
Yes.
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
Quoted 8 lines · Christoph Hellwig
I think this would be cleaner if we'd just always use
__get_vm_area_callerand at the top of the file add a:#ifndef
IOREMAP_START
#defineIOREMAP_STARTVMALLOC_START
#defineIOREMAP_ENDVMALLOC_END
#endif
Quoted 5 lines
Quoted 2 lines
Together with a little comment that ioremap often, but not always uses the generic vmalloc area.
.. and with that we can also simply
is_ioremap_addrby moving it toioremap.cand making it always operate on the IOREMAP constants.
In the current code, is_ioremap_addr() is being used in kernel/iomem.c. However, mm/ioremap.c is only built in when CONFIG_GENERIC_IOREMAP is enabled. This will impact those architectures which haven't taken GENERIC_IOREMAP way.
[~]$ git grep is_ioremap_addr arch/powerpc/include/asm/pgtable.h:#define is_ioremap_addr is_ioremap_addr arch/powerpc/include/asm/pgtable.h:static inline bool is_ioremap_addr(const void *x) include/linux/mm.h:static inline bool is_ioremap_addr(const void *x) include/linux/mm.h:static inline bool is_ioremap_addr(const void *x)
kernel/iomem.c: if (is_ioremap_addr(addr)) mm/ioremap.c: if (is_ioremap_addr(vaddr))
[bhe@MiWiFi-R3L-srv linux-arm64]$ git grep ioremap mm/Makefile mm/Makefile:obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o mm/Makefile:obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o
If we want to consolidate code, we can move is_ioremap_addr() to include/linux/mm.h libe below. Not sure if it's fine. With it, both kernel/iomem.c and mm/ioremap.c can use is_ioremap_addr().
include/linux/mm.h +19 -3
@@ -1041,9 +1041,25 @@ 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) +#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 #ifdef CONFIG_MMU
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 3 lines · Baoquan He
If we want to consolidate code, we can move
is_ioremap_addr()toinclude/linux/mm.hlibe below. Not sure if it's fine. With it, bothkernel/iomem.candmm/ioremap.ccan useis_ioremap_addr().
Can we just add a ne header for this given that no one else really needs it?
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Baoquan He
If we want to consolidate code, we can move
is_ioremap_addr()toinclude/linux/mm.hlibe below. Not sure if it's fine. With it, bothkernel/iomem.candmm/ioremap.ccan useis_ioremap_addr().Can we just add a ne header for this given that no one else really needs it?
Is it OK like below?
From fe5d4d25afa1e989fa82877c8466a97fc8bd8c93 Mon Sep 17 00:00:00 2001
From: Baoquan He <[email protected]>
Date: Fri, 2 Jun 2023 18:36:48 +0800
Subject: [PATCH] mm: move is_ioremap_addr() into new header file
Content-type: text/plain
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.
--- include/linux/ioremap.h | 29 +++++++++++++++++++++++++++++ include/linux/mm.h | 5 ----- kernel/iomem.c | 1 + mm/ioremap.c | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 include/linux/ioremap.h
include/linux/ioremap.h new file +29 -0
@@ -0,0 +1,29 @@ +/* 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 */
include/linux/mm.h +0 -5
@@ -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);
kernel/iomem.c +1 -0
@@ -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 */
mm/ioremap.c +1 -0
@@ -10,6 +10,7 @@#include <linux/mm.h> #include <linux/io.h> #include <linux/export.h> +#include <linux/ioremap.h> /* * Ioremap often, but not always uses the generic vmalloc area. E.g on
Signature · 1 line
2.34.1
Quoted 2 lines
Christoph Hellwig
Reviewed-byRe: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
Quoted 10 lines · Baoquan He
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Baoquan He
If we want to consolidate code, we can move
is_ioremap_addr()toinclude/linux/mm.hlibe below. Not sure if it's fine. With it, bothkernel/iomem.candmm/ioremap.ccan useis_ioremap_addr().Can we just add a ne header for this given that no one else really needs it?
Is it OK like below?
Looks good to me:
Re: [PATCH v5 RESEND 14/17] mm/ioremap: Consider IOREMAP space in generic ioremap
In reply to Christoph HellwigQuoted 16 lines · Christoph Hellwig
mm/ioremap.c void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, · line 44
Quoted 11 lines · Baoquan He
mm/ioremap.c +5
-0@@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,if (!ioremap_allowed (phys_addr, size,pgprot_val (prot)))return NULL ; +#ifdef IOREMAP_START + area =__get_vm_area_caller (size,VM_IOREMAP ,IOREMAP_START , +IOREMAP_END ,__builtin_return_address (0 )); +#else area =get_vm_area_caller (size,VM_IOREMAP ,__builtin_return_address (0 )); +#endif I think this would be cleaner if we'd just always use
__get_vm_area_callerand at the top of the file add a:
Quoted 7 lines
#ifndef
IOREMAP_START
#defineIOREMAP_STARTVMALLOC_START
#defineIOREMAP_ENDVMALLOC_END
#endifTogether with a little comment that ioremap often, but not always uses the generic vmalloc area.
Great idea, will do as suggested.
PATCH RESEND v5 15/17 powerpc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeFrom: 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().
--- 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(-)
arch/powerpc/Kconfig +1 -0
@@ -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
arch/powerpc/include/asm/io.h +3 -5
@@ -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_protextern 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 iounmapvoid __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);
arch/powerpc/mm/ioremap.c +1 -25
@@ -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 ; -}
arch/powerpc/mm/ioremap_32.c +9 -10
@@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *callphys_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 *callreturn (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);
arch/powerpc/mm/ioremap_64.c +2 -10
@@ -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);
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 15/17] powerpc: mm: Convert to GENERIC_IOREMAP
Quoted 11 lines · Baoquan He
From: Christophe Leroy <[email protected]>
By taking
GENERIC_IOREMAPmethod, the genericgeneric_ioremap_prot(),generic_iounmap(), and their generic wrapperioremap_prot(),ioremap()andiounmap()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 itsioremap_prot(),ioremap()oriounmap(). This change will simplify implementation by removing duplicated codes withgeneric_ioremap_prot()andgeneric_iounmap(), and has the equivalent functioality as before.
Quoted 8 lines
Here, add wrapper functions
ioremap_prot()andiounmap()for powerpc's special operation whenioremap()andiounmap().Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Baoquan He <[email protected]>Cc Michael Ellerman <[email protected]>Cc Nicholas Piggin <[email protected]>
Quoted 178 lines
--- 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(-)arch/powerpc/Kconfig +1
-0@@ -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 PCIarch/powerpc/include/asm/io.h +3
-5@@ -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_protextern 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 iounmapvoid __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);arch/powerpc/mm/ioremap.c +1
-25@@ -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 ; -}arch/powerpc/mm/ioremap_32.c +9
-10@@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *callphys_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 *callreturn (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);arch/powerpc/mm/ioremap_64.c +2
-10@@ -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);Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 15/17] powerpc: mm: Convert to GENERIC_IOREMAP
In reply to Baoquan HeLooks good:
PATCH RESEND v5 16/17 arm64 : mm: add wrapper function ioremap_prot()
In reply to Baoquan HeSince hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain the the specific handling in addition to generic_ioremap_prot() invocation.
--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/include/asm/io.h +1 -2
@@ -139,8 +139,7 @@ extern void __memset_io(volatile void __iomem *, int, size_t);* I/O memory mapping functions. */ -bool ioremap_allowed (phys_addr_t phys_addr,size_t size,unsigned long prot); -#define ioremap_allowed ioremap_allowed +#define ioremap_prot ioremap_prot#define _PAGE_IOREMAP PROT_DEVICE_nGnRE
arch/arm64/mm/ioremap.c +6 -4
@@ -3,20 +3,22 @@#include <linux/mm.h> #include <linux/io.h> -bool ioremap_allowed (phys_addr_t phys_addr,size_t size,unsigned long prot) +void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size, +unsigned long prot) {unsigned long last_addr = phys_addr + size -1 ;/* Don't allow outside PHYS_MASK */ if (last_addr & ~PHYS_MASK ) -return false; +return NULL ;/* Don't allow RAM to be mapped. */ if (WARN_ON (pfn_is_map_memory (__phys_to_pfn (phys_addr)))) -return false; +return NULL ; -return true; +return generic_ioremap_prot (phys_addr, size,__pgprot (prot)); } +EXPORT_SYMBOL (ioremap_prot);/* * Must be called after early_fixmap_init
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 16/17] arm64 : mm: add wrapper function ioremap_prot()
Quoted 8 lines · Baoquan He
Since hook functions
ioremap_allowed()andiounmap_allowed()will be obsoleted, add wrapper functionioremap_prot()to contain the the specific handling in addition togeneric_ioremap_prot()invocation.Signed-off-by Baoquan He <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>
Quoted 54 lines
--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-)arch/arm64/include/asm/io.h +1
-2@@ -139,8 +139,7 @@ extern void __memset_io(volatile void __iomem *, int, size_t);* I/O memory mapping functions. */ -bool ioremap_allowed (phys_addr_t phys_addr,size_t size,unsigned long prot); -#define ioremap_allowed ioremap_allowed +#define ioremap_prot ioremap_prot#define _PAGE_IOREMAP PROT_DEVICE_nGnREarch/arm64/mm/ioremap.c +6
-4@@ -3,20 +3,22 @@#include <linux/mm.h> #include <linux/io.h> -bool ioremap_allowed (phys_addr_t phys_addr,size_t size,unsigned long prot) +void __iomem *ioremap_prot (phys_addr_t phys_addr,size_t size, +unsigned long prot) {unsigned long last_addr = phys_addr + size -1 ;/* Don't allow outside PHYS_MASK */ if (last_addr & ~PHYS_MASK ) -return false; +return NULL ;/* Don't allow RAM to be mapped. */ if (WARN_ON (pfn_is_map_memory (__phys_to_pfn (phys_addr)))) -return false; +return NULL ; -return true; +return generic_ioremap_prot (phys_addr, size,__pgprot (prot)); } +EXPORT_SYMBOL (ioremap_prot);/* * Must be called after early_fixmap_init Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 16/17] arm64 : mm: add wrapper function ioremap_prot()
In reply to Baoquan HeLooks good:
Re: [PATCH v5 RESEND 16/17] arm64 : mm: add wrapper function ioremap_prot()
In reply to Baoquan HeQuoted 4 lines · Baoquan He
Since hook functions
ioremap_allowed()andiounmap_allowed()will be obsoleted, add wrapper functionioremap_prot()to contain the the specific handling in addition togeneric_ioremap_prot()invocation.
Quoted 8 lines
Signed-off-by Baoquan He <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-)
PATCH RESEND v5 17/17 mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed
In reply to Baoquan HeNow there are no users of ioremap_allowed and iounmap_allowed, clean them up.
--- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-)
include/asm-generic/io.h +0 -26
@@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr)#elif defined(CONFIG_GENERIC_IOREMAP )#include <linux/pgtable.h> -/* -* Arch code can implement the following two hooks when using GENERIC_IOREMAP -* ioremap_allowed() return a bool, -* - true means continue to remap -* - false means skip remap and return directly -* iounmap_allowed() return a bool, -* - true means continue to vunmap -* - false means skip vunmap and return directly -*/ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed (phys_addr_t phys_addr,size_t size, -unsigned long prot) -{ -return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed (void *addr) -{ -return true; -} -#endif -void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size,pgprot_t prot);
mm/ioremap.c +0 -6
@@ -32,9 +32,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size =PAGE_ALIGN (size + offset); -if (!ioremap_allowed (phys_addr, size,pgprot_val (prot))) -return NULL ; -#ifdef IOREMAP_START area =__get_vm_area_caller (size,VM_IOREMAP ,IOREMAP_START ,IOREMAP_END ,__builtin_return_address (0 ));
@@ -68,9 +65,6 @@ void generic_iounmap(volatile void __iomem *addr) {void *vaddr = (void *)((unsigned long )addr &PAGE_MASK ); -if (!iounmap_allowed (vaddr)) -return ; -if (is_ioremap_addr (vaddr))vunmap (vaddr); }
Signature · 1 line
2.34.1
Re: [PATCH v5 RESEND 17/17] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed
Quoted 4 lines · Baoquan He
Now there are no users of
ioremap_allowedandiounmap_allowed, clean them up.Signed-off-by Baoquan He <[email protected]>
Quoted 70 lines
--- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-)include/asm-generic/io.h +0
-26@@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr)#elif defined(CONFIG_GENERIC_IOREMAP )#include <linux/pgtable.h> -/* -* Arch code can implement the following two hooks when using GENERIC_IOREMAP -* ioremap_allowed() return a bool, -* - true means continue to remap -* - false means skip remap and return directly -* iounmap_allowed() return a bool, -* - true means continue to vunmap -* - false means skip vunmap and return directly -*/ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed (phys_addr_t phys_addr,size_t size, -unsigned long prot) -{ -return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed (void *addr) -{ -return true; -} -#endif -void __iomem *generic_ioremap_prot (phys_addr_t phys_addr,size_t size,pgprot_t prot);mm/ioremap.c +0
-6@@ -32,9 +32,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size =PAGE_ALIGN (size + offset); -if (!ioremap_allowed (phys_addr, size,pgprot_val (prot))) -return NULL ; -#ifdef IOREMAP_START area =__get_vm_area_caller (size,VM_IOREMAP ,IOREMAP_START ,IOREMAP_END ,__builtin_return_address (0 ));@@ -68,9 +65,6 @@ void generic_iounmap(volatile void __iomem *addr) {void *vaddr = (void *)((unsigned long )addr &PAGE_MASK ); -if (!iounmap_allowed (vaddr)) -return ; -if (is_ioremap_addr (vaddr))vunmap (vaddr); }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v5 RESEND 17/17] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed
In reply to Baoquan HeLooks good:
Re: [PATCH v5 RESEND 17/17] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed
In reply to Baoquan HeQuoted 9 lines · Baoquan He
Now there are no users of
ioremap_allowedandiounmap_allowed, clean them up.Signed-off-by Baoquan He <[email protected]>--- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-)