[PATCH stable 4.9 2/2] arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed
From: Arnd Bergmann [ Upstream commit cef397038167ac15d085914493d6c86385773709 ] Stefan Agner reported a bug when using zsram on 32-bit Arm machines with RAM above the 4GB address boundary: Unable to handle kernel NULL pointer dereference at virtual address pgd = a27bd01c [] *pgd=236a0003, *pmd=1ffa64003 Internal error: Oops: 207 [#1] SMP ARM Modules linked in: mdio_bcm_unimac(+) brcmfmac cfg80211 brcmutil raspberrypi_hwmon hci_uart crc32_arm_ce bcm2711_thermal phy_generic genet CPU: 0 PID: 123 Comm: mkfs.ext4 Not tainted 5.9.6 #1 Hardware name: BCM2711 PC is at zs_map_object+0x94/0x338 LR is at zram_bvec_rw.constprop.0+0x330/0xa64 pc : []lr : []psr: 6013 sp : e376bbe0 ip : fp : c1e2921c r10: 0002 r9 : c1dda730 r8 : r7 : e8ff7a00 r6 : r5 : 02f9ffa0 r4 : e371 r3 : 000fdffe r2 : c1e0ce80 r1 : ebf979a0 r0 : Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 30c5383d Table: 235c2a80 DAC: fffd Process mkfs.ext4 (pid: 123, stack limit = 0x495a22e6) Stack: (0xe376bbe0 to 0xe376c000) As it turns out, zsram needs to know the maximum memory size, which is defined in MAX_PHYSMEM_BITS when CONFIG_SPARSEMEM is set, or in MAX_POSSIBLE_PHYSMEM_BITS on the x86 architecture. The same problem will be hit on all 32-bit architectures that have a physical address space larger than 4GB and happen to not enable sparsemem and include asm/sparsemem.h from asm/pgtable.h. After the initial discussion, I suggested just always defining MAX_POSSIBLE_PHYSMEM_BITS whenever CONFIG_PHYS_ADDR_T_64BIT is set, or provoking a build error otherwise. This addresses all configurations that can currently have this runtime bug, but leaves all other configurations unchanged. I looked up the possible number of bits in source code and datasheets, here is what I found: - on ARC, CONFIG_ARC_HAS_PAE40 controls whether 32 or 40 bits are used - on ARM, CONFIG_LPAE enables 40 bit addressing, without it we never support more than 32 bits, even though supersections in theory allow up to 40 bits as well. - on MIPS, some MIPS32r1 or later chips support 36 bits, and MIPS32r5 XPA supports up to 60 bits in theory, but 40 bits are more than anyone will ever ship - On PowerPC, there are three different implementations of 36 bit addressing, but 32-bit is used without CONFIG_PTE_64BIT - On RISC-V, the normal page table format can support 34 bit addressing. There is no highmem support on RISC-V, so anything above 2GB is unused, but it might be useful to eventually support CONFIG_ZRAM for high pages. Fixes: 61989a80fb3a ("staging: zsmalloc: zsmalloc memory allocation library") Fixes: 02390b87a945 ("mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS") Acked-by: Thomas Bogendoerfer Reviewed-by: Stefan Agner Tested-by: Stefan Agner Acked-by: Mike Rapoport Link: https://lore.kernel.org/linux-mm/bdfa44bf1c570b05d6c70898e2bbb0acf234ecdf.1604762181.git.ste...@agner.ch/ Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin [florian: patch arch/powerpc/include/asm/pte-common.h for 4.9.y removed arch/riscv/include/asm/pgtable.h which does not exist] Signed-off-by: Florian Fainelli --- arch/arc/include/asm/pgtable.h| 2 ++ arch/arm/include/asm/pgtable-2level.h | 2 ++ arch/arm/include/asm/pgtable-3level.h | 2 ++ arch/mips/include/asm/pgtable-32.h| 3 +++ arch/powerpc/include/asm/pte-common.h | 2 ++ include/asm-generic/pgtable.h | 13 + 6 files changed, 24 insertions(+) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index c10f5cb203e6..81198a6773c6 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -137,8 +137,10 @@ #ifdef CONFIG_ARC_HAS_PAE40 #define PTE_BITS_NON_RWX_IN_PD1(0xff | PAGE_MASK | _PAGE_CACHEABLE) +#define MAX_POSSIBLE_PHYSMEM_BITS 40 #else #define PTE_BITS_NON_RWX_IN_PD1(PAGE_MASK | _PAGE_CACHEABLE) +#define MAX_POSSIBLE_PHYSMEM_BITS 32 #endif /** diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index 92fd2c8a9af0..6154902bed83 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -78,6 +78,8 @@ #define PTE_HWTABLE_OFF(PTE_HWTABLE_PTRS * sizeof(pte_t)) #define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32)) +#define MAX_POSSIBLE_PHYSMEM_BITS 32 + /* * PMD_SHIFT determines the size of the area a second-level page table can map * PGDIR_SHIFT determines what a third-level page table entry can map diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 2a029bceaf2f..35807e611b6e 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -37
[PATCH stable 4.9 1/2] mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
From: "Kirill A. Shutemov" commit 02390b87a9459937cdb299e6b34ff33992512ec7 upstream With boot-time switching between paging mode we will have variable MAX_PHYSMEM_BITS. Let's use the maximum variable possible for CONFIG_X86_5LEVEL=y configuration to define zsmalloc data structures. The patch introduces MAX_POSSIBLE_PHYSMEM_BITS to cover such case. It also suits well to handle PAE special case. Signed-off-by: Kirill A. Shutemov Reviewed-by: Nitin Gupta Acked-by: Minchan Kim Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Sergey Senozhatsky Cc: Thomas Gleixner Cc: linux...@kvack.org Link: http://lkml.kernel.org/r/20180214111656.88514-3-kirill.shute...@linux.intel.com Signed-off-by: Ingo Molnar [florian: drop arch/x86/include/asm/pgtable_64_types.h changes since there is no CONFIG_X86_5LEVEL] Signed-off-by: Florian Fainelli --- arch/x86/include/asm/pgtable-3level_types.h | 1 + mm/zsmalloc.c | 13 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h index bcc89625ebe5..f3f719d59e61 100644 --- a/arch/x86/include/asm/pgtable-3level_types.h +++ b/arch/x86/include/asm/pgtable-3level_types.h @@ -42,5 +42,6 @@ typedef union { */ #define PTRS_PER_PTE 512 +#define MAX_POSSIBLE_PHYSMEM_BITS 36 #endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */ diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 8db3c2b27a17..2b7bfd97587a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -83,18 +83,19 @@ * This is made more complicated by various memory models and PAE. */ -#ifndef MAX_PHYSMEM_BITS -#ifdef CONFIG_HIGHMEM64G -#define MAX_PHYSMEM_BITS 36 -#else /* !CONFIG_HIGHMEM64G */ +#ifndef MAX_POSSIBLE_PHYSMEM_BITS +#ifdef MAX_PHYSMEM_BITS +#define MAX_POSSIBLE_PHYSMEM_BITS MAX_PHYSMEM_BITS +#else /* * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just * be PAGE_SHIFT */ -#define MAX_PHYSMEM_BITS BITS_PER_LONG +#define MAX_POSSIBLE_PHYSMEM_BITS BITS_PER_LONG #endif #endif -#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) + +#define _PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT) /* * Memory for allocating for handle keeps object position by -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH stable 4.9 0/2] zsmalloc MAX_POSSIBLE_PHYSMEM_BITS
This patch series is a back port necessary to address the problem reported by Stefan Agner: https://lore.kernel.org/linux-mm/bdfa44bf1c570b05d6c70898e2bbb0acf234ecdf.1604762181.git.ste...@agner.ch/ but which ended up being addressed by Arnd in a slightly different way from Stefan's submission. The first patch from Kirill is back ported in order to have MAX_POSSIBLE_PHYSMEM_BITS be acted on my the zsmalloc.c code. Arnd Bergmann (1): arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed Kirill A. Shutemov (1): mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS arch/arc/include/asm/pgtable.h | 2 ++ arch/arm/include/asm/pgtable-2level.h | 2 ++ arch/arm/include/asm/pgtable-3level.h | 2 ++ arch/mips/include/asm/pgtable-32.h | 3 +++ arch/powerpc/include/asm/pte-common.h | 2 ++ arch/x86/include/asm/pgtable-3level_types.h | 1 + include/asm-generic/pgtable.h | 13 + mm/zsmalloc.c | 13 +++-- 8 files changed, 32 insertions(+), 6 deletions(-) -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH stable 4.14 1/2] mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
From: "Kirill A. Shutemov" commit 02390b87a9459937cdb299e6b34ff33992512ec7 upstream With boot-time switching between paging mode we will have variable MAX_PHYSMEM_BITS. Let's use the maximum variable possible for CONFIG_X86_5LEVEL=y configuration to define zsmalloc data structures. The patch introduces MAX_POSSIBLE_PHYSMEM_BITS to cover such case. It also suits well to handle PAE special case. Signed-off-by: Kirill A. Shutemov Reviewed-by: Nitin Gupta Acked-by: Minchan Kim Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Sergey Senozhatsky Cc: Thomas Gleixner Cc: linux...@kvack.org Link: http://lkml.kernel.org/r/20180214111656.88514-3-kirill.shute...@linux.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Florian Fainelli --- arch/x86/include/asm/pgtable-3level_types.h | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 ++ mm/zsmalloc.c | 13 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h index 876b4c77d983..6a59a6d0cc50 100644 --- a/arch/x86/include/asm/pgtable-3level_types.h +++ b/arch/x86/include/asm/pgtable-3level_types.h @@ -44,5 +44,6 @@ typedef union { */ #define PTRS_PER_PTE 512 +#define MAX_POSSIBLE_PHYSMEM_BITS 36 #endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */ diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index bf6d2692fc60..2bd79b7ae9d6 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -40,6 +40,8 @@ typedef struct { pteval_t pte; } pte_t; #define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) #define P4D_MASK (~(P4D_SIZE - 1)) +#define MAX_POSSIBLE_PHYSMEM_BITS 52 + #else /* CONFIG_X86_5LEVEL */ /* diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 6ed736ea9b59..633ebcac82f8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -83,18 +83,19 @@ * This is made more complicated by various memory models and PAE. */ -#ifndef MAX_PHYSMEM_BITS -#ifdef CONFIG_HIGHMEM64G -#define MAX_PHYSMEM_BITS 36 -#else /* !CONFIG_HIGHMEM64G */ +#ifndef MAX_POSSIBLE_PHYSMEM_BITS +#ifdef MAX_PHYSMEM_BITS +#define MAX_POSSIBLE_PHYSMEM_BITS MAX_PHYSMEM_BITS +#else /* * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just * be PAGE_SHIFT */ -#define MAX_PHYSMEM_BITS BITS_PER_LONG +#define MAX_POSSIBLE_PHYSMEM_BITS BITS_PER_LONG #endif #endif -#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) + +#define _PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT) /* * Memory for allocating for handle keeps object position by -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH stable 4.14 2/2] arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed
From: Arnd Bergmann [ Upstream commit cef397038167ac15d085914493d6c86385773709 ] Stefan Agner reported a bug when using zsram on 32-bit Arm machines with RAM above the 4GB address boundary: Unable to handle kernel NULL pointer dereference at virtual address pgd = a27bd01c [] *pgd=236a0003, *pmd=1ffa64003 Internal error: Oops: 207 [#1] SMP ARM Modules linked in: mdio_bcm_unimac(+) brcmfmac cfg80211 brcmutil raspberrypi_hwmon hci_uart crc32_arm_ce bcm2711_thermal phy_generic genet CPU: 0 PID: 123 Comm: mkfs.ext4 Not tainted 5.9.6 #1 Hardware name: BCM2711 PC is at zs_map_object+0x94/0x338 LR is at zram_bvec_rw.constprop.0+0x330/0xa64 pc : []lr : []psr: 6013 sp : e376bbe0 ip : fp : c1e2921c r10: 0002 r9 : c1dda730 r8 : r7 : e8ff7a00 r6 : r5 : 02f9ffa0 r4 : e371 r3 : 000fdffe r2 : c1e0ce80 r1 : ebf979a0 r0 : Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 30c5383d Table: 235c2a80 DAC: fffd Process mkfs.ext4 (pid: 123, stack limit = 0x495a22e6) Stack: (0xe376bbe0 to 0xe376c000) As it turns out, zsram needs to know the maximum memory size, which is defined in MAX_PHYSMEM_BITS when CONFIG_SPARSEMEM is set, or in MAX_POSSIBLE_PHYSMEM_BITS on the x86 architecture. The same problem will be hit on all 32-bit architectures that have a physical address space larger than 4GB and happen to not enable sparsemem and include asm/sparsemem.h from asm/pgtable.h. After the initial discussion, I suggested just always defining MAX_POSSIBLE_PHYSMEM_BITS whenever CONFIG_PHYS_ADDR_T_64BIT is set, or provoking a build error otherwise. This addresses all configurations that can currently have this runtime bug, but leaves all other configurations unchanged. I looked up the possible number of bits in source code and datasheets, here is what I found: - on ARC, CONFIG_ARC_HAS_PAE40 controls whether 32 or 40 bits are used - on ARM, CONFIG_LPAE enables 40 bit addressing, without it we never support more than 32 bits, even though supersections in theory allow up to 40 bits as well. - on MIPS, some MIPS32r1 or later chips support 36 bits, and MIPS32r5 XPA supports up to 60 bits in theory, but 40 bits are more than anyone will ever ship - On PowerPC, there are three different implementations of 36 bit addressing, but 32-bit is used without CONFIG_PTE_64BIT - On RISC-V, the normal page table format can support 34 bit addressing. There is no highmem support on RISC-V, so anything above 2GB is unused, but it might be useful to eventually support CONFIG_ZRAM for high pages. Fixes: 61989a80fb3a ("staging: zsmalloc: zsmalloc memory allocation library") Fixes: 02390b87a945 ("mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS") Acked-by: Thomas Bogendoerfer Reviewed-by: Stefan Agner Tested-by: Stefan Agner Acked-by: Mike Rapoport Link: https://lore.kernel.org/linux-mm/bdfa44bf1c570b05d6c70898e2bbb0acf234ecdf.1604762181.git.ste...@agner.ch/ Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin [florian: patch arch/powerpc/include/asm/pte-common.h for 4.14.y removed arch/riscv/include/asm/pgtable.h which does not exist] Signed-off-by: Florian Fainelli --- arch/arc/include/asm/pgtable.h| 2 ++ arch/arm/include/asm/pgtable-2level.h | 2 ++ arch/arm/include/asm/pgtable-3level.h | 2 ++ arch/mips/include/asm/pgtable-32.h| 3 +++ arch/powerpc/include/asm/pte-common.h | 2 ++ include/asm-generic/pgtable.h | 13 + 6 files changed, 24 insertions(+) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index 77676e18da69..a31ae69da639 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -138,8 +138,10 @@ #ifdef CONFIG_ARC_HAS_PAE40 #define PTE_BITS_NON_RWX_IN_PD1(0xff | PAGE_MASK | _PAGE_CACHEABLE) +#define MAX_POSSIBLE_PHYSMEM_BITS 40 #else #define PTE_BITS_NON_RWX_IN_PD1(PAGE_MASK | _PAGE_CACHEABLE) +#define MAX_POSSIBLE_PHYSMEM_BITS 32 #endif /** diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index 92fd2c8a9af0..6154902bed83 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -78,6 +78,8 @@ #define PTE_HWTABLE_OFF(PTE_HWTABLE_PTRS * sizeof(pte_t)) #define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32)) +#define MAX_POSSIBLE_PHYSMEM_BITS 32 + /* * PMD_SHIFT determines the size of the area a second-level page table can map * PGDIR_SHIFT determines what a third-level page table entry can map diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 2a029bceaf2f..35807e611b6e 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -37
[PATCH stable 4.14 0/2] zsmalloc MAX_POSSIBLE_PHYSMEM_BITS
This patch series is a back port necessary to address the problem reported by Stefan Agner: https://lore.kernel.org/linux-mm/bdfa44bf1c570b05d6c70898e2bbb0acf234ecdf.1604762181.git.ste...@agner.ch/ but which ended up being addressed by Arnd in a slightly different way from Stefan's submission. The first patch from Kirill is back ported in order to have MAX_POSSIBLE_PHYSMEM_BITS be acted on my the zsmalloc.c code. Arnd Bergmann (1): arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed Kirill A. Shutemov (1): mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS arch/arc/include/asm/pgtable.h | 2 ++ arch/arm/include/asm/pgtable-2level.h | 2 ++ arch/arm/include/asm/pgtable-3level.h | 2 ++ arch/mips/include/asm/pgtable-32.h | 3 +++ arch/powerpc/include/asm/pte-common.h | 2 ++ arch/x86/include/asm/pgtable-3level_types.h | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 ++ include/asm-generic/pgtable.h | 13 + mm/zsmalloc.c | 13 +++-- 9 files changed, 34 insertions(+), 6 deletions(-) -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH stable 4.19 1/1] arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed
From: Arnd Bergmann [ Upstream commit cef397038167ac15d085914493d6c86385773709 ] Stefan Agner reported a bug when using zsram on 32-bit Arm machines with RAM above the 4GB address boundary: Unable to handle kernel NULL pointer dereference at virtual address pgd = a27bd01c [] *pgd=236a0003, *pmd=1ffa64003 Internal error: Oops: 207 [#1] SMP ARM Modules linked in: mdio_bcm_unimac(+) brcmfmac cfg80211 brcmutil raspberrypi_hwmon hci_uart crc32_arm_ce bcm2711_thermal phy_generic genet CPU: 0 PID: 123 Comm: mkfs.ext4 Not tainted 5.9.6 #1 Hardware name: BCM2711 PC is at zs_map_object+0x94/0x338 LR is at zram_bvec_rw.constprop.0+0x330/0xa64 pc : []lr : []psr: 6013 sp : e376bbe0 ip : fp : c1e2921c r10: 0002 r9 : c1dda730 r8 : r7 : e8ff7a00 r6 : r5 : 02f9ffa0 r4 : e371 r3 : 000fdffe r2 : c1e0ce80 r1 : ebf979a0 r0 : Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 30c5383d Table: 235c2a80 DAC: fffd Process mkfs.ext4 (pid: 123, stack limit = 0x495a22e6) Stack: (0xe376bbe0 to 0xe376c000) As it turns out, zsram needs to know the maximum memory size, which is defined in MAX_PHYSMEM_BITS when CONFIG_SPARSEMEM is set, or in MAX_POSSIBLE_PHYSMEM_BITS on the x86 architecture. The same problem will be hit on all 32-bit architectures that have a physical address space larger than 4GB and happen to not enable sparsemem and include asm/sparsemem.h from asm/pgtable.h. After the initial discussion, I suggested just always defining MAX_POSSIBLE_PHYSMEM_BITS whenever CONFIG_PHYS_ADDR_T_64BIT is set, or provoking a build error otherwise. This addresses all configurations that can currently have this runtime bug, but leaves all other configurations unchanged. I looked up the possible number of bits in source code and datasheets, here is what I found: - on ARC, CONFIG_ARC_HAS_PAE40 controls whether 32 or 40 bits are used - on ARM, CONFIG_LPAE enables 40 bit addressing, without it we never support more than 32 bits, even though supersections in theory allow up to 40 bits as well. - on MIPS, some MIPS32r1 or later chips support 36 bits, and MIPS32r5 XPA supports up to 60 bits in theory, but 40 bits are more than anyone will ever ship - On PowerPC, there are three different implementations of 36 bit addressing, but 32-bit is used without CONFIG_PTE_64BIT - On RISC-V, the normal page table format can support 34 bit addressing. There is no highmem support on RISC-V, so anything above 2GB is unused, but it might be useful to eventually support CONFIG_ZRAM for high pages. Fixes: 61989a80fb3a ("staging: zsmalloc: zsmalloc memory allocation library") Fixes: 02390b87a945 ("mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS") Acked-by: Thomas Bogendoerfer Reviewed-by: Stefan Agner Tested-by: Stefan Agner Acked-by: Mike Rapoport Link: https://lore.kernel.org/linux-mm/bdfa44bf1c570b05d6c70898e2bbb0acf234ecdf.1604762181.git.ste...@agner.ch/ Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin [florian: patch arch/powerpc/include/asm/pte-common.h for 4.19.y] Signed-off-by: Florian Fainelli --- arch/arc/include/asm/pgtable.h| 2 ++ arch/arm/include/asm/pgtable-2level.h | 2 ++ arch/arm/include/asm/pgtable-3level.h | 2 ++ arch/mips/include/asm/pgtable-32.h| 3 +++ arch/powerpc/include/asm/pte-common.h | 2 ++ arch/riscv/include/asm/pgtable-32.h | 2 ++ include/asm-generic/pgtable.h | 13 + 7 files changed, 26 insertions(+) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index cf4be70d5892..f231963b4011 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -138,8 +138,10 @@ #ifdef CONFIG_ARC_HAS_PAE40 #define PTE_BITS_NON_RWX_IN_PD1(0xff | PAGE_MASK | _PAGE_CACHEABLE) +#define MAX_POSSIBLE_PHYSMEM_BITS 40 #else #define PTE_BITS_NON_RWX_IN_PD1(PAGE_MASK | _PAGE_CACHEABLE) +#define MAX_POSSIBLE_PHYSMEM_BITS 32 #endif /** diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index 12659ce5c1f3..90bf19d99378 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -78,6 +78,8 @@ #define PTE_HWTABLE_OFF(PTE_HWTABLE_PTRS * sizeof(pte_t)) #define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32)) +#define MAX_POSSIBLE_PHYSMEM_BITS 32 + /* * PMD_SHIFT determines the size of the area a second-level page table can map * PGDIR_SHIFT determines what a third-level page table entry can map diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 6d50a11d7793..7ba08dd650e3 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -37,6 +37,8 @@ #de
Re: [PATCH RESEND v6 00/10] dt-bindings: usb: Harmonize xHCI/EHCI/OHCI/DWC3 nodes name
On 2/10/21 9:28 AM, Serge Semin wrote: > As the subject states this series is an attempt to harmonize the xHCI, > EHCI, OHCI and DWC USB3 DT nodes with the DT schema introduced in the > framework of the patchset [1]. > > Firstly as Krzysztof suggested we've deprecated a support of DWC USB3 > controllers with "synopsys,"-vendor prefix compatible string in favor of > the ones with valid "snps,"-prefix. It's done in all the DTS files, > which have been unfortunate to define such nodes. > > Secondly we suggest to fix the snps,quirk-frame-length-adjustment property > declaration in the Amlogic meson-g12-common.dtsi DTS file, since it has > been erroneously declared as boolean while having uint32 type. Neil said > it was ok to init that property with 0x20 value. > > Thirdly the main part of the patchset concern fixing the xHCI, EHCI/OHCI > and DWC USB3 DT nodes name as in accordance with their DT schema the > corresponding node name is suppose to comply with the Generic USB HCD DT > schema, which requires the USB nodes to have the name acceptable by the > regexp: "^usb(@.*)?". Such requirement had been applicable even before we > introduced the new DT schema in [1], but as we can see it hasn't been > strictly implemented for a lot the DTS files. Since DT schema is now > available the automated DTS validation shall make sure that the rule isn't > violated. > > Note most of these patches have been a part of the last three patches of > [1]. But since there is no way to have them merged in in a combined > manner, I had to move them to the dedicated series and split them up so to > be accepted by the corresponding subsystem maintainers one-by-one. > > [1] Link: > https://lore.kernel.org/linux-usb/20201014101402.18271-1-sergey.se...@baikalelectronics.ru/ > Changelog v1: > - As Krzysztof suggested I've created a script which checked whether the > node names had been also updated in all the depended dts files. As a > result I found two more files which should have been also modified: > arch/arc/boot/dts/{axc003.dtsi,axc003_idu.dtsi} > - Correct the USB DWC3 nodes name found in > arch/arm64/boot/dts/apm/{apm-storm.dtsi,apm-shadowcat.dtsi} too. > > Link: > https://lore.kernel.org/linux-usb/20201020115959.2658-1-sergey.se...@baikalelectronics.ru > Changelog v2: > - Drop the patch: > [PATCH 01/29] usb: dwc3: Discard synopsys,dwc3 compatibility string > and get back the one which marks the "synopsys,dwc3" compatible string > as deprecated into the DT schema related series. > - Drop the patches: > [PATCH 03/29] arm: dts: am437x: Correct DWC USB3 compatible string > [PATCH 04/29] arm: dts: exynos: Correct DWC USB3 compatible string > [PATCH 07/29] arm: dts: bcm53x: Harmonize EHCI/OHCI DT nodes name > [PATCH 08/29] arm: dts: stm32: Harmonize EHCI/OHCI DT nodes name > [PATCH 16/29] arm: dts: bcm5301x: Harmonize xHCI DT nodes name > [PATCH 19/29] arm: dts: exynos: Harmonize DWC USB3 DT nodes name > [PATCH 21/29] arm: dts: ls1021a: Harmonize DWC USB3 DT nodes name > [PATCH 22/29] arm: dts: omap5: Harmonize DWC USB3 DT nodes name > [PATCH 24/29] arm64: dts: allwinner: h6: Harmonize DWC USB3 DT nodes name > [PATCH 26/29] arm64: dts: exynos: Harmonize DWC USB3 DT nodes name > [PATCH 27/29] arm64: dts: layerscape: Harmonize DWC USB3 DT nodes name > since they have been applied to the corresponding maintainers repos. > - Fix drivers/usb/dwc3/dwc3-qcom.c to be looking for the "usb@"-prefixed > sub-node and falling back to the "dwc3@"-prefixed one on failure. > > Link: > https://lore.kernel.org/linux-usb/2020091552.15593-1-sergey.se...@baikalelectronics.ru > Changelog v3: > - Drop the patches: > [PATCH v2 04/18] arm: dts: hisi-x5hd2: Harmonize EHCI/OHCI DT nodes name > [PATCH v2 06/18] arm64: dts: hisi: Harmonize EHCI/OHCI DT nodes name > [PATCH v2 07/18] mips: dts: jz47x: Harmonize EHCI/OHCI DT nodes name > [PATCH v2 08/18] mips: dts: sead3: Harmonize EHCI/OHCI DT nodes name > [PATCH v2 09/18] mips: dts: ralink: mt7628a: Harmonize EHCI/OHCI DT nodes > name > [PATCH v2 11/18] arm64: dts: marvell: cp11x: Harmonize xHCI DT nodes name > [PATCH v2 12/18] arm: dts: marvell: armada-375: Harmonize DWC USB3 DT nodes > name > [PATCH v2 16/18] arm64: dts: hi3660: Harmonize DWC USB3 DT nodes name > since they have been applied to the corresponding maintainers repos. > > Link: > https://lore.kernel.org/linux-usb/20201205155621.3045-1-sergey.se...@baikalelectronics.ru > Changelog v4: > - Just resend. > > Link: > https://lore.kernel.org/linux-usb/20201210091756.18057-1-sergey.se...@baikalelectronics.ru/ > Changelog v5: > - Drop the patch: > [PATCH v4 02/10] arm64: dts: amlogic: meson-g12: Set FL-adj property value > since it has been applied to the corresponding maintainers repos. > - Get back the patch: > [PATCH 21/29] arm: dts: ls1021a: Harmonize DWC USB3 DT nodes name > as it has been missing in the kernel 5.11-rc7 > - Rebase onto the kernel 5.11-rc7 > > Link:
Re: [PATCH 07/20] dt-bindings: usb: xhci: Add Broadcom STB v2 compatible device
On 10/14/20 3:13 AM, Serge Semin wrote: > For some reason the "brcm,xhci-brcm-v2" compatible string has been missing > in the original bindings file. Add it to the Generic xHCI Controllers DT > schema since the controller driver expects it to be supported. > > Signed-off-by: Serge Semin Acked-by: Florian Fainelli -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 18/20] arch: dts: Fix EHCI/OHCI DT nodes name
On 10/14/20 3:14 AM, Serge Semin wrote: > In accordance with the Generic EHCI/OHCI bindings the corresponding node > name is suppose to comply with the Generic USB HCD DT schema, which > requires the USB nodes to have the name acceptable by the regexp: > "^usb(@.*)?" . Let's fix the DTS files, which have the nodes defined with > incompatible names. > > Signed-off-by: Serge Semin > > --- > > Please, test the patch out to make sure it doesn't brake the dependent DTS > files. I did only a manual grepping of the possible nodes dependencies. > --- > arch/arm/boot/dts/bcm5301x.dtsi| 4 ++-- > arch/arm/boot/dts/bcm53573.dtsi| 4 ++-- Acked-by: Florian Fainelli -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 18/20] arch: dts: Fix EHCI/OHCI DT nodes name
On 10/14/20 11:11 AM, Serge Semin wrote: > On Wed, Oct 14, 2020 at 11:00:45AM -0700, Florian Fainelli wrote: >> On 10/14/20 3:14 AM, Serge Semin wrote: >>> In accordance with the Generic EHCI/OHCI bindings the corresponding node >>> name is suppose to comply with the Generic USB HCD DT schema, which >>> requires the USB nodes to have the name acceptable by the regexp: >>> "^usb(@.*)?" . Let's fix the DTS files, which have the nodes defined with >>> incompatible names. >>> >>> Signed-off-by: Serge Semin >>> >>> --- >>> >>> Please, test the patch out to make sure it doesn't brake the dependent DTS >>> files. I did only a manual grepping of the possible nodes dependencies. >> > >> Not sure how you envisioned these change to be picked up, but you may >> need to split these changes between ARM/ARM64, MIPS and PowerPC at >> least. And within ARM/ARM64 you will most likely have to split according >> to the various SoC maintainers. > > Hmm, I don't really know how it's going to be done in this case, but there > must > be a way to get the cross-platform patches picked up in general. For > instance, see the patches like: > 714acdbd1c94 arch: rename copy_thread_tls() back to copy_thread() > 140c8180eb7c arch: remove HAVE_COPY_THREAD_TLS > They touched the files from different files, but still have been merged in. That situation is different, when a new facility is added and someone has gone through the work of adding support for all architectures (or nearly all of them), you want them to be merged in a way that limits merge conflicts with other architecture changes. Here you are fixing warnings, and each file you touch can clearly be independently change from other files in the series without causing merge conflicts. You are however creating the potential for merge conflicts with other changes that the various SoC maintainers have queued up. > Maybe I should have copied these three patches to the > "linux-a...@vger.kernel.org" > list or some other mailing list... Maybe Rob can queue them through his device tree repository, with the ack of the various SoC maintainers... -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 18/20] arch: dts: Fix EHCI/OHCI DT nodes name
On 10/14/20 3:14 AM, Serge Semin wrote: > In accordance with the Generic EHCI/OHCI bindings the corresponding node > name is suppose to comply with the Generic USB HCD DT schema, which > requires the USB nodes to have the name acceptable by the regexp: > "^usb(@.*)?" . Let's fix the DTS files, which have the nodes defined with > incompatible names. > > Signed-off-by: Serge Semin > > --- > > Please, test the patch out to make sure it doesn't brake the dependent DTS > files. I did only a manual grepping of the possible nodes dependencies. Not sure how you envisioned these change to be picked up, but you may need to split these changes between ARM/ARM64, MIPS and PowerPC at least. And within ARM/ARM64 you will most likely have to split according to the various SoC maintainers. -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v4 6/6] arch: Move initrd= parsing into do_mounts_initrd.c
On 11/12/18 4:57 PM, Vineet Gupta wrote: > On 11/12/18 4:52 PM, Florian Fainelli wrote: >> On 11/12/18 4:40 PM, Vineet Gupta wrote: >>> On 11/12/18 4:38 PM, Florian Fainelli wrote: >>>>>> #ifdef CONFIG_BLK_DEV_INITRD >>>>>> -if (initrd_start) >>>>>> -memblock_reserve(__pa(initrd_start), initrd_end - >>>>>> initrd_start); >>>>>> +if (phys_initrd_size) { >>>>>> +memblock_reserve(phys_initrd_start, phys_initrd_size); >>>>>> +initrd_start = (unsigned long)__va(phys_initrd_start); >>>>>> +initrd_end = initrd_start + phys_initrd_size; >>>>>> +} >>>>>> #endif >>>>> The common code now uses phys_initrd*, and you also use the same in ARC >>>>> code, do >>>>> we still need the initrd_* setting here ? >>>>> ARC semantics was using them as PA anyways. >>>> Yes, the generic initrd code expects initrd_start/end to be virtual >>>> addresses, which we now directly derive from phys_initrd_start, that >>>> should really be equivalent. >>> So we can skip this explicit setting above - ARC arch code doesn't access >>> the virt >>> initrd_start >> OK, you are saying we could just have the generic initrd code do this >> assignment instead of having each architecture do it, is that a correct >> understanding? > > Correct ! > >> If so, I suppose it could be done, whether as of this >> patch series or as a follow-up, either way is fine with me. > > If it is not too much trouble, I'd prefer this now. I should have chimed > earlier. > >> One possible caveat is if __va() and __phys_to_virt() behave differently >> (e.g: because of CONFIG_DEBUG_VIRTUAL or other things). > > > Thing is, after your patches, we don't use the vanilla initrd_xxx in arch > code any > longer. So this becomes just an implementation detail, which core code may or > maynot need and if it does, this needs to work already w/o having to set > anything > in arch code. Agree ? If you do not mind, I would prefer this series to go in, as-is, and clean up the initrd_start/initrd_end assignment as a follow up patch series. The reason is mostly that I am not yet clear on the timing of these operations between the architecture resolving the virtual address and the initrd code starting to use it. Would that sound reasonable to you? -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v4 6/6] arch: Move initrd= parsing into do_mounts_initrd.c
On 11/12/18 4:40 PM, Vineet Gupta wrote: > On 11/12/18 4:38 PM, Florian Fainelli wrote: >>>> #ifdef CONFIG_BLK_DEV_INITRD >>>> - if (initrd_start) >>>> - memblock_reserve(__pa(initrd_start), initrd_end - initrd_start); >>>> + if (phys_initrd_size) { >>>> + memblock_reserve(phys_initrd_start, phys_initrd_size); >>>> + initrd_start = (unsigned long)__va(phys_initrd_start); >>>> + initrd_end = initrd_start + phys_initrd_size; >>>> + } >>>> #endif >>> The common code now uses phys_initrd*, and you also use the same in ARC >>> code, do >>> we still need the initrd_* setting here ? >>> ARC semantics was using them as PA anyways. >> Yes, the generic initrd code expects initrd_start/end to be virtual >> addresses, which we now directly derive from phys_initrd_start, that >> should really be equivalent. > > So we can skip this explicit setting above - ARC arch code doesn't access the > virt > initrd_start OK, you are saying we could just have the generic initrd code do this assignment instead of having each architecture do it, is that a correct understanding? If so, I suppose it could be done, whether as of this patch series or as a follow-up, either way is fine with me. One possible caveat is if __va() and __phys_to_virt() behave differently (e.g: because of CONFIG_DEBUG_VIRTUAL or other things). -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v4 6/6] arch: Move initrd= parsing into do_mounts_initrd.c
On 11/12/18 4:34 PM, Vineet Gupta wrote: > On 11/5/18 2:58 PM, Florian Fainelli wrote: >> ARC, ARM, ARM64 and Unicore32 are all capable of parsing the "initrd=" >> command line parameter to allow specifying the physical address and size >> of an initrd. Move that parsing into init/do_mounts_initrd.c such that >> we no longer duplicate that logic. >> >> Signed-off-by: Florian Fainelli >> --- >> arch/arc/mm/init.c | 25 + >> arch/arm/mm/init.c | 17 - >> arch/arm64/mm/init.c | 18 -- >> arch/unicore32/mm/init.c | 18 -- >> init/do_mounts_initrd.c | 17 + >> 5 files changed, 22 insertions(+), 73 deletions(-) >> >> diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c >> index f8fe5668b30f..43bf4c3a1290 100644 >> --- a/arch/arc/mm/init.c >> +++ b/arch/arc/mm/init.c >> @@ -78,24 +78,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 >> size) >> base, TO_MB(size), !in_use ? "Not used":""); >> } >> >> -#ifdef CONFIG_BLK_DEV_INITRD >> -static int __init early_initrd(char *p) >> -{ >> -unsigned long start, size; >> -char *endp; >> - >> -start = memparse(p, ); >> -if (*endp == ',') { >> -size = memparse(endp + 1, NULL); >> - >> -initrd_start = (unsigned long)__va(start); >> -initrd_end = (unsigned long)__va(start + size); >> -} >> -return 0; >> -} >> -early_param("initrd", early_initrd); >> -#endif >> - >> /* >> * First memory setup routine called from setup_arch() >> * 1. setup swapper's mm @init_mm >> @@ -140,8 +122,11 @@ void __init setup_arch_memory(void) >> memblock_reserve(low_mem_start, __pa(_end) - low_mem_start); >> >> #ifdef CONFIG_BLK_DEV_INITRD >> -if (initrd_start) >> -memblock_reserve(__pa(initrd_start), initrd_end - initrd_start); >> +if (phys_initrd_size) { >> +memblock_reserve(phys_initrd_start, phys_initrd_size); >> +initrd_start = (unsigned long)__va(phys_initrd_start); >> +initrd_end = initrd_start + phys_initrd_size; >> +} >> #endif > > The common code now uses phys_initrd*, and you also use the same in ARC code, > do > we still need the initrd_* setting here ? > ARC semantics was using them as PA anyways. Yes, the generic initrd code expects initrd_start/end to be virtual addresses, which we now directly derive from phys_initrd_start, that should really be equivalent. -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v4 0/6] arm64: Get rid of __early_init_dt_declare_initrd()
On 11/6/18 6:06 AM, Mike Rapoport wrote: > On Mon, Nov 05, 2018 at 02:54:25PM -0800, Florian Fainelli wrote: >> Hi all, >> >> Changes in v4: >> >> - dropped initrd_below_start_ok assignment in ARM64, not necessary at >> all (Ard) >> - replace #ifdef CONFIG_BLK_DEV_INITRD with if >> (IS_ENABLED(CONFIG_BLK_DEV_INITRD) for consistency with other parts >> of arm64_memblock_init() (Rob) >> >> Changes in v3: >> >> - use C conditionals in drivers/of/fdt.c >> - added check on phys_initrd_size in arch/arm64/mm/init.c to determine >> whether initrd_start must be populated >> - fixed a build warning with ARC that was just missing an (unsigned >> long) cast >> >> Changes in v2: >> >> - get rid of ARCH_HAS_PHYS_INITRD and instead define >> phys_initrd_start/phys_initrd_size in init/do_mounts_initrd.c >> >> - make __early_init_dt_declare_initrd() account for ARM64 specific >> behavior with __va() when having CONFIG_DEBUG_VM enabled >> >> - consolidate early_initrd() command line parsing into >> init/do_mounts_initrd.c >> >> Because phys_initrd_start/phys_initrd_size are now compiled in >> ini/do_mounts_initrd.c which is only built with CONFIG_BLK_DEV_INITRD=y, >> we need to be a bit careful about the uses throughout architecture >> specific code. >> >> Previous discussions/submissions list here: >> >> v3: >> https://www.spinics.net/lists/arm-kernel/msg683566.html >> v2: >> https://lkml.org/lkml/2018/10/25/4 >> >> Florian Fainelli (6): >> nds32: Remove phys_initrd_start and phys_initrd_size >> arch: Make phys_initrd_start and phys_initrd_size global variables >> of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT >> arm64: Utilize phys_initrd_start/phys_initrd_size >> of/fdt: Remove custom __early_init_dt_declare_initrd() implementation >> arch: Move initrd= parsing into do_mounts_initrd.c > > For the series: > > Reviewed-by: Mike Rapoport Thanks Mike, Rob, do you want to merge that series through the OF tree? -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v4 6/6] arch: Move initrd= parsing into do_mounts_initrd.c
ARC, ARM, ARM64 and Unicore32 are all capable of parsing the "initrd=" command line parameter to allow specifying the physical address and size of an initrd. Move that parsing into init/do_mounts_initrd.c such that we no longer duplicate that logic. Signed-off-by: Florian Fainelli --- arch/arc/mm/init.c | 25 + arch/arm/mm/init.c | 17 - arch/arm64/mm/init.c | 18 -- arch/unicore32/mm/init.c | 18 -- init/do_mounts_initrd.c | 17 + 5 files changed, 22 insertions(+), 73 deletions(-) diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index f8fe5668b30f..43bf4c3a1290 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -78,24 +78,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) base, TO_MB(size), !in_use ? "Not used":""); } -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(start + size); - } - return 0; -} -early_param("initrd", early_initrd); -#endif - /* * First memory setup routine called from setup_arch() * 1. setup swapper's mm @init_mm @@ -140,8 +122,11 @@ void __init setup_arch_memory(void) memblock_reserve(low_mem_start, __pa(_end) - low_mem_start); #ifdef CONFIG_BLK_DEV_INITRD - if (initrd_start) - memblock_reserve(__pa(initrd_start), initrd_end - initrd_start); + if (phys_initrd_size) { + memblock_reserve(phys_initrd_start, phys_initrd_size); + initrd_start = (unsigned long)__va(phys_initrd_start); + initrd_end = initrd_start + phys_initrd_size; + } #endif early_init_fdt_reserve_self(); diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index a3b6f1f1cbaf..478ea8b7db87 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -51,23 +51,6 @@ unsigned long __init __clear_cr(unsigned long mask) #endif #ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - phys_addr_t start; - unsigned long size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); - static int __init parse_tag_initrd(const struct tag *tag) { pr_warn("ATAG_INITRD is deprecated; " diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index a66ffcde5f13..7474093363bc 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -61,24 +61,6 @@ s64 memstart_addr __ro_after_init = -1; phys_addr_t arm64_dma_phys_limit __ro_after_init; -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); -#endif - #ifdef CONFIG_KEXEC_CORE /* * reserve_crashkernel() - reserves memory for crash kernel diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index 02aa2c0b295e..85ef2c624090 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -30,24 +30,6 @@ #include "mm.h" -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); -#endif - /* * This keeps memory configuration data used by a couple memory * initialization functions, as well as show_mem() for the skipping diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 45865b72f4ea..732d21f4a637 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -27,6 +27,23 @@ static int __init no_initrd(char *str) __setup("noinitrd", no_initrd); +static int __init early_initrd(char *p) +{ + phys_addr_t start; + unsigned long size; + char *endp; + + start = memparse(p, ); + if (*endp == ',') { + size = memparse(endp + 1, NULL); + + phys_initrd_start = start; + phys_initrd_size = size; + } + return 0; +} +early_param("initrd", early_initrd
[PATCH v4 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size
ARM64 is the only architecture that re-defines __early_init_dt_declare_initrd() in order for that function to populate initrd_start/initrd_end with physical addresses instead of virtual addresses. Instead of having an override we can leverage drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to populate those variables for us. Signed-off-by: Florian Fainelli --- arch/arm64/mm/init.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9d9582cac6c4..a66ffcde5f13 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -71,8 +71,8 @@ static int __init early_initrd(char *p) if (*endp == ',') { size = memparse(endp + 1, NULL); - initrd_start = start; - initrd_end = start + size; + phys_initrd_start = start; + phys_initrd_size = size; } return 0; } @@ -407,14 +407,14 @@ void __init arm64_memblock_init(void) memblock_add(__pa_symbol(_text), (u64)(_end - _text)); } - if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { /* * Add back the memory we just removed if it results in the * initrd to become inaccessible via the linear mapping. * Otherwise, this is a no-op */ - u64 base = initrd_start & PAGE_MASK; - u64 size = PAGE_ALIGN(initrd_end) - base; + u64 base = phys_initrd_start & PAGE_MASK; + u64 size = PAGE_ALIGN(phys_initrd_size); /* * We can only add back the initrd memory if we don't end up @@ -458,15 +458,11 @@ void __init arm64_memblock_init(void) * pagetables with memblock. */ memblock_reserve(__pa_symbol(_text), _end - _text); -#ifdef CONFIG_BLK_DEV_INITRD - if (initrd_start) { - memblock_reserve(initrd_start, initrd_end - initrd_start); - + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { /* the generic initrd code expects virtual addresses */ - initrd_start = __phys_to_virt(initrd_start); - initrd_end = __phys_to_virt(initrd_end); + initrd_start = __phys_to_virt(phys_initrd_start); + initrd_end = initrd_start + phys_initrd_size; } -#endif early_init_fdt_scan_reserved_mem(); -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v4 1/6] nds32: Remove phys_initrd_start and phys_initrd_size
This will conflict with a subsequent change making phys_initrd_start and phys_initrd_size global variables. nds32 does not make use of those nor provides a suitable declarations so just get rid of them. Signed-off-by: Florian Fainelli --- arch/nds32/mm/init.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c index 131104bd2538..253f79fc7196 100644 --- a/arch/nds32/mm/init.c +++ b/arch/nds32/mm/init.c @@ -21,8 +21,6 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); DEFINE_SPINLOCK(anon_alias_lock); extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; -extern unsigned long phys_initrd_start; -extern unsigned long phys_initrd_size; /* * empty_zero_page is a special page that is used for -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v4 5/6] of/fdt: Remove custom __early_init_dt_declare_initrd() implementation
Now that ARM64 uses phys_initrd_start/phys_initrd_size, we can get rid of its custom __early_init_dt_declare_initrd() which causes a fair amount of objects rebuild when changing CONFIG_BLK_DEV_INITRD. In order to make sure ARM64 does not produce a BUG() when VM debugging is turned on though, we must avoid early calls to __va() which is what __early_init_dt_declare_initrd() does and wrap this around to avoid running that code on ARM64. Signed-off-by: Florian Fainelli --- arch/arm64/include/asm/memory.h | 8 drivers/of/fdt.c| 15 ++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b96442960aea..dc3ca21ba240 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -168,14 +168,6 @@ #define IOREMAP_MAX_ORDER (PMD_SHIFT) #endif -#ifdef CONFIG_BLK_DEV_INITRD -#define __early_init_dt_declare_initrd(__start, __end) \ - do {\ - initrd_start = (__start); \ - initrd_end = (__end); \ - } while (0) -#endif - #ifndef __ASSEMBLY__ #include diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 88760a0983a7..cd72a41fcab2 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -891,15 +891,20 @@ const void * __init of_flat_dt_match_machine(const void *default_match, } #ifdef CONFIG_BLK_DEV_INITRD -#ifndef __early_init_dt_declare_initrd static void __early_init_dt_declare_initrd(unsigned long start, unsigned long end) { - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; + /* ARM64 would cause a BUG to occur here when CONFIG_DEBUG_VM is +* enabled since __va() is called too early. ARM64 does make use +* of phys_initrd_start/phys_initrd_size so we can skip this +* conversion. +*/ + if (!IS_ENABLED(CONFIG_ARM64)) { + initrd_start = (unsigned long)__va(start); + initrd_end = (unsigned long)__va(end); + initrd_below_start_ok = 1; + } } -#endif /** * early_init_dt_check_for_initrd - Decode initrd location from flat tree -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v4 3/6] of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT
Now that we have central and global variables holding the physical address and size of the initrd, we can have early_init_dt_check_for_initrd() populate phys_initrd_start/phys_initrd_size for us. This allows us to remove a chunk of code from arch/arm/mm/init.c introduced with commit 65939301acdb ("arm: set initrd_start/initrd_end for fdt scan"). Signed-off-by: Florian Fainelli --- arch/arm/mm/init.c | 6 -- drivers/of/fdt.c | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 438625764ccd..a3b6f1f1cbaf 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -235,12 +235,6 @@ static void __init arm_initrd_init(void) phys_addr_t start; unsigned long size; - /* FDT scan will populate initrd_start */ - if (initrd_start && !phys_initrd_size) { - phys_initrd_start = __virt_to_phys(initrd_start); - phys_initrd_size = initrd_end - initrd_start; - } - initrd_start = initrd_end = 0; if (!phys_initrd_size) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bb532aae0d92..88760a0983a7 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -924,6 +924,8 @@ static void __init early_init_dt_check_for_initrd(unsigned long node) end = of_read_number(prop, len/4); __early_init_dt_declare_initrd(start, end); + phys_initrd_start = start; + phys_initrd_size = end - start; pr_debug("initrd_start=0x%llx initrd_end=0x%llx\n", (unsigned long long)start, (unsigned long long)end); -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v4 0/6] arm64: Get rid of __early_init_dt_declare_initrd()
Hi all, Changes in v4: - dropped initrd_below_start_ok assignment in ARM64, not necessary at all (Ard) - replace #ifdef CONFIG_BLK_DEV_INITRD with if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) for consistency with other parts of arm64_memblock_init() (Rob) Changes in v3: - use C conditionals in drivers/of/fdt.c - added check on phys_initrd_size in arch/arm64/mm/init.c to determine whether initrd_start must be populated - fixed a build warning with ARC that was just missing an (unsigned long) cast Changes in v2: - get rid of ARCH_HAS_PHYS_INITRD and instead define phys_initrd_start/phys_initrd_size in init/do_mounts_initrd.c - make __early_init_dt_declare_initrd() account for ARM64 specific behavior with __va() when having CONFIG_DEBUG_VM enabled - consolidate early_initrd() command line parsing into init/do_mounts_initrd.c Because phys_initrd_start/phys_initrd_size are now compiled in ini/do_mounts_initrd.c which is only built with CONFIG_BLK_DEV_INITRD=y, we need to be a bit careful about the uses throughout architecture specific code. Previous discussions/submissions list here: v3: https://www.spinics.net/lists/arm-kernel/msg683566.html v2: https://lkml.org/lkml/2018/10/25/4 Florian Fainelli (6): nds32: Remove phys_initrd_start and phys_initrd_size arch: Make phys_initrd_start and phys_initrd_size global variables of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT arm64: Utilize phys_initrd_start/phys_initrd_size of/fdt: Remove custom __early_init_dt_declare_initrd() implementation arch: Move initrd= parsing into do_mounts_initrd.c arch/arc/mm/init.c | 25 +--- arch/arm/mm/init.c | 28 ++- arch/arm64/include/asm/memory.h | 8 arch/arm64/mm/init.c| 34 ++--- arch/nds32/mm/init.c| 2 -- arch/unicore32/mm/init.c| 24 +-- drivers/of/fdt.c| 17 - include/linux/initrd.h | 3 +++ init/do_mounts_initrd.c | 20 +++ 9 files changed, 53 insertions(+), 108 deletions(-) -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v4 2/6] arch: Make phys_initrd_start and phys_initrd_size global variables
Make phys_initrd_start and phys_initrd_size global variables declared in init/do_mounts_initrd.c such that we can later have generic code in drivers/of/fdt.c populate those variables for us. This requires both the ARM and unicore32 implementations to be properly guarded against CONFIG_BLK_DEV_INITRD, and also initialize the variables to the expected default values (unicore32). Signed-off-by: Florian Fainelli --- arch/arm/mm/init.c | 5 ++--- arch/unicore32/mm/init.c | 10 +++--- include/linux/initrd.h | 3 +++ init/do_mounts_initrd.c | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 32e4845af2b6..438625764ccd 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -50,9 +50,7 @@ unsigned long __init __clear_cr(unsigned long mask) } #endif -static phys_addr_t phys_initrd_start __initdata = 0; -static unsigned long phys_initrd_size __initdata = 0; - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd(char *p) { phys_addr_t start; @@ -89,6 +87,7 @@ static int __init parse_tag_initrd2(const struct tag *tag) } __tagtable(ATAG_INITRD2, parse_tag_initrd2); +#endif static void __init find_limits(unsigned long *min, unsigned long *max_low, unsigned long *max_high) diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index cf4eb9481fd6..02aa2c0b295e 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -30,9 +30,7 @@ #include "mm.h" -static unsigned long phys_initrd_start __initdata = 0x0100; -static unsigned long phys_initrd_size __initdata = SZ_8M; - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd(char *p) { unsigned long start, size; @@ -48,6 +46,7 @@ static int __init early_initrd(char *p) return 0; } early_param("initrd", early_initrd); +#endif /* * This keeps memory configuration data used by a couple memory @@ -156,6 +155,11 @@ void __init uc32_memblock_init(struct meminfo *mi) memblock_reserve(__pa(_text), _end - _text); #ifdef CONFIG_BLK_DEV_INITRD + if (!phys_initrd_size) { + phys_initrd_start = 0x0100; + phys_initrd_size = SZ_8M; + } + if (phys_initrd_size) { memblock_reserve(phys_initrd_start, phys_initrd_size); diff --git a/include/linux/initrd.h b/include/linux/initrd.h index 84b423044088..14beaff9b445 100644 --- a/include/linux/initrd.h +++ b/include/linux/initrd.h @@ -21,4 +21,7 @@ extern int initrd_below_start_ok; extern unsigned long initrd_start, initrd_end; extern void free_initrd_mem(unsigned long, unsigned long); +extern phys_addr_t phys_initrd_start; +extern unsigned long phys_initrd_size; + extern unsigned int real_root_dev; diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index d1a5d885ce13..45865b72f4ea 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -16,6 +16,9 @@ int initrd_below_start_ok; unsigned int real_root_dev;/* do_proc_dointvec cannot handle kdev_t */ static int __initdata mount_initrd = 1; +phys_addr_t phys_initrd_start __initdata; +unsigned long phys_initrd_size __initdata; + static int __init no_initrd(char *str) { mount_initrd = 0; -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v3 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size
On 11/5/18 1:00 PM, Ard Biesheuvel wrote: > On 5 November 2018 at 21:51, Florian Fainelli wrote: >> On 11/5/18 12:44 PM, Ard Biesheuvel wrote: >>> On 5 November 2018 at 21:41, Florian Fainelli wrote: >>>> On 11/5/18 12:39 PM, Ard Biesheuvel wrote: >>>>> Hi Florian, >>>>> >>>>> On 31 October 2018 at 20:28, Florian Fainelli >>>>> wrote: >>>>>> ARM64 is the only architecture that re-defines >>>>>> __early_init_dt_declare_initrd() in order for that function to populate >>>>>> initrd_start/initrd_end with physical addresses instead of virtual >>>>>> addresses. Instead of having an override we can leverage >>>>>> drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to >>>>>> populate those variables for us. >>>>>> >>>>>> Signed-off-by: Florian Fainelli >>>>>> --- >>>>>> arch/arm64/mm/init.c | 19 +-- >>>>>> 1 file changed, 9 insertions(+), 10 deletions(-) >>>>>> >>>>>> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >>>>>> index 3cf87341859f..00ef2166bb73 100644 >>>>>> --- a/arch/arm64/mm/init.c >>>>>> +++ b/arch/arm64/mm/init.c >>>>>> @@ -72,8 +72,8 @@ static int __init early_initrd(char *p) >>>>>> if (*endp == ',') { >>>>>> size = memparse(endp + 1, NULL); >>>>>> >>>>>> - initrd_start = start; >>>>>> - initrd_end = start + size; >>>>>> + phys_initrd_start = start; >>>>>> + phys_initrd_size = size; >>>>>> } >>>>>> return 0; >>>>>> } >>>>>> @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void) >>>>>> memblock_add(__pa_symbol(_text), (u64)(_end - _text)); >>>>>> } >>>>>> >>>>>> - if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { >>>>>> + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { >>>>>> /* >>>>>> * Add back the memory we just removed if it results in >>>>>> the >>>>>> * initrd to become inaccessible via the linear mapping. >>>>>> * Otherwise, this is a no-op >>>>>> */ >>>>>> - u64 base = initrd_start & PAGE_MASK; >>>>>> - u64 size = PAGE_ALIGN(initrd_end) - base; >>>>>> + u64 base = phys_initrd_start & PAGE_MASK; >>>>>> + u64 size = PAGE_ALIGN(phys_initrd_size); >>>>>> >>>>>> /* >>>>>> * We can only add back the initrd memory if we don't >>>>>> end up >>>>>> @@ -460,12 +460,11 @@ void __init arm64_memblock_init(void) >>>>>> */ >>>>>> memblock_reserve(__pa_symbol(_text), _end - _text); >>>>>> #ifdef CONFIG_BLK_DEV_INITRD >>>>>> - if (initrd_start) { >>>>>> - memblock_reserve(initrd_start, initrd_end - >>>>>> initrd_start); >>>>>> - >>>>>> + if (phys_initrd_size) { >>>>>> /* the generic initrd code expects virtual addresses */ >>>>>> - initrd_start = __phys_to_virt(initrd_start); >>>>>> - initrd_end = __phys_to_virt(initrd_end); >>>>>> + initrd_start = __phys_to_virt(phys_initrd_start); >>>>>> + initrd_end = initrd_start + phys_initrd_size; >>>>>> + initrd_below_start_ok = 0; >>>>> >>>>> Where is this assignment coming from? >>>> >>>> __early_init_dt_declare_initrd() sets initrd_below_start_ok to 1 though >>>> after patch #5 this is not necessary any more. >>> >>> Yes, but why? The original arm64 version of >>> __early_init_dt_declare_initrd() does not set it but now you set to 1 >>> in the IS_ENABLED(CONFIG_ARM64) section in the generic code and set it >>> back to 0 here. >> >> Humm, it is an if (!IS_ENABLED(CONFIG_ARM64)) condition, so we would not >> be taking that branch on an ARM64 kernel. >> > > Right. So now that we are not setting it to 1 on arm64, there is no > longer a reason to set it to 0 again, no? Correct, and in fact, this is not a problem either at patch #4 (which has the custom __early_init_dt_declare_initrd()) or #5 (which removes it), any other feedback you would like me to address before addressing Rob's suggestion? > >> If you are saying the assignment is not necessary anymore after patch #5 >> , that is true, though this can only be done a part of part #5, not as >> part of patch #4 in order not to break initrd functionality in-between >> patches. >> >>> >>> Or am I missing something? >>> >> >> Not sure, I could be too, it's Monday after all :) > > Yeah :-) > -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v3 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size
On 11/5/18 12:44 PM, Ard Biesheuvel wrote: > On 5 November 2018 at 21:41, Florian Fainelli wrote: >> On 11/5/18 12:39 PM, Ard Biesheuvel wrote: >>> Hi Florian, >>> >>> On 31 October 2018 at 20:28, Florian Fainelli wrote: >>>> ARM64 is the only architecture that re-defines >>>> __early_init_dt_declare_initrd() in order for that function to populate >>>> initrd_start/initrd_end with physical addresses instead of virtual >>>> addresses. Instead of having an override we can leverage >>>> drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to >>>> populate those variables for us. >>>> >>>> Signed-off-by: Florian Fainelli >>>> --- >>>> arch/arm64/mm/init.c | 19 +-- >>>> 1 file changed, 9 insertions(+), 10 deletions(-) >>>> >>>> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >>>> index 3cf87341859f..00ef2166bb73 100644 >>>> --- a/arch/arm64/mm/init.c >>>> +++ b/arch/arm64/mm/init.c >>>> @@ -72,8 +72,8 @@ static int __init early_initrd(char *p) >>>> if (*endp == ',') { >>>> size = memparse(endp + 1, NULL); >>>> >>>> - initrd_start = start; >>>> - initrd_end = start + size; >>>> + phys_initrd_start = start; >>>> + phys_initrd_size = size; >>>> } >>>> return 0; >>>> } >>>> @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void) >>>> memblock_add(__pa_symbol(_text), (u64)(_end - _text)); >>>> } >>>> >>>> - if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { >>>> + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { >>>> /* >>>> * Add back the memory we just removed if it results in the >>>> * initrd to become inaccessible via the linear mapping. >>>> * Otherwise, this is a no-op >>>> */ >>>> - u64 base = initrd_start & PAGE_MASK; >>>> - u64 size = PAGE_ALIGN(initrd_end) - base; >>>> + u64 base = phys_initrd_start & PAGE_MASK; >>>> + u64 size = PAGE_ALIGN(phys_initrd_size); >>>> >>>> /* >>>> * We can only add back the initrd memory if we don't end >>>> up >>>> @@ -460,12 +460,11 @@ void __init arm64_memblock_init(void) >>>> */ >>>> memblock_reserve(__pa_symbol(_text), _end - _text); >>>> #ifdef CONFIG_BLK_DEV_INITRD >>>> - if (initrd_start) { >>>> - memblock_reserve(initrd_start, initrd_end - initrd_start); >>>> - >>>> + if (phys_initrd_size) { >>>> /* the generic initrd code expects virtual addresses */ >>>> - initrd_start = __phys_to_virt(initrd_start); >>>> - initrd_end = __phys_to_virt(initrd_end); >>>> + initrd_start = __phys_to_virt(phys_initrd_start); >>>> + initrd_end = initrd_start + phys_initrd_size; >>>> + initrd_below_start_ok = 0; >>> >>> Where is this assignment coming from? >> >> __early_init_dt_declare_initrd() sets initrd_below_start_ok to 1 though >> after patch #5 this is not necessary any more. > > Yes, but why? The original arm64 version of > __early_init_dt_declare_initrd() does not set it but now you set to 1 > in the IS_ENABLED(CONFIG_ARM64) section in the generic code and set it > back to 0 here. Humm, it is an if (!IS_ENABLED(CONFIG_ARM64)) condition, so we would not be taking that branch on an ARM64 kernel. If you are saying the assignment is not necessary anymore after patch #5 , that is true, though this can only be done a part of part #5, not as part of patch #4 in order not to break initrd functionality in-between patches. > > Or am I missing something? > Not sure, I could be too, it's Monday after all :) -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v3 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size
On 11/5/18 12:39 PM, Ard Biesheuvel wrote: > Hi Florian, > > On 31 October 2018 at 20:28, Florian Fainelli wrote: >> ARM64 is the only architecture that re-defines >> __early_init_dt_declare_initrd() in order for that function to populate >> initrd_start/initrd_end with physical addresses instead of virtual >> addresses. Instead of having an override we can leverage >> drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to >> populate those variables for us. >> >> Signed-off-by: Florian Fainelli >> --- >> arch/arm64/mm/init.c | 19 +-- >> 1 file changed, 9 insertions(+), 10 deletions(-) >> >> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >> index 3cf87341859f..00ef2166bb73 100644 >> --- a/arch/arm64/mm/init.c >> +++ b/arch/arm64/mm/init.c >> @@ -72,8 +72,8 @@ static int __init early_initrd(char *p) >> if (*endp == ',') { >> size = memparse(endp + 1, NULL); >> >> - initrd_start = start; >> - initrd_end = start + size; >> + phys_initrd_start = start; >> + phys_initrd_size = size; >> } >> return 0; >> } >> @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void) >> memblock_add(__pa_symbol(_text), (u64)(_end - _text)); >> } >> >> - if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { >> + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { >> /* >> * Add back the memory we just removed if it results in the >> * initrd to become inaccessible via the linear mapping. >> * Otherwise, this is a no-op >> */ >> - u64 base = initrd_start & PAGE_MASK; >> - u64 size = PAGE_ALIGN(initrd_end) - base; >> + u64 base = phys_initrd_start & PAGE_MASK; >> + u64 size = PAGE_ALIGN(phys_initrd_size); >> >> /* >> * We can only add back the initrd memory if we don't end up >> @@ -460,12 +460,11 @@ void __init arm64_memblock_init(void) >> */ >> memblock_reserve(__pa_symbol(_text), _end - _text); >> #ifdef CONFIG_BLK_DEV_INITRD >> - if (initrd_start) { >> - memblock_reserve(initrd_start, initrd_end - initrd_start); >> - >> + if (phys_initrd_size) { >> /* the generic initrd code expects virtual addresses */ >> - initrd_start = __phys_to_virt(initrd_start); >> - initrd_end = __phys_to_virt(initrd_end); >> + initrd_start = __phys_to_virt(phys_initrd_start); >> + initrd_end = initrd_start + phys_initrd_size; >> + initrd_below_start_ok = 0; > > Where is this assignment coming from? __early_init_dt_declare_initrd() sets initrd_below_start_ok to 1 though after patch #5 this is not necessary any more. -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v3 6/6] arch: Move initrd= parsing into do_mounts_initrd.c
ARC, ARM, ARM64 and Unicore32 are all capable of parsing the "initrd=" command line parameter to allow specifying the physical address and size of an initrd. Move that parsing into init/do_mounts_initrd.c such that we no longer duplicate that logic. Signed-off-by: Florian Fainelli --- arch/arc/mm/init.c | 25 + arch/arm/mm/init.c | 17 - arch/arm64/mm/init.c | 18 -- arch/unicore32/mm/init.c | 18 -- init/do_mounts_initrd.c | 17 + 5 files changed, 22 insertions(+), 73 deletions(-) diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ba145065c579..55879a9dee0d 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -79,24 +79,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) base, TO_MB(size), !in_use ? "Not used":""); } -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(start + size); - } - return 0; -} -early_param("initrd", early_initrd); -#endif - /* * First memory setup routine called from setup_arch() * 1. setup swapper's mm @init_mm @@ -141,8 +123,11 @@ void __init setup_arch_memory(void) memblock_reserve(low_mem_start, __pa(_end) - low_mem_start); #ifdef CONFIG_BLK_DEV_INITRD - if (initrd_start) - memblock_reserve(__pa(initrd_start), initrd_end - initrd_start); + if (phys_initrd_size) { + memblock_reserve(phys_initrd_start, phys_initrd_size); + initrd_start = (unsigned long)__va(phys_initrd_start); + initrd_end = initrd_start + phys_initrd_size; + } #endif early_init_fdt_reserve_self(); diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 4bfa08e27319..58ec68709606 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -52,23 +52,6 @@ unsigned long __init __clear_cr(unsigned long mask) #endif #ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - phys_addr_t start; - unsigned long size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); - static int __init parse_tag_initrd(const struct tag *tag) { pr_warn("ATAG_INITRD is deprecated; " diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 00ef2166bb73..d95a6cb205b8 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -62,24 +62,6 @@ s64 memstart_addr __ro_after_init = -1; phys_addr_t arm64_dma_phys_limit __ro_after_init; -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); -#endif - #ifdef CONFIG_KEXEC_CORE /* * reserve_crashkernel() - reserves memory for crash kernel diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index f2f815d46846..99acdb829a7e 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -31,24 +31,6 @@ #include "mm.h" -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); -#endif - /* * This keeps memory configuration data used by a couple memory * initialization functions, as well as show_mem() for the skipping diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 45865b72f4ea..732d21f4a637 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -27,6 +27,23 @@ static int __init no_initrd(char *str) __setup("noinitrd", no_initrd); +static int __init early_initrd(char *p) +{ + phys_addr_t start; + unsigned long size; + char *endp; + + start = memparse(p, ); + if (*endp == ',') { + size = memparse(endp + 1, NULL); + + phys_initrd_start = start; + phys_initrd_size = size; + } + return 0; +} +early_param("initrd", early_initrd
[PATCH v3 5/6] of/fdt: Remove custom __early_init_dt_declare_initrd() implementation
Now that ARM64 uses phys_initrd_start/phys_initrd_size, we can get rid of its custom __early_init_dt_declare_initrd() which causes a fair amount of objects rebuild when changing CONFIG_BLK_DEV_INITRD. In order to make sure ARM64 does not produce a BUG() when VM debugging is turned on though, we must avoid early calls to __va() which is what __early_init_dt_declare_initrd() does and wrap this around to avoid running that code on ARM64. Signed-off-by: Florian Fainelli --- arch/arm64/include/asm/memory.h | 8 drivers/of/fdt.c| 15 ++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b96442960aea..dc3ca21ba240 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -168,14 +168,6 @@ #define IOREMAP_MAX_ORDER (PMD_SHIFT) #endif -#ifdef CONFIG_BLK_DEV_INITRD -#define __early_init_dt_declare_initrd(__start, __end) \ - do {\ - initrd_start = (__start); \ - initrd_end = (__end); \ - } while (0) -#endif - #ifndef __ASSEMBLY__ #include diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index e34cb49231b5..4118a344cf45 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -892,15 +892,20 @@ const void * __init of_flat_dt_match_machine(const void *default_match, } #ifdef CONFIG_BLK_DEV_INITRD -#ifndef __early_init_dt_declare_initrd static void __early_init_dt_declare_initrd(unsigned long start, unsigned long end) { - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; + /* ARM64 would cause a BUG to occur here when CONFIG_DEBUG_VM is +* enabled since __va() is called too early. ARM64 does make use +* of phys_initrd_start/phys_initrd_size so we can skip this +* conversion. +*/ + if (!IS_ENABLED(CONFIG_ARM64)) { + initrd_start = (unsigned long)__va(start); + initrd_end = (unsigned long)__va(end); + initrd_below_start_ok = 1; + } } -#endif /** * early_init_dt_check_for_initrd - Decode initrd location from flat tree -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v3 2/6] arch: Make phys_initrd_start and phys_initrd_size global variables
Make phys_initrd_start and phys_initrd_size global variables declared in init/do_mounts_initrd.c such that we can later have generic code in drivers/of/fdt.c populate those variables for us. This requires both the ARM and unicore32 implementations to be properly guarded against CONFIG_BLK_DEV_INITRD, and also initialize the variables to the expected default values (unicore32). Signed-off-by: Florian Fainelli --- arch/arm/mm/init.c | 5 ++--- arch/unicore32/mm/init.c | 10 +++--- include/linux/initrd.h | 3 +++ init/do_mounts_initrd.c | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 0cc8e04295a4..87d59a53861d 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -51,9 +51,7 @@ unsigned long __init __clear_cr(unsigned long mask) } #endif -static phys_addr_t phys_initrd_start __initdata = 0; -static unsigned long phys_initrd_size __initdata = 0; - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd(char *p) { phys_addr_t start; @@ -90,6 +88,7 @@ static int __init parse_tag_initrd2(const struct tag *tag) } __tagtable(ATAG_INITRD2, parse_tag_initrd2); +#endif static void __init find_limits(unsigned long *min, unsigned long *max_low, unsigned long *max_high) diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index 8f8699e62bd5..f2f815d46846 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -31,9 +31,7 @@ #include "mm.h" -static unsigned long phys_initrd_start __initdata = 0x0100; -static unsigned long phys_initrd_size __initdata = SZ_8M; - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd(char *p) { unsigned long start, size; @@ -49,6 +47,7 @@ static int __init early_initrd(char *p) return 0; } early_param("initrd", early_initrd); +#endif /* * This keeps memory configuration data used by a couple memory @@ -157,6 +156,11 @@ void __init uc32_memblock_init(struct meminfo *mi) memblock_reserve(__pa(_text), _end - _text); #ifdef CONFIG_BLK_DEV_INITRD + if (!phys_initrd_size) { + phys_initrd_start = 0x0100; + phys_initrd_size = SZ_8M; + } + if (phys_initrd_size) { memblock_reserve(phys_initrd_start, phys_initrd_size); diff --git a/include/linux/initrd.h b/include/linux/initrd.h index 84b423044088..14beaff9b445 100644 --- a/include/linux/initrd.h +++ b/include/linux/initrd.h @@ -21,4 +21,7 @@ extern int initrd_below_start_ok; extern unsigned long initrd_start, initrd_end; extern void free_initrd_mem(unsigned long, unsigned long); +extern phys_addr_t phys_initrd_start; +extern unsigned long phys_initrd_size; + extern unsigned int real_root_dev; diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index d1a5d885ce13..45865b72f4ea 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -16,6 +16,9 @@ int initrd_below_start_ok; unsigned int real_root_dev;/* do_proc_dointvec cannot handle kdev_t */ static int __initdata mount_initrd = 1; +phys_addr_t phys_initrd_start __initdata; +unsigned long phys_initrd_size __initdata; + static int __init no_initrd(char *str) { mount_initrd = 0; -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v3 0/6] arm64: Get rid of __early_init_dt_declare_initrd()
Hi all, Changes in v3: - use C conditionals in drivers/of/fdt.c - added check on phys_initrd_size in arch/arm64/mm/init.c to determine whether initrd_start must be populated - fixed a build warning with ARC that was just missing an (unsigned long) cast Changes in v2: - get rid of ARCH_HAS_PHYS_INITRD and instead define phys_initrd_start/phys_initrd_size in init/do_mounts_initrd.c - make __early_init_dt_declare_initrd() account for ARM64 specific behavior with __va() when having CONFIG_DEBUG_VM enabled - consolidate early_initrd() command line parsing into init/do_mounts_initrd.c Because phys_initrd_start/phys_initrd_size are now compiled in ini/do_mounts_initrd.c which is only built with CONFIG_BLK_DEV_INITRD=y, we need to be a bit careful about the uses throughout architecture specific code. Previous discussions/submissions list here: v3: https://www.spinics.net/lists/arm-kernel/msg683566.html v2: https://lkml.org/lkml/2018/10/25/4 Florian Fainelli (6): nds32: Remove phys_initrd_start and phys_initrd_size arch: Make phys_initrd_start and phys_initrd_size global variables of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT arm64: Utilize phys_initrd_start/phys_initrd_size of/fdt: Remove custom __early_init_dt_declare_initrd() implementation arch: Move initrd= parsing into do_mounts_initrd.c arch/arc/mm/init.c | 25 + arch/arm/mm/init.c | 28 ++-- arch/arm64/include/asm/memory.h | 8 arch/arm64/mm/init.c| 33 +++-- arch/nds32/mm/init.c| 2 -- arch/unicore32/mm/init.c| 24 +--- drivers/of/fdt.c| 17 - include/linux/initrd.h | 3 +++ init/do_mounts_initrd.c | 20 9 files changed, 54 insertions(+), 106 deletions(-) -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size
On 10/31/18 12:03 AM, Mike Rapoport wrote: > On Tue, Oct 30, 2018 at 04:07:19PM -0700, Florian Fainelli wrote: >> ARM64 is the only architecture that re-defines >> __early_init_dt_declare_initrd() in order for that function to populate >> initrd_start/initrd_end with physical addresses instead of virtual >> addresses. Instead of having an override we can leverage >> drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to >> populate those variables for us. >> >> Signed-off-by: Florian Fainelli >> --- >> arch/arm64/mm/init.c | 21 + >> 1 file changed, 9 insertions(+), 12 deletions(-) >> >> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >> index 3cf87341859f..e95cee656a55 100644 >> --- a/arch/arm64/mm/init.c >> +++ b/arch/arm64/mm/init.c >> @@ -72,8 +72,8 @@ static int __init early_initrd(char *p) >> if (*endp == ',') { >> size = memparse(endp + 1, NULL); >> >> -initrd_start = start; >> -initrd_end = start + size; >> +phys_initrd_start = start; >> +phys_initrd_size = size; >> } >> return 0; >> } >> @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void) >> memblock_add(__pa_symbol(_text), (u64)(_end - _text)); >> } >> >> -if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { >> +if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { >> /* >> * Add back the memory we just removed if it results in the >> * initrd to become inaccessible via the linear mapping. >> * Otherwise, this is a no-op >> */ >> -u64 base = initrd_start & PAGE_MASK; >> -u64 size = PAGE_ALIGN(initrd_end) - base; >> +u64 base = phys_initrd_start & PAGE_MASK; >> +u64 size = PAGE_ALIGN(phys_initrd_size); >> >> /* >> * We can only add back the initrd memory if we don't end up >> @@ -460,13 +460,10 @@ void __init arm64_memblock_init(void) >> */ >> memblock_reserve(__pa_symbol(_text), _end - _text); >> #ifdef CONFIG_BLK_DEV_INITRD >> -if (initrd_start) { > > There may be no initrd at all, so the condition here would rather become > > if (phys_initrd_start) Or use phys_initrd_size, which would be consistent with how other architectures typically test for this. > >> -memblock_reserve(initrd_start, initrd_end - initrd_start); >> - >> -/* the generic initrd code expects virtual addresses */ >> -initrd_start = __phys_to_virt(initrd_start); >> -initrd_end = __phys_to_virt(initrd_end); >> -} >> +/* the generic initrd code expects virtual addresses */ >> +initrd_start = __phys_to_virt(phys_initrd_start); >> +initrd_end = initrd_start + phys_initrd_size; >> +initrd_below_start_ok = 0; >> #endif > > I also wonder what is the reason to keep memstart_addr randomization and > initrd setup interleaved? > > What we have now is roughly: > > 1) set memstart_addr > 2) enforce memory_limit > 3) reserve initrd > 4) randomize memstart_addr > 5) reserve text + data > 6) reserve initrd again and set virtual addresses of initrd_{start,end} > > Maybe it's possible to merge (3) into (6) ? That's kind of orthogonal to this patch series, but it's a valid question, not sure I would want to tackle that just now though :) -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 5/6] of/fdt: Remove custom __early_init_dt_declare_initrd() implementation
Now that ARM64 uses phys_initrd_start/phys_initrd_size, we can get rid of its custom __early_init_dt_declare_initrd() which causes a fair amount of objects rebuild when changing CONFIG_BLK_DEV_INITRD. In order to make sure ARM64 does not produce a BUG() when VM debugging is turned on though, we must avoid early calls to __va() which is what __early_init_dt_declare_initrd() does and wrap this around to avoid running that code on ARM64. Signed-off-by: Florian Fainelli --- arch/arm64/include/asm/memory.h | 8 drivers/of/fdt.c| 9 +++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b96442960aea..dc3ca21ba240 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -168,14 +168,6 @@ #define IOREMAP_MAX_ORDER (PMD_SHIFT) #endif -#ifdef CONFIG_BLK_DEV_INITRD -#define __early_init_dt_declare_initrd(__start, __end) \ - do {\ - initrd_start = (__start); \ - initrd_end = (__end); \ - } while (0) -#endif - #ifndef __ASSEMBLY__ #include diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index e34cb49231b5..f2b5becae96a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -892,15 +892,20 @@ const void * __init of_flat_dt_match_machine(const void *default_match, } #ifdef CONFIG_BLK_DEV_INITRD -#ifndef __early_init_dt_declare_initrd static void __early_init_dt_declare_initrd(unsigned long start, unsigned long end) { + /* ARM64 would cause a BUG to occur here when CONFIG_DEBUG_VM is +* enabled since __va() is called too early. ARM64 does make use +* of phys_initrd_start/phys_initrd_size so we can skip this +* conversion. +*/ +#if (!IS_ENABLED(CONFIG_ARM64)) initrd_start = (unsigned long)__va(start); initrd_end = (unsigned long)__va(end); initrd_below_start_ok = 1; -} #endif +} /** * early_init_dt_check_for_initrd - Decode initrd location from flat tree -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size
ARM64 is the only architecture that re-defines __early_init_dt_declare_initrd() in order for that function to populate initrd_start/initrd_end with physical addresses instead of virtual addresses. Instead of having an override we can leverage drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to populate those variables for us. Signed-off-by: Florian Fainelli --- arch/arm64/mm/init.c | 21 + 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 3cf87341859f..e95cee656a55 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -72,8 +72,8 @@ static int __init early_initrd(char *p) if (*endp == ',') { size = memparse(endp + 1, NULL); - initrd_start = start; - initrd_end = start + size; + phys_initrd_start = start; + phys_initrd_size = size; } return 0; } @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void) memblock_add(__pa_symbol(_text), (u64)(_end - _text)); } - if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) { + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) { /* * Add back the memory we just removed if it results in the * initrd to become inaccessible via the linear mapping. * Otherwise, this is a no-op */ - u64 base = initrd_start & PAGE_MASK; - u64 size = PAGE_ALIGN(initrd_end) - base; + u64 base = phys_initrd_start & PAGE_MASK; + u64 size = PAGE_ALIGN(phys_initrd_size); /* * We can only add back the initrd memory if we don't end up @@ -460,13 +460,10 @@ void __init arm64_memblock_init(void) */ memblock_reserve(__pa_symbol(_text), _end - _text); #ifdef CONFIG_BLK_DEV_INITRD - if (initrd_start) { - memblock_reserve(initrd_start, initrd_end - initrd_start); - - /* the generic initrd code expects virtual addresses */ - initrd_start = __phys_to_virt(initrd_start); - initrd_end = __phys_to_virt(initrd_end); - } + /* the generic initrd code expects virtual addresses */ + initrd_start = __phys_to_virt(phys_initrd_start); + initrd_end = initrd_start + phys_initrd_size; + initrd_below_start_ok = 0; #endif early_init_fdt_scan_reserved_mem(); -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 6/6] arch: Move initrd= parsing into do_mounts_initrd.c
ARC, ARM, ARM64 and Unicore32 are all capable of parsing the "initrd=" command line parameter to allow specifying the physical address and size of an initrd. Move that parsing into init/do_mounts_initrd.c such that we no longer duplicate that logic. Signed-off-by: Florian Fainelli --- arch/arc/mm/init.c | 25 + arch/arm/mm/init.c | 17 - arch/arm64/mm/init.c | 18 -- arch/unicore32/mm/init.c | 18 -- init/do_mounts_initrd.c | 17 + 5 files changed, 22 insertions(+), 73 deletions(-) diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ba145065c579..369d3d699929 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -79,24 +79,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) base, TO_MB(size), !in_use ? "Not used":""); } -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(start + size); - } - return 0; -} -early_param("initrd", early_initrd); -#endif - /* * First memory setup routine called from setup_arch() * 1. setup swapper's mm @init_mm @@ -141,8 +123,11 @@ void __init setup_arch_memory(void) memblock_reserve(low_mem_start, __pa(_end) - low_mem_start); #ifdef CONFIG_BLK_DEV_INITRD - if (initrd_start) - memblock_reserve(__pa(initrd_start), initrd_end - initrd_start); + if (phys_initrd_size) { + memblock_reserve(phys_initrd_start, phys_initrd_size); + initrd_start = __va(phys_initrd_start); + initrd_end = initrd_start + phys_initrd_size; + } #endif early_init_fdt_reserve_self(); diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 4bfa08e27319..58ec68709606 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -52,23 +52,6 @@ unsigned long __init __clear_cr(unsigned long mask) #endif #ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - phys_addr_t start; - unsigned long size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); - static int __init parse_tag_initrd(const struct tag *tag) { pr_warn("ATAG_INITRD is deprecated; " diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index e95cee656a55..9045afacd10b 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -62,24 +62,6 @@ s64 memstart_addr __ro_after_init = -1; phys_addr_t arm64_dma_phys_limit __ro_after_init; -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); -#endif - #ifdef CONFIG_KEXEC_CORE /* * reserve_crashkernel() - reserves memory for crash kernel diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index f2f815d46846..99acdb829a7e 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -31,24 +31,6 @@ #include "mm.h" -#ifdef CONFIG_BLK_DEV_INITRD -static int __init early_initrd(char *p) -{ - unsigned long start, size; - char *endp; - - start = memparse(p, ); - if (*endp == ',') { - size = memparse(endp + 1, NULL); - - phys_initrd_start = start; - phys_initrd_size = size; - } - return 0; -} -early_param("initrd", early_initrd); -#endif - /* * This keeps memory configuration data used by a couple memory * initialization functions, as well as show_mem() for the skipping diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 45865b72f4ea..732d21f4a637 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -27,6 +27,23 @@ static int __init no_initrd(char *str) __setup("noinitrd", no_initrd); +static int __init early_initrd(char *p) +{ + phys_addr_t start; + unsigned long size; + char *endp; + + start = memparse(p, ); + if (*endp == ',') { + size = memparse(endp + 1, NULL); + + phys_initrd_start = start; + phys_initrd_size = size; + } + return 0; +} +early_param("initrd", early_initrd); + static i
[PATCH v2 2/6] arch: Make phys_initrd_start and phys_initrd_size global variables
Make phys_initrd_start and phys_initrd_size global variables declared in init/do_mounts_initrd.c such that we can later have generic code in drivers/of/fdt.c populate those variables for us. This requires both the ARM and unicore32 implementations to be properly guarded against CONFIG_BLK_DEV_INITRD, and also initialize the variables to the expected default values (unicore32). Signed-off-by: Florian Fainelli --- arch/arm/mm/init.c | 5 ++--- arch/unicore32/mm/init.c | 10 +++--- include/linux/initrd.h | 3 +++ init/do_mounts_initrd.c | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 0cc8e04295a4..87d59a53861d 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -51,9 +51,7 @@ unsigned long __init __clear_cr(unsigned long mask) } #endif -static phys_addr_t phys_initrd_start __initdata = 0; -static unsigned long phys_initrd_size __initdata = 0; - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd(char *p) { phys_addr_t start; @@ -90,6 +88,7 @@ static int __init parse_tag_initrd2(const struct tag *tag) } __tagtable(ATAG_INITRD2, parse_tag_initrd2); +#endif static void __init find_limits(unsigned long *min, unsigned long *max_low, unsigned long *max_high) diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index 8f8699e62bd5..f2f815d46846 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -31,9 +31,7 @@ #include "mm.h" -static unsigned long phys_initrd_start __initdata = 0x0100; -static unsigned long phys_initrd_size __initdata = SZ_8M; - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd(char *p) { unsigned long start, size; @@ -49,6 +47,7 @@ static int __init early_initrd(char *p) return 0; } early_param("initrd", early_initrd); +#endif /* * This keeps memory configuration data used by a couple memory @@ -157,6 +156,11 @@ void __init uc32_memblock_init(struct meminfo *mi) memblock_reserve(__pa(_text), _end - _text); #ifdef CONFIG_BLK_DEV_INITRD + if (!phys_initrd_size) { + phys_initrd_start = 0x0100; + phys_initrd_size = SZ_8M; + } + if (phys_initrd_size) { memblock_reserve(phys_initrd_start, phys_initrd_size); diff --git a/include/linux/initrd.h b/include/linux/initrd.h index 84b423044088..14beaff9b445 100644 --- a/include/linux/initrd.h +++ b/include/linux/initrd.h @@ -21,4 +21,7 @@ extern int initrd_below_start_ok; extern unsigned long initrd_start, initrd_end; extern void free_initrd_mem(unsigned long, unsigned long); +extern phys_addr_t phys_initrd_start; +extern unsigned long phys_initrd_size; + extern unsigned int real_root_dev; diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index d1a5d885ce13..45865b72f4ea 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -16,6 +16,9 @@ int initrd_below_start_ok; unsigned int real_root_dev;/* do_proc_dointvec cannot handle kdev_t */ static int __initdata mount_initrd = 1; +phys_addr_t phys_initrd_start __initdata; +unsigned long phys_initrd_size __initdata; + static int __init no_initrd(char *str) { mount_initrd = 0; -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 1/6] nds32: Remove phys_initrd_start and phys_initrd_size
This will conflict with a subsequent change making phys_initrd_start and phys_initrd_size global variables. nds32 does not make use of those nor provides a suitable declarations so just get rid of them. Signed-off-by: Florian Fainelli --- arch/nds32/mm/init.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c index c713d2ad55dc..32f55a24ccbb 100644 --- a/arch/nds32/mm/init.c +++ b/arch/nds32/mm/init.c @@ -22,8 +22,6 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); DEFINE_SPINLOCK(anon_alias_lock); extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; -extern unsigned long phys_initrd_start; -extern unsigned long phys_initrd_size; /* * empty_zero_page is a special page that is used for -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 3/6] of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT
Now that we have central and global variables holding the physical address and size of the initrd, we can have early_init_dt_check_for_initrd() populate phys_initrd_start/phys_initrd_size for us. This allows us to remove a chunk of code from arch/arm/mm/init.c introduced with commit 65939301acdb ("arm: set initrd_start/initrd_end for fdt scan"). Signed-off-by: Florian Fainelli --- arch/arm/mm/init.c | 6 -- drivers/of/fdt.c | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 87d59a53861d..4bfa08e27319 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -236,12 +236,6 @@ static void __init arm_initrd_init(void) phys_addr_t start; unsigned long size; - /* FDT scan will populate initrd_start */ - if (initrd_start && !phys_initrd_size) { - phys_initrd_start = __virt_to_phys(initrd_start); - phys_initrd_size = initrd_end - initrd_start; - } - initrd_start = initrd_end = 0; if (!phys_initrd_size) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 76c83c1ffeda..e34cb49231b5 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -925,6 +925,8 @@ static void __init early_init_dt_check_for_initrd(unsigned long node) end = of_read_number(prop, len/4); __early_init_dt_declare_initrd(start, end); + phys_initrd_start = start; + phys_initrd_size = end - start; pr_debug("initrd_start=0x%llx initrd_end=0x%llx\n", (unsigned long long)start, (unsigned long long)end); -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 0/6] arm64: Get rid of __early_init_dt_declare_initrd()
Hi all, Changes in v2: - get rid of ARCH_HAS_PHYS_INITRD and instead define phys_initrd_start/phys_initrd_size in init/do_mounts_initrd.c - make __early_init_dt_declare_initrd() account for ARM64 specific behavior with __va() when having CONFIG_DEBUG_VM enabled - consolidate early_initrd() command line parsing into init/do_mounts_initrd.c Because phys_initrd_start/phys_initrd_size are now compiled in ini/do_mounts_initrd.c which is only built with CONFIG_BLK_DEV_INITRD=y, we need to be a bit careful about the uses throughout architecture specific code. Previous discussions/submissions list here: v3: https://www.spinics.net/lists/arm-kernel/msg683566.html v2: https://lkml.org/lkml/2018/10/25/4 Florian Fainelli (6): nds32: Remove phys_initrd_start and phys_initrd_size arch: Make phys_initrd_start and phys_initrd_size global variables of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT arm64: Utilize phys_initrd_start/phys_initrd_size of/fdt: Remove custom __early_init_dt_declare_initrd() implementation arch: Move initrd= parsing into do_mounts_initrd.c arch/arc/mm/init.c | 25 +-- arch/arm/mm/init.c | 28 ++ arch/arm64/include/asm/memory.h | 8 arch/arm64/mm/init.c| 35 +++-- arch/nds32/mm/init.c| 2 -- arch/unicore32/mm/init.c| 24 +- drivers/of/fdt.c| 11 +-- include/linux/initrd.h | 3 +++ init/do_mounts_initrd.c | 20 +++ 9 files changed, 51 insertions(+), 105 deletions(-) -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 0/2] arm64: Cut rebuild time when changing CONFIG_BLK_DEV_INITRD
On 10/26/18 4:07 AM, Mike Rapoport wrote: > On Thu, Oct 25, 2018 at 04:07:13PM -0700, Florian Fainelli wrote: >> On 10/25/18 2:13 PM, Rob Herring wrote: >>> On Thu, Oct 25, 2018 at 12:30 PM Mike Rapoport wrote: >>>> >>>> On Thu, Oct 25, 2018 at 08:15:15AM -0500, Rob Herring wrote: >>>>> +Ard >>>>> >>>>> On Thu, Oct 25, 2018 at 4:38 AM Mike Rapoport wrote: >>>>>> >>>>>> On Wed, Oct 24, 2018 at 02:55:17PM -0500, Rob Herring wrote: >>>>>>> On Wed, Oct 24, 2018 at 2:33 PM Florian Fainelli >>>>>>> wrote: >>>>>>>> >>>>>>>> Hi all, >>>>>>>> >>>>>>>> While investigating why ARM64 required a ton of objects to be rebuilt >>>>>>>> when toggling CONFIG_DEV_BLK_INITRD, it became clear that this was >>>>>>>> because we define __early_init_dt_declare_initrd() differently and we >>>>>>>> do >>>>>>>> that in arch/arm64/include/asm/memory.h which gets included by a fair >>>>>>>> amount of other header files, and translation units as well. >>>>>>> >>>>>> I think arm64 does not have to redefine __early_init_dt_declare_initrd(). >>>>>> Something like this might be just all we need (completely untested, >>>>>> probably it won't even compile): > > [ ... ] > >> FWIW, I am extracting the ARM implementation that parses the initrd >> early command line parameter and the "setup" code doing the page >> boundary alignment and memblock checking into a helper into lib/ that >> other architectures can re-use. So far, this removes the need for >> unicore32, arc and arm to duplicate essentially the same logic. > > Presuming you are going to need asm-generic/initrd.h for that as well, > using override for __early_init_dt_declare_initrd in arm64 version of > initrd.h might be the simplest option. What I am contemplating doing is promote phys_initrd_start/phys_initrd_size to be global variables (similar to initrd_start, initrd_end) and have a generic helper function for parsing the initrd= command line parameter and finally removing __early_init_dt_declare_initrd() because we could have early_init_dt_check_for_initrd() just populate phys_initrd_start/phys_initrd_size directly as well as initrd_start/initrd_end using __va() to preserve compatibility with architectures that rely on this. Then I would convert ARM64 to check for phys_initrd_start which is really what it is is trying to do in arch/arm64/mm/init.c::arm64_memblock_init(). Does that sound like a reasonable approach? -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 0/2] arm64: Cut rebuild time when changing CONFIG_BLK_DEV_INITRD
On 10/24/18 12:55 PM, Rob Herring wrote: > On Wed, Oct 24, 2018 at 2:33 PM Florian Fainelli wrote: >> >> Hi all, >> >> While investigating why ARM64 required a ton of objects to be rebuilt >> when toggling CONFIG_DEV_BLK_INITRD, it became clear that this was >> because we define __early_init_dt_declare_initrd() differently and we do >> that in arch/arm64/include/asm/memory.h which gets included by a fair >> amount of other header files, and translation units as well. > > I scratch my head sometimes as to why some config options rebuild so > much stuff. One down, ? to go. :) > This one was by far the most invasive one due to its include chain, but yes, there would be many more that could be optimized. >> Changing the value of CONFIG_DEV_BLK_INITRD is a common thing with build >> systems that generate two kernels: one with the initramfs and one >> without. buildroot is one of these build systems, OpenWrt is also >> another one that does this. >> >> This patch series proposes adding an empty initrd.h to satisfy the need >> for drivers/of/fdt.c to unconditionally include that file, and moves the >> custom __early_init_dt_declare_initrd() definition away from >> asm/memory.h >> >> This cuts the number of objects rebuilds from 1920 down to 26, so a >> factor 73 approximately. >> >> Apologies for the long CC list, please let me know how you would go >> about merging that and if another approach would be preferable, e.g: >> introducing a CONFIG_ARCH_INITRD_BELOW_START_OK Kconfig option or >> something like that. > > There may be a better way as of 4.20 because bootmem is now gone and > only memblock is used. This should unify what each arch needs to do > with initrd early. We need the physical address early for memblock > reserving. Then later on we need the virtual address to access the > initrd. Perhaps we should just change initrd_start and initrd_end to > physical addresses (or add 2 new variables would be less invasive and > allow for different translation than __va()). The sanity checks and > memblock reserve could also perhaps be moved to a common location. > > Alternatively, given arm64 is the only oddball, I'd be fine with an > "if (IS_ENABLED(CONFIG_ARM64))" condition in the default > __early_init_dt_declare_initrd as long as we have a path to removing > it like the above option. OK, let me cook a patch doing that and meanwhile I will look at how much work is involved to implement the above option you outlined, which also sounds entirely reasonable. Thanks! -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 1/2] arch: Add asm-generic/initrd.h and make use of it for most architectures
In preparation for separating the definition of __early_init_dt_declare_initrd() on ARM64 in order to cut the amount of files that require a rebuild when CONFIG_BLK_DEV_INITRD value is changed, introduce an empty asm-generic initrd.h file and update all architectures but arm64 to make use of it. Signed-off-by: Florian Fainelli --- arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/Kbuild| 1 + arch/arm/include/asm/Kbuild| 1 + arch/c6x/include/asm/Kbuild| 1 + arch/h8300/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild| 1 + arch/ia64/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/Kbuild | 1 + arch/nds32/include/asm/Kbuild | 1 + arch/nios2/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/Kbuild| 1 + arch/riscv/include/asm/Kbuild | 1 + arch/s390/include/asm/Kbuild | 1 + arch/sh/include/asm/Kbuild | 1 + arch/sparc/include/asm/Kbuild | 1 + arch/um/include/asm/Kbuild | 1 + arch/unicore32/include/asm/Kbuild | 1 + arch/x86/include/asm/Kbuild| 1 + arch/xtensa/include/asm/Kbuild | 1 + include/asm-generic/initrd.h | 1 + 24 files changed, 24 insertions(+) create mode 100644 include/asm-generic/initrd.h diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild index 0580cb8c84b2..cd6f723aed1b 100644 --- a/arch/alpha/include/asm/Kbuild +++ b/arch/alpha/include/asm/Kbuild @@ -5,6 +5,7 @@ generic-y += compat.h generic-y += exec.h generic-y += export.h generic-y += fb.h +generic-y += initrd.h generic-y += irq_work.h generic-y += mcs_spinlock.h generic-y += mm-arch-hooks.h diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index feed50ce89fa..ba18632aa493 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -10,6 +10,7 @@ generic-y += fb.h generic-y += ftrace.h generic-y += hardirq.h generic-y += hw_irq.h +generic-y += initrd.h generic-y += irq_regs.h generic-y += irq_work.h generic-y += kmap_types.h diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild index 1d66db9c9db5..b91d5b32e64f 100644 --- a/arch/arm/include/asm/Kbuild +++ b/arch/arm/include/asm/Kbuild @@ -4,6 +4,7 @@ generic-y += early_ioremap.h generic-y += emergency-restart.h generic-y += exec.h generic-y += extable.h +generic-y += initrd.h generic-y += irq_regs.h generic-y += kdebug.h generic-y += local.h diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild index 33a2c94fed0d..9e14cf6e89b4 100644 --- a/arch/c6x/include/asm/Kbuild +++ b/arch/c6x/include/asm/Kbuild @@ -13,6 +13,7 @@ generic-y += extable.h generic-y += fb.h generic-y += futex.h generic-y += hw_irq.h +generic-y += initrd.h generic-y += io.h generic-y += irq_regs.h generic-y += irq_work.h diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild index a5d0b2991f47..7d4e06a757c8 100644 --- a/arch/h8300/include/asm/Kbuild +++ b/arch/h8300/include/asm/Kbuild @@ -19,6 +19,7 @@ generic-y += futex.h generic-y += hardirq.h generic-y += hash.h generic-y += hw_irq.h +generic-y += initrd.h generic-y += irq_regs.h generic-y += irq_work.h generic-y += kdebug.h diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild index 47c4da3d64a4..0be62abf2123 100644 --- a/arch/hexagon/include/asm/Kbuild +++ b/arch/hexagon/include/asm/Kbuild @@ -13,6 +13,7 @@ generic-y += fb.h generic-y += ftrace.h generic-y += hardirq.h generic-y += hw_irq.h +generic-y += initrd.h generic-y += iomap.h generic-y += irq_regs.h generic-y += irq_work.h diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild index 557bbc8ba9f5..1a1f1e4ba0d5 100644 --- a/arch/ia64/include/asm/Kbuild +++ b/arch/ia64/include/asm/Kbuild @@ -1,5 +1,6 @@ generic-y += compat.h generic-y += exec.h +generic-y += initrd.h generic-y += irq_work.h generic-y += mcs_spinlock.h generic-y += mm-arch-hooks.h diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild index a4b8d3331a9e..9903551e0c9c 100644 --- a/arch/m68k/include/asm/Kbuild +++ b/arch/m68k/include/asm/Kbuild @@ -7,6 +7,7 @@ generic-y += exec.h generic-y += extable.h generic-y += futex.h generic-y += hw_irq.h +generic-y += initrd.h generic-y += irq_regs.h generic-y += irq_work.h generic-y += kdebug.h diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild index 569ba9e670c1..ec37e6304be5 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild @@ -11,6 +11,7 @@ generic-y += exec.h generic-y += extable.h generic-y += fb.h generic-y += hardirq.h +generic-y += initrd.h generic-y += irq_regs.h generic-y += irq_work.h generic-y += kdebug.h diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild index
[PATCH v2 2/2] arm64: Create asm/initrd.h
ARM64 is the only architecture that requires a re-definition of __early_init_dt_declare_initrd(). Now that we added the infrastructure in asm-generic to provide an asm/initrd.h file, properly break up that definition from asm/memory.h and make use of that header in drivers/of/fdt.c where this is used. This significantly cuts the number of objects that need to be rebuilt on ARM64 due to the repercusions of including asm/memory.h in several places. Signed-off-by: Florian Fainelli --- arch/arm64/include/asm/initrd.h | 13 + arch/arm64/include/asm/memory.h | 8 drivers/of/fdt.c| 1 + 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 arch/arm64/include/asm/initrd.h diff --git a/arch/arm64/include/asm/initrd.h b/arch/arm64/include/asm/initrd.h new file mode 100644 index ..0c9572485810 --- /dev/null +++ b/arch/arm64/include/asm/initrd.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_INITRD_H +#define __ASM_INITRD_H + +#ifdef CONFIG_BLK_DEV_INITRD +#define __early_init_dt_declare_initrd(__start, __end) \ + do {\ + initrd_start = (__start); \ + initrd_end = (__end); \ + } while (0) +#endif + +#endif /* __ASM_INITRD_H */ diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b96442960aea..dc3ca21ba240 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -168,14 +168,6 @@ #define IOREMAP_MAX_ORDER (PMD_SHIFT) #endif -#ifdef CONFIG_BLK_DEV_INITRD -#define __early_init_dt_declare_initrd(__start, __end) \ - do {\ - initrd_start = (__start); \ - initrd_end = (__end); \ - } while (0) -#endif - #ifndef __ASSEMBLY__ #include diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 800ad252cf9c..4e4711af907b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -28,6 +28,7 @@ #include /* for COMMAND_LINE_SIZE */ #include +#include #include "of_private.h" -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 0/2] arm64: Cut rebuild time when changing CONFIG_BLK_DEV_INITRD
Hi all, While investigating why ARM64 required a ton of objects to be rebuilt when toggling CONFIG_DEV_BLK_INITRD, it became clear that this was because we define __early_init_dt_declare_initrd() differently and we do that in arch/arm64/include/asm/memory.h which gets included by a fair amount of other header files, and translation units as well. Changing the value of CONFIG_DEV_BLK_INITRD is a common thing with build systems that generate two kernels: one with the initramfs and one without. buildroot is one of these build systems, OpenWrt is also another one that does this. This patch series proposes adding an empty initrd.h to satisfy the need for drivers/of/fdt.c to unconditionally include that file, and moves the custom __early_init_dt_declare_initrd() definition away from asm/memory.h This cuts the number of objects rebuilds from 1920 down to 26, so a factor 73 approximately. Apologies for the long CC list, please let me know how you would go about merging that and if another approach would be preferable, e.g: introducing a CONFIG_ARCH_INITRD_BELOW_START_OK Kconfig option or something like that. Changes in v2: - put an /* empty */ comment in the asm-generic/initrd.h file - trim down the CC list to maximize the chances of people receiving this Florian Fainelli (2): arch: Add asm-generic/initrd.h and make use of it for most architectures arm64: Create asm/initrd.h arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/Kbuild| 1 + arch/arm/include/asm/Kbuild| 1 + arch/arm64/include/asm/initrd.h| 13 + arch/arm64/include/asm/memory.h| 8 arch/c6x/include/asm/Kbuild| 1 + arch/h8300/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild| 1 + arch/ia64/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/Kbuild | 1 + arch/nds32/include/asm/Kbuild | 1 + arch/nios2/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/Kbuild| 1 + arch/riscv/include/asm/Kbuild | 1 + arch/s390/include/asm/Kbuild | 1 + arch/sh/include/asm/Kbuild | 1 + arch/sparc/include/asm/Kbuild | 1 + arch/um/include/asm/Kbuild | 1 + arch/unicore32/include/asm/Kbuild | 1 + arch/x86/include/asm/Kbuild| 1 + arch/xtensa/include/asm/Kbuild | 1 + drivers/of/fdt.c | 1 + include/asm-generic/initrd.h | 1 + 27 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 arch/arm64/include/asm/initrd.h create mode 100644 include/asm-generic/initrd.h -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH 2/2] arm64: Create asm/initrd.h
ARM64 is the only architecture that requires a re-definition of __early_init_dt_declare_initrd(). Now that we added the infrastructure in asm-generic to provide an asm/initrd.h file, properly break up that definition from asm/memory.h and make use of that header in drivers/of/fdt.c where this is used. This significantly cuts the number of objects that need to be rebuilt on ARM64 due to the repercusions of including asm/memory.h in several places. Signed-off-by: Florian Fainelli --- arch/arm64/include/asm/initrd.h | 13 + arch/arm64/include/asm/memory.h | 8 drivers/of/fdt.c| 1 + 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 arch/arm64/include/asm/initrd.h diff --git a/arch/arm64/include/asm/initrd.h b/arch/arm64/include/asm/initrd.h new file mode 100644 index ..0c9572485810 --- /dev/null +++ b/arch/arm64/include/asm/initrd.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_INITRD_H +#define __ASM_INITRD_H + +#ifdef CONFIG_BLK_DEV_INITRD +#define __early_init_dt_declare_initrd(__start, __end) \ + do {\ + initrd_start = (__start); \ + initrd_end = (__end); \ + } while (0) +#endif + +#endif /* __ASM_INITRD_H */ diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b96442960aea..dc3ca21ba240 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -168,14 +168,6 @@ #define IOREMAP_MAX_ORDER (PMD_SHIFT) #endif -#ifdef CONFIG_BLK_DEV_INITRD -#define __early_init_dt_declare_initrd(__start, __end) \ - do {\ - initrd_start = (__start); \ - initrd_end = (__end); \ - } while (0) -#endif - #ifndef __ASSEMBLY__ #include diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 800ad252cf9c..4e4711af907b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -28,6 +28,7 @@ #include /* for COMMAND_LINE_SIZE */ #include +#include #include "of_private.h" -- 2.17.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] net: phy: dp83867: Fix for automatically detected PHYs
On 02/03/2017 09:30 AM, Alexey Brodkin wrote: > Hi Andrew, > > On Fri, 2017-02-03 at 18:10 +0100, Andrew Lunn wrote: >> On Fri, Feb 03, 2017 at 07:52:37PM +0300, Alexey Brodkin wrote: >>> >>> Current implemntation returns ENODEV if device tree node for >>> phy is absent. But in reality there're many boards with the one >>> and only PHY on board and MACs that may find a PHY by querying >>> MDIO bus. One good example is STMMAC. >> >> Humm, not so sure about that. That check for an OF node has always >> been there, since day one for this driver. >> >> What has changed recently is where it looks for these device tree >> properties. It used to wrongly look in the MAC node. It was changed to >> look in the PHY node. So this is probably the reason you are having >> problems. > > Well we don't mention PHY node in our device trees because with > 1 PHY connected via MDIO bus there's no point in spending electrons > on adding extra stuff. That's a terrible justification, you are running Linux on devices, if you care about electrons run a tiny RTOS ;) > Well in case if default settings work fine - > which up until now was the case for us. You should really consider listing your Ethernet PHY as a child node of dwmac MDIO bus because that will be a correct and accurate representation of the hardware, and if the PHY driver needs specific properties to be given (e.g: random TX/RX delays, etc.) that is the only way you could communicate those properly to the PHY driver. > > Just in case that's a typical example: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arc/boot/dts/axs10x_mb.dtsi#n58 > > --->8--- > ethernet@0x18000 { > #interrupt-cells = <1>; > compatible = "snps,dwmac"; > reg = < 0x18000 0x2000 >; > interrupts = < 4 >; > interrupt-names = "macirq"; > phy-mode = "rgmii"; > snps,pbl = < 32 >; > clocks = <>; > clock-names = "stmmaceth"; > max-speed = <100>; > }; > --->8--- > > This is especially nice because we may change the base-board and use > there another PHY and as long we have drivers for all possible PHY built > in the kernel (or available via modules) proper driver will be instantiated > based on PHY ID read from MDIO. I.e. having no PHY node in DT adds > flexibility. The of_mdio code can automatically scan PHYs on the bus, and try to associate them with a proper Device Tree node reference, would that exist, but this is really fragile. -- Florian ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc