powerpc: Add support for GENERIC_EARLY_IOREMAP
cover powerpc: Add support for GENERIC_EARLY_IOREMAP
This series adds support for GENERIC_EARLY_IOREMAP on powerpc.
It also adds a warning in the standard ioremap() when it's called before vmalloc is available in order to help locate those users.
Next step will be to incrementaly migrate all early users of ioremap() to using early_ioremap() or other method.
Once they are all converted we can drop all the logic behind ioremap_bot.
Christophe Leroy (4):
powerpc/fixmap: don't clear fixmap area in paging_init() powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt()
powerpc: Add support for GENERIC_EARLY_IOREMAP powerpc/ioremap: warn on early use of ioremap()
arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/fixmap.h | 19 ++++++++++++++++++- arch/powerpc/kernel/setup_32.c | 3 +++ arch/powerpc/kernel/setup_64.c | 3 +++ arch/powerpc/mm/ioremap_32.c | 1 + arch/powerpc/mm/ioremap_64.c | 2 ++ arch/powerpc/mm/mem.c | 8 -------- 8 files changed, 29 insertions(+), 9 deletions(-)
Signature · 1 line
2.13.3
PATCH 1/4 powerpc/fixmap: don't clear fixmap area in paging_init()
fixmap is intended to map things permanently like the IMMR region on FSL SOC (8xx, 83xx, ...), so don't clear it when initialising paging()
--- arch/powerpc/mm/mem.c | 8 -------- 1 file changed, 8 deletions(-)
arch/powerpc/mm/mem.c +0 -8
@@ -216,14 +216,6 @@ void __init paging_init(void)unsigned long long total_ram =memblock_phys_mem_size ();phys_addr_t top_of_ram =memblock_end_of_DRAM (); -#ifdef CONFIG_PPC32 -unsigned long v =__fix_to_virt (__end_of_fixed_addresses -1 ); -unsigned long end =__fix_to_virt (FIX_HOLE ); - -for (; v < end; v +=PAGE_SIZE ) -map_kernel_page (v,0 ,__pgprot (0 ));/* XXX gross */ -#endif -#ifdef CONFIG_HIGHMEM map_kernel_page (PKMAP_BASE ,0 ,__pgprot (0 ));/* XXX gross */ pkmap_page_table =virt_to_kpte (PKMAP_BASE );
Signature · 1 line
2.13.3
Michael Ellerman
AppliedRe: [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
Quoted 4 lines · Christophe Leroy
fixmap is intended to map things permanently like the IMMR region on FSL SOC (8xx, 83xx, ...), so don't clear it when initialising
paging()Signed-off-by Christophe Leroy <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f2bb86937d86ebcb0e52f95b6d19aba1d850e601
cheers
Re: [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
Le 26/11/2019 à 02:13, Michael Ellerman a écrit :
Quoted 10 lines · Christophe Leroy
Quoted 4 lines
fixmap is intended to map things permanently like the IMMR region on FSL SOC (8xx, 83xx, ...), so don't clear it when initialising
paging()Signed-off-by Christophe Leroy <[email protected]>Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f2bb86937d86ebcb0e52f95b6d19aba1d850e601
Hi,
What happened ?
It looks like it is gone in today's powerpc next.
Christophe
Re: [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
Le 27/11/2019 à 15:43, Christophe Leroy a écrit :
Quoted 11 lines
Le 26/11/2019 à 02:13, Michael Ellerman a écrit :
Quoted 8 lines · Christophe Leroy
Quoted 4 lines
fixmap is intended to map things permanently like the IMMR region on FSL SOC (8xx, 83xx, ...), so don't clear it when initialising
paging()Signed-off-by Christophe Leroy <[email protected]>Applied to powerpc next, thanks.
Quoted 9 lines
Hi,
What happened ?
It looks like it is gone in today's powerpc next.
I see it back today in powerpc/merge, thanks.
The issue is it is crashing with HIGHMEM, indeed exactly the same as you saw with "[PATCH] powerpc/8xx: Fix permanently mapped IMMR region.", since that was exactly the same code.
I sent a fix for it, and I also rebased "[PATCH] powerpc/8xx: Fix permanently mapped IMMR region." into v2 to exclude from it the already merged part.
It would be wise if you could merge both.
Thanks
Christophe
PATCH 2/4 powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt()
In reply to Christophe LeroyModify back __set_fixmap() to using __fix_to_virt() instead of fix_to_virt() otherwise the following happens because it seems GCC doesn't see idx as a builtin const.
CC mm/early_ioremap.o
In file included from ./include/linux/kernel.h:11:0,
from mm/early_ioremap.c:11:
In function ‘fix_to_virt’,
inlined from ‘__set_fixmap’ at ./arch/powerpc/include/asm/fixmap.h:87:2,
inlined from ‘__early_ioremap’ at mm/early_ioremap.c:156:4:./include/linux/compiler.h:350:38: error: call to ‘__compiletime_assert_32’ declared with attribute error: BUILD_BUG_ON failed: idx >= __end_of_fixed_addresses
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
^
./include/linux/compiler.h:331:4: note: in definition of macro ‘__compiletime_assert’
prefix ## suffix(); \
^./include/linux/compiler.h:350:2: note: in expansion of macro ‘_compiletime_assert’
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’
BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
^
--- arch/powerpc/include/asm/fixmap.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/fixmap.h +6 -1
@@ -77,7 +77,12 @@ enum fixed_addresses {static inline void __set_fixmap (enum fixed_addresses idx,phys_addr_t phys,pgprot_t flags) { -map_kernel_page (fix_to_virt (idx), phys, flags); +if (__builtin_constant_p (idx)) +BUILD_BUG_ON (idx >= __end_of_fixed_addresses); +else if (WARN_ON (idx >= __end_of_fixed_addresses)) +return ; + +map_kernel_page (__fix_to_virt (idx), phys, flags); }#endif /* !__ASSEMBLY__ */
Signature · 1 line
2.13.3
Michael Ellerman
AppliedRe: [PATCH v1 2/4] powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt()
Quoted 29 lines · Christophe Leroy
Modify back
__set_fixmap()to using__fix_to_virt()instead offix_to_virt()otherwise the following happens because it seems GCC doesn't see idx as a builtin const.CC
mm/early_ioremap.o
In file included from./include/linux/kernel.h:11:0,from mm/early_ioremap.c:11:In function ‘fix_to_virt’,
inlined from ‘__set_fixmap’ at./arch/powerpc/include/asm/fixmap.h:87:2,
inlined from ‘__early_ioremap’ atmm/early_ioremap.c:156:4:./include/linux/compiler.h:350:38: error: call to ‘__compiletime_assert_32’ declared with attribute error:BUILD_BUG_ONfailed: idx >=__end_of_fixed_addresses
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)^ ./include/linux/compiler.h:331:4: note: in definition of macro ‘__compiletime_assert’ prefix ## suffix(); \ ^
./include/linux/compiler.h:350:2: note: in expansion of macro ‘_compiletime_assert’
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)^./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^
./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’
BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
^
Quoted 2 lines
Signed-off-by Christophe Leroy <[email protected]>Fixes 4cfac2f9c7f1 ("powerpc/mm: Simplify __set_fixmap()")
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/77693a5fb57be4606a6024ec8e3076f9499b906b
cheers
PATCH 3/4 powerpc: Add support for GENERIC_EARLY_IOREMAP
In reply to Christophe LeroyAdd support for GENERIC_EARLY_IOREMAP.
Let's define 16 slots of 256Kbytes each for early ioremap.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/fixmap.h | 12 ++++++++++++ arch/powerpc/kernel/setup_32.c | 3 +++ arch/powerpc/kernel/setup_64.c | 3 +++ 5 files changed, 20 insertions(+)
arch/powerpc/Kconfig +1 -0
@@ -161,6 +161,7 @@ config PPC select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC + select GENERIC_EARLY_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI
arch/powerpc/include/asm/Kbuild +1 -0
@@ -12,3 +12,4 @@ generic-y += preempt.h generic-y += vtime.h generic-y += msi.h generic-y += simd.h +generic-y += early_ioremap.h
arch/powerpc/include/asm/fixmap.h +12 -0
@@ -15,6 +15,7 @@#define _ASM_FIXMAP_H#ifndef __ASSEMBLY__ +#include <linux/sizes.h> #include <asm/page.h> #include <asm/pgtable.h> #ifdef CONFIG_HIGHMEM
@@ -64,6 +65,14 @@ enum fixed_addresses {FIX_IMMR_SIZE , #endif/* FIX_PCIE_MCFG, */ + __end_of_permanent_fixed_addresses, + +#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) +#define FIX_BTMAPS_SLOTS 16 +#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) + +FIX_BTMAP_END = __end_of_permanent_fixed_addresses, +FIX_BTMAP_BEGIN =FIX_BTMAP_END +TOTAL_FIX_BTMAPS -1 , __end_of_fixed_addresses };
@@ -71,6 +80,7 @@ enum fixed_addresses {#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG +#define FIXMAP_PAGE_IO PAGE_KERNEL_NCG#include <asm-generic/fixmap.h>
@@ -85,5 +95,7 @@ static inline void __set_fixmap(enum fixed_addresses idx,map_kernel_page (__fix_to_virt (idx), phys, flags); } +#define __early_set_fixmap __set_fixmap +#endif /* !__ASSEMBLY__ */ #endif
arch/powerpc/kernel/setup_32.c +3 -0
@@ -44,6 +44,7 @@#include <asm/asm-prototypes.h> #include <asm/kdump.h> #include <asm/feature-fixups.h> +#include <asm/early_ioremap.h> #include "setup.h"
@@ -80,6 +81,8 @@ notrace void __init machine_init(u64 dt_ptr)/* Configure static keys first, now that we're relocated. */ setup_feature_keys (); +early_ioremap_setup (); +/* Enable early debugging if any specified (see udbg.h) */ udbg_early_init ();
arch/powerpc/kernel/setup_64.c +3 -0
@@ -65,6 +65,7 @@#include <asm/hw_irq.h> #include <asm/feature-fixups.h> #include <asm/kup.h> +#include <asm/early_ioremap.h> #include "setup.h"
@@ -338,6 +339,8 @@ void __init early_setup(unsigned long dt_ptr)apply_feature_fixups ();setup_feature_keys (); +early_ioremap_setup (); +/* Initialize the hash table or TLB handling */ early_init_mmu ();
Signature · 1 line
2.13.3
Quoted 111 lines · Christophe Leroy
Add support for
GENERIC_EARLY_IOREMAP.Let's define 16 slots of 256Kbytes each for early ioremap.
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/fixmap.h | 12 ++++++++++++ arch/powerpc/kernel/setup_32.c | 3 +++ arch/powerpc/kernel/setup_64.c | 3 +++ 5 files changed, 20 insertions(+)arch/powerpc/Kconfig +1
-0@@ -161,6 +161,7 @@ config PPC select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC + select GENERIC_EARLY_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCIarch/powerpc/include/asm/Kbuild +1
-0@@ -12,3 +12,4 @@ generic-y += preempt.h generic-y += vtime.h generic-y += msi.h generic-y += simd.h +generic-y += early_ioremap.harch/powerpc/include/asm/fixmap.h +12
-0@@ -15,6 +15,7 @@#define _ASM_FIXMAP_H#ifndef __ASSEMBLY__ +#include <linux/sizes.h> #include <asm/page.h> #include <asm/pgtable.h> #ifdef CONFIG_HIGHMEM @@ -64,6 +65,14 @@ enum fixed_addresses {FIX_IMMR_SIZE , #endif/* FIX_PCIE_MCFG, */ + __end_of_permanent_fixed_addresses, + +#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) +#define FIX_BTMAPS_SLOTS 16 +#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) + +FIX_BTMAP_END = __end_of_permanent_fixed_addresses, +FIX_BTMAP_BEGIN =FIX_BTMAP_END +TOTAL_FIX_BTMAPS -1 , __end_of_fixed_addresses };@@ -71,6 +80,7 @@ enum fixed_addresses {#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG +#define FIXMAP_PAGE_IO PAGE_KERNEL_NCG#include <asm-generic/fixmap.h> @@ -85,5 +95,7 @@ static inline void __set_fixmap(enum fixed_addresses idx,map_kernel_page (__fix_to_virt (idx), phys, flags); } +#define __early_set_fixmap __set_fixmap +#endif /* !__ASSEMBLY__ */ #endif arch/powerpc/kernel/setup_32.c +3
-0@@ -44,6 +44,7 @@#include <asm/asm-prototypes.h> #include <asm/kdump.h> #include <asm/feature-fixups.h> +#include <asm/early_ioremap.h> #include "setup.h" @@ -80,6 +81,8 @@ notrace void __init machine_init(u64 dt_ptr)/* Configure static keys first, now that we're relocated. */ setup_feature_keys (); +early_ioremap_setup (); +/* Enable early debugging if any specified (see udbg.h) */ udbg_early_init ();arch/powerpc/kernel/setup_64.c +1
-0@@ -65,6 +65,7 @@#include <asm/hw_irq.h> #include <asm/feature-fixups.h> #include <asm/kup.h> +#include <asm/early_ioremap.h> #include "setup.h"
arch/powerpc/kernel/setup_64.c void __init early_setup(unsigned long dt_ptr) · line 346
Quoted 8 lines
arch/powerpc/kernel/setup_64.c +2
-0@@ -338,6 +339,8 @@ void __init early_setup(unsigned long dt_ptr)apply_feature_fixups ();setup_feature_keys (); +early_ioremap_setup (); +/* Initialize the hash table or TLB handling */ early_init_mmu ();
Can we remove early_ioremap_range() after this?
-aneesh
Le 12/09/2019 à 17:37, Aneesh Kumar K.V a écrit :
Quoted 116 lines
Quoted 114 lines · Christophe Leroy
Add support for
GENERIC_EARLY_IOREMAP.Let's define 16 slots of 256Kbytes each for early ioremap.
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/fixmap.h | 12 ++++++++++++ arch/powerpc/kernel/setup_32.c | 3 +++ arch/powerpc/kernel/setup_64.c | 3 +++ 5 files changed, 20 insertions(+)arch/powerpc/Kconfig +1
-0@@ -161,6 +161,7 @@ config PPC select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC + select GENERIC_EARLY_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCIarch/powerpc/include/asm/Kbuild +1
-0@@ -12,3 +12,4 @@ generic-y += preempt.h generic-y += vtime.h generic-y += msi.h generic-y += simd.h +generic-y += early_ioremap.harch/powerpc/include/asm/fixmap.h +12
-0@@ -15,6 +15,7 @@#define _ASM_FIXMAP_H#ifndef __ASSEMBLY__ +#include <linux/sizes.h> #include <asm/page.h> #include <asm/pgtable.h> #ifdef CONFIG_HIGHMEM @@ -64,6 +65,14 @@ enum fixed_addresses {FIX_IMMR_SIZE , #endif/* FIX_PCIE_MCFG, */ + __end_of_permanent_fixed_addresses, + +#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) +#define FIX_BTMAPS_SLOTS 16 +#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) + +FIX_BTMAP_END = __end_of_permanent_fixed_addresses, +FIX_BTMAP_BEGIN =FIX_BTMAP_END +TOTAL_FIX_BTMAPS -1 , __end_of_fixed_addresses };@@ -71,6 +80,7 @@ enum fixed_addresses {#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG +#define FIXMAP_PAGE_IO PAGE_KERNEL_NCG#include <asm-generic/fixmap.h> @@ -85,5 +95,7 @@ static inline void __set_fixmap(enum fixed_addresses idx,map_kernel_page (__fix_to_virt (idx), phys, flags); } +#define __early_set_fixmap __set_fixmap +#endif /* !__ASSEMBLY__ */ #endif arch/powerpc/kernel/setup_32.c +3
-0@@ -44,6 +44,7 @@#include <asm/asm-prototypes.h> #include <asm/kdump.h> #include <asm/feature-fixups.h> +#include <asm/early_ioremap.h> #include "setup.h" @@ -80,6 +81,8 @@ notrace void __init machine_init(u64 dt_ptr)/* Configure static keys first, now that we're relocated. */ setup_feature_keys (); +early_ioremap_setup (); +/* Enable early debugging if any specified (see udbg.h) */ udbg_early_init ();arch/powerpc/kernel/setup_64.c +1
-0@@ -65,6 +65,7 @@#include <asm/hw_irq.h> #include <asm/feature-fixups.h> #include <asm/kup.h> +#include <asm/early_ioremap.h> #include "setup.h" @@ -338,6 +339,8 @@ void __init early_setup(unsigned long dt_ptr)apply_feature_fixups ();setup_feature_keys ();
Quoted 8 lines
arch/powerpc/kernel/setup_64.c void __init early_setup(unsigned long dt_ptr) · line 346
Quoted 5 lines
arch/powerpc/kernel/setup_64.c +2
-0+early_ioremap_setup (); +/* Initialize the hash table or TLB handling */ early_init_mmu ();Can we remove
early_ioremap_range()after this?
Yes, once all early callers of ioremap functions are converted to using early_ioremap()
Christophe
A message that is not in the archive (sent off-list or not yet received): [email protected]
Le 12/09/2019 à 17:50, Aneesh Kumar K.V a écrit :
Quoted 131 lines
Quoted 126 lines · Christophe Leroy
Le 12/09/2019 à 17:37, Aneesh Kumar K.V a écrit :
Quoted 116 lines
Quoted 114 lines · Christophe Leroy
Add support for
GENERIC_EARLY_IOREMAP.Let's define 16 slots of 256Kbytes each for early ioremap.
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/fixmap.h | 12 ++++++++++++ arch/powerpc/kernel/setup_32.c | 3 +++ arch/powerpc/kernel/setup_64.c | 3 +++ 5 files changed, 20 insertions(+)arch/powerpc/Kconfig +1
-0@@ -161,6 +161,7 @@ config PPC select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC + select GENERIC_EARLY_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCIarch/powerpc/include/asm/Kbuild +1
-0@@ -12,3 +12,4 @@ generic-y += preempt.h generic-y += vtime.h generic-y += msi.h generic-y += simd.h +generic-y += early_ioremap.harch/powerpc/include/asm/fixmap.h +12
-0@@ -15,6 +15,7 @@#define _ASM_FIXMAP_H#ifndef __ASSEMBLY__ +#include <linux/sizes.h> #include <asm/page.h> #include <asm/pgtable.h> #ifdef CONFIG_HIGHMEM @@ -64,6 +65,14 @@ enum fixed_addresses {FIX_IMMR_SIZE , #endif/* FIX_PCIE_MCFG, */ + __end_of_permanent_fixed_addresses, + +#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) +#define FIX_BTMAPS_SLOTS 16 +#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) + +FIX_BTMAP_END = __end_of_permanent_fixed_addresses, +FIX_BTMAP_BEGIN =FIX_BTMAP_END +TOTAL_FIX_BTMAPS -1 , __end_of_fixed_addresses };@@ -71,6 +80,7 @@ enum fixed_addresses {#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG +#define FIXMAP_PAGE_IO PAGE_KERNEL_NCG#include <asm-generic/fixmap.h> @@ -85,5 +95,7 @@ static inline void __set_fixmap(enum fixed_addresses idx,map_kernel_page (__fix_to_virt (idx), phys, flags); } +#define __early_set_fixmap __set_fixmap +#endif /* !__ASSEMBLY__ */ #endif arch/powerpc/kernel/setup_32.c +3
-0@@ -44,6 +44,7 @@#include <asm/asm-prototypes.h> #include <asm/kdump.h> #include <asm/feature-fixups.h> +#include <asm/early_ioremap.h> #include "setup.h" @@ -80,6 +81,8 @@ notrace void __init machine_init(u64 dt_ptr)/* Configure static keys first, now that we're relocated. */ setup_feature_keys (); +early_ioremap_setup (); +/* Enable early debugging if any specified (see udbg.h) */ udbg_early_init ();arch/powerpc/kernel/setup_64.c +1
-0@@ -65,6 +65,7 @@#include <asm/hw_irq.h> #include <asm/feature-fixups.h> #include <asm/kup.h> +#include <asm/early_ioremap.h> #include "setup.h" @@ -338,6 +339,8 @@ void __init early_setup(unsigned long dt_ptr)apply_feature_fixups ();setup_feature_keys ();Quoted 8 lines
arch/powerpc/kernel/setup_64.c void __init early_setup(unsigned long dt_ptr) · line 346
Quoted 5 lines
arch/powerpc/kernel/setup_64.c +2
-0+early_ioremap_setup (); +/* Initialize the hash table or TLB handling */ early_init_mmu ();Can we remove
early_ioremap_range()after this?Quoted 2 lines
Yes, once all early callers of ioremap functions are converted to using
early_ioremap()
Quoted 9 lines
Why can't we switch the early callers to
early_ioremapand print a warning?ie,
if (!slab_available()) { pr_warn("switch to early_ioremap"); early_ioremap(); }
Because:
- early_iounmap() requires the size of the area to be freed unlike iounmap()
- early_ioremap() is for ephemeral mappings. All early mapping must be gone at the end of init (this is verified by late_initcall(check_early_ioremap_leak))
Second point means another approach has to be taken for installing early permanent mapping, for instance by using fixmaps.
Christophe
Michael Ellerman
AppliedQuoted 5 lines · Christophe Leroy
Add support for
GENERIC_EARLY_IOREMAP.Let's define 16 slots of 256Kbytes each for early ioremap.
Signed-off-by Christophe Leroy <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/265c3491c4bc8d40587996d6ee2f447a7ccfb4f3
cheers
PATCH 4/4 powerpc/ioremap: warn on early use of ioremap()
In reply to Christophe LeroyPowerpc now has EARLY_IOREMAP.
Next step is to convert all early users of ioremap() to early_ioremap().
Add a warning to help locate those users.
--- arch/powerpc/mm/ioremap_32.c | 1 + arch/powerpc/mm/ioremap_64.c | 2 ++ 2 files changed, 3 insertions(+)
arch/powerpc/mm/ioremap_32.c +1 -0
@@ -68,6 +68,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call/* * Should check if it is a candidate for a BAT mapping */ +pr_warn ("ioremap() called early from %pS. Use early_ioremap() instead\n" , caller); err =early_ioremap_range (ioremap_bot - size, p, size, prot);if (err)
arch/powerpc/mm/ioremap_64.c +2 -0
@@ -81,6 +81,8 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size,if (slab_is_available ())return do_ioremap (paligned, offset, size, prot, caller); +pr_warn ("ioremap() called early from %pS. Use early_ioremap() instead\n" , caller); + err =early_ioremap_range (ioremap_bot, paligned, size, prot);if (err)return NULL ;
Signature · 1 line
2.13.3
Michael Ellerman
AppliedRe: [PATCH v1 4/4] powerpc/ioremap: warn on early use of ioremap()
Quoted 8 lines · Christophe Leroy
Powerpc now has
EARLY_IOREMAP.Next step is to convert all early users of
ioremap()toearly_ioremap().Add a warning to help locate those users.
Signed-off-by Christophe Leroy <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/d538aadc2718a95bfd80095c66ea814824535b34
cheers
Quoted 10 lines · Christophe Leroy
This series adds support for
GENERIC_EARLY_IOREMAPon powerpc.It also adds a warning in the standard
ioremap()when it's called before vmalloc is available in order to help locate those users.Next step will be to incrementaly migrate all early users of
ioremap()to usingearly_ioremap()or other method.Once they are all converted we can drop all the logic behind
ioremap_bot.
Thanks, this looks pretty nice!