* [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
2019-09-12 13:49 [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
@ 2019-09-12 13:49 ` Christophe Leroy
2019-11-26 1:13 ` Michael Ellerman
2019-09-12 13:49 ` [PATCH v1 2/4] powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt() Christophe Leroy
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Christophe Leroy @ 2019-09-12 13:49 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
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 <christophe.leroy@c-s.fr>
---
arch/powerpc/mm/mem.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index be941d382c8d..278be4712e10 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -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);
--
2.13.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
2019-09-12 13:49 ` [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init() Christophe Leroy
@ 2019-11-26 1:13 ` Michael Ellerman
2019-11-27 14:43 ` Christophe Leroy
0 siblings, 1 reply; 15+ messages in thread
From: Michael Ellerman @ 2019-11-26 1:13 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
On Thu, 2019-09-12 at 13:49:41 UTC, Christophe Leroy wrote:
> 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 <christophe.leroy@c-s.fr>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f2bb86937d86ebcb0e52f95b6d19aba1d850e601
cheers
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
2019-11-26 1:13 ` Michael Ellerman
@ 2019-11-27 14:43 ` Christophe Leroy
2019-11-28 8:06 ` Christophe Leroy
0 siblings, 1 reply; 15+ messages in thread
From: Christophe Leroy @ 2019-11-27 14:43 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
Le 26/11/2019 à 02:13, Michael Ellerman a écrit :
> On Thu, 2019-09-12 at 13:49:41 UTC, Christophe Leroy wrote:
>> 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 <christophe.leroy@c-s.fr>
>
> 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init()
2019-11-27 14:43 ` Christophe Leroy
@ 2019-11-28 8:06 ` Christophe Leroy
0 siblings, 0 replies; 15+ messages in thread
From: Christophe Leroy @ 2019-11-28 8:06 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
Le 27/11/2019 à 15:43, Christophe Leroy a écrit :
>
>
> Le 26/11/2019 à 02:13, Michael Ellerman a écrit :
>> On Thu, 2019-09-12 at 13:49:41 UTC, Christophe Leroy wrote:
>>> 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 <christophe.leroy@c-s.fr>
>>
>> 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.
>
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 2/4] powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt()
2019-09-12 13:49 [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
2019-09-12 13:49 ` [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init() Christophe Leroy
@ 2019-09-12 13:49 ` Christophe Leroy
2019-11-25 10:47 ` Michael Ellerman
2019-09-12 13:49 ` [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
` (2 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Christophe Leroy @ 2019-09-12 13:49 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
Modify 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);
^
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Fixes: 4cfac2f9c7f1 ("powerpc/mm: Simplify __set_fixmap()")
---
arch/powerpc/include/asm/fixmap.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
index 0cfc365d814b..722289a1d000 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h
@@ -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__ */
--
2.13.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v1 2/4] powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt()
2019-09-12 13:49 ` [PATCH v1 2/4] powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt() Christophe Leroy
@ 2019-11-25 10:47 ` Michael Ellerman
0 siblings, 0 replies; 15+ messages in thread
From: Michael Ellerman @ 2019-11-25 10:47 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1884 bytes --]
On Thu, 2019-09-12 at 13:49:42 UTC, Christophe Leroy wrote:
> Modify 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);
> ^
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Fixes: 4cfac2f9c7f1 ("powerpc/mm: Simplify __set_fixmap()")
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/77693a5fb57be4606a6024ec8e3076f9499b906b
cheers
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP
2019-09-12 13:49 [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
2019-09-12 13:49 ` [PATCH v1 1/4] powerpc/fixmap: don't clear fixmap area in paging_init() Christophe Leroy
2019-09-12 13:49 ` [PATCH v1 2/4] powerpc/fixmap: Use __fix_to_virt() instead of fix_to_virt() Christophe Leroy
@ 2019-09-12 13:49 ` Christophe Leroy
2019-09-12 15:37 ` Aneesh Kumar K.V
2019-11-25 10:47 ` Michael Ellerman
2019-09-12 13:49 ` [PATCH v1 4/4] powerpc/ioremap: warn on early use of ioremap() Christophe Leroy
2019-09-18 13:40 ` [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christoph Hellwig
4 siblings, 2 replies; 15+ messages in thread
From: Christophe Leroy @ 2019-09-12 13:49 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
Add support for GENERIC_EARLY_IOREMAP.
Let's define 16 slots of 256Kbytes each for early ioremap.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
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(+)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6a7c797fa9d2..8fe252962518 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -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
diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
index 9a1d2fc6ceb7..30829120659c 100644
--- a/arch/powerpc/include/asm/Kbuild
+++ b/arch/powerpc/include/asm/Kbuild
@@ -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
diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
index 722289a1d000..d5c4d357bd33 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h
@@ -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
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index a7541edf0cdb..dcffe927f5b9 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -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();
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 44b4c432a273..b85f6a1cc3a1 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -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();
--
2.13.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP
2019-09-12 13:49 ` [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
@ 2019-09-12 15:37 ` Aneesh Kumar K.V
2019-09-12 15:43 ` Christophe Leroy
2019-11-25 10:47 ` Michael Ellerman
1 sibling, 1 reply; 15+ messages in thread
From: Aneesh Kumar K.V @ 2019-09-12 15:37 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, npiggin, hch
Cc: linuxppc-dev, linux-kernel
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> Add support for GENERIC_EARLY_IOREMAP.
>
> Let's define 16 slots of 256Kbytes each for early ioremap.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> 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(+)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 6a7c797fa9d2..8fe252962518 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -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
> diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
> index 9a1d2fc6ceb7..30829120659c 100644
> --- a/arch/powerpc/include/asm/Kbuild
> +++ b/arch/powerpc/include/asm/Kbuild
> @@ -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
> diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
> index 722289a1d000..d5c4d357bd33 100644
> --- a/arch/powerpc/include/asm/fixmap.h
> +++ b/arch/powerpc/include/asm/fixmap.h
> @@ -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
> diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
> index a7541edf0cdb..dcffe927f5b9 100644
> --- a/arch/powerpc/kernel/setup_32.c
> +++ b/arch/powerpc/kernel/setup_32.c
> @@ -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();
>
> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
> index 44b4c432a273..b85f6a1cc3a1 100644
> --- a/arch/powerpc/kernel/setup_64.c
> +++ b/arch/powerpc/kernel/setup_64.c
> @@ -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();
>
Can we remove early_ioremap_range() after this?
-aneesh
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP
2019-09-12 15:37 ` Aneesh Kumar K.V
@ 2019-09-12 15:43 ` Christophe Leroy
[not found] ` <874l1hsed6.fsf@linux.ibm.com>
0 siblings, 1 reply; 15+ messages in thread
From: Christophe Leroy @ 2019-09-12 15:43 UTC (permalink / raw)
To: Aneesh Kumar K.V, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, npiggin, hch
Cc: linuxppc-dev, linux-kernel
Le 12/09/2019 à 17:37, Aneesh Kumar K.V a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> Add support for GENERIC_EARLY_IOREMAP.
>>
>> Let's define 16 slots of 256Kbytes each for early ioremap.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> 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(+)
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 6a7c797fa9d2..8fe252962518 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -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
>> diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
>> index 9a1d2fc6ceb7..30829120659c 100644
>> --- a/arch/powerpc/include/asm/Kbuild
>> +++ b/arch/powerpc/include/asm/Kbuild
>> @@ -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
>> diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
>> index 722289a1d000..d5c4d357bd33 100644
>> --- a/arch/powerpc/include/asm/fixmap.h
>> +++ b/arch/powerpc/include/asm/fixmap.h
>> @@ -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
>> diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
>> index a7541edf0cdb..dcffe927f5b9 100644
>> --- a/arch/powerpc/kernel/setup_32.c
>> +++ b/arch/powerpc/kernel/setup_32.c
>> @@ -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();
>>
>> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
>> index 44b4c432a273..b85f6a1cc3a1 100644
>> --- a/arch/powerpc/kernel/setup_64.c
>> +++ b/arch/powerpc/kernel/setup_64.c
>> @@ -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();
>>
>
> Can we remove early_ioremap_range() after this?
>
Yes, once all early callers of ioremap functions are converted to using
early_ioremap()
Christophe
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP
2019-09-12 13:49 ` [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
2019-09-12 15:37 ` Aneesh Kumar K.V
@ 2019-11-25 10:47 ` Michael Ellerman
1 sibling, 0 replies; 15+ messages in thread
From: Michael Ellerman @ 2019-11-25 10:47 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
On Thu, 2019-09-12 at 13:49:43 UTC, Christophe Leroy wrote:
> Add support for GENERIC_EARLY_IOREMAP.
>
> Let's define 16 slots of 256Kbytes each for early ioremap.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/265c3491c4bc8d40587996d6ee2f447a7ccfb4f3
cheers
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 4/4] powerpc/ioremap: warn on early use of ioremap()
2019-09-12 13:49 [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
` (2 preceding siblings ...)
2019-09-12 13:49 ` [PATCH v1 3/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
@ 2019-09-12 13:49 ` Christophe Leroy
2019-11-25 10:47 ` Michael Ellerman
2019-09-18 13:40 ` [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christoph Hellwig
4 siblings, 1 reply; 15+ messages in thread
From: Christophe Leroy @ 2019-09-12 13:49 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin,
hch
Cc: linuxppc-dev, linux-kernel
Powerpc 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.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/mm/ioremap_32.c | 1 +
arch/powerpc/mm/ioremap_64.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c
index f36121f25243..743e11384dea 100644
--- a/arch/powerpc/mm/ioremap_32.c
+++ b/arch/powerpc/mm/ioremap_32.c
@@ -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)
diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c
index fd29e51700cd..50a99d9684f7 100644
--- a/arch/powerpc/mm/ioremap_64.c
+++ b/arch/powerpc/mm/ioremap_64.c
@@ -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;
--
2.13.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP
2019-09-12 13:49 [PATCH v1 0/4] powerpc: Add support for GENERIC_EARLY_IOREMAP Christophe Leroy
` (3 preceding siblings ...)
2019-09-12 13:49 ` [PATCH v1 4/4] powerpc/ioremap: warn on early use of ioremap() Christophe Leroy
@ 2019-09-18 13:40 ` Christoph Hellwig
4 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-09-18 13:40 UTC (permalink / raw)
To: Christophe Leroy; +Cc: linux-kernel, npiggin, hch, Paul Mackerras, linuxppc-dev
On Thu, Sep 12, 2019 at 01:49:40PM +0000, Christophe Leroy wrote:
> 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.
Thanks, this looks pretty nice!
^ permalink raw reply [flat|nested] 15+ messages in thread