2019-01-19 13:30:36

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 0/6] Fixmap support and MM cleanups

This patchset does:
1. Moves MM related code from kernel/setup.c to mm/init.c
2. Implements compile-time fixed mappings

Using fixed mappings available, we can now get earlyprints
even without SBI calls. For example, we can use kernel
parameter "earlycon=uart8250,mmio,0x10000000" to get early
prints on QEMU virt machine without using SBI calls.

The patchset is tested on QEMU virt machine. It is based on
Linux-5.0-rc2 and can be found at riscv_fixmap_v2 branch of:
https://github.com/avpatel/linux.git.

Changes since v1:
- Use more characters per line in changelog of PATCH3
- Removed #ifndef __ASSEMBLY__ from PATCH5
- Use more characters per line in commets of PATCH5
- Added PATCH6 to implement keepinitrd kernel parameter

Anup Patel (6):
RISC-V: Move free_initrd_mem() to kernel/setup.c
RISC-V: Setup init_mm before parse_early_param()
RISC-V: Move setup_bootmem() to mm/init.c
RISC-V: Move setup_vm() to mm/init.c
RISC-V: Implement compile-time fixed mappings
RISC-V: Implement keepinitrd kernel parameter

arch/riscv/Kconfig | 3 +
arch/riscv/include/asm/fixmap.h | 44 +++++++++++
arch/riscv/include/asm/pgtable.h | 1 +
arch/riscv/kernel/setup.c | 114 ++++++----------------------
arch/riscv/mm/init.c | 124 ++++++++++++++++++++++++++++++-
5 files changed, 189 insertions(+), 97 deletions(-)
create mode 100644 arch/riscv/include/asm/fixmap.h

--
2.17.1



2019-01-19 13:30:36

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 4/6] RISC-V: Move setup_vm() to mm/init.c

The setup_vm() is responsible for setting up initial page table
hence should be placed in mm/init.c.

Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
arch/riscv/kernel/setup.c | 49 ---------------------------------------
arch/riscv/mm/init.c | 49 +++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index ab29a66a17fc..9cd583b6d1cd 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -102,55 +102,6 @@ void free_initrd_mem(unsigned long start, unsigned long end)
}
#endif /* CONFIG_BLK_DEV_INITRD */

-pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
-pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
-
-#ifndef __PAGETABLE_PMD_FOLDED
-#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT)
-pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss;
-pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
-#endif
-
-asmlinkage void __init setup_vm(void)
-{
- extern char _start;
- uintptr_t i;
- uintptr_t pa = (uintptr_t) &_start;
- pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC);
-
- va_pa_offset = PAGE_OFFSET - pa;
- pfn_base = PFN_DOWN(pa);
-
- /* Sanity check alignment and size */
- BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0);
- BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0);
-
-#ifndef __PAGETABLE_PMD_FOLDED
- trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
- pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd),
- __pgprot(_PAGE_TABLE));
- trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot);
-
- for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
- size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
- swapper_pg_dir[o] =
- pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i,
- __pgprot(_PAGE_TABLE));
- }
- for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++)
- swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot);
-#else
- trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
- pfn_pgd(PFN_DOWN(pa), prot);
-
- for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
- size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
- swapper_pg_dir[o] =
- pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot);
- }
-#endif
-}
-
void __init parse_dtb(unsigned int hartid, void *dtb)
{
if (!early_init_dt_scan(__va(dtb)))
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index d0965979ee70..f8e396dc80a4 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -102,3 +102,52 @@ void __init setup_bootmem(void)
&memblock.memory, 0);
}
}
+
+pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
+pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
+
+#ifndef __PAGETABLE_PMD_FOLDED
+#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT)
+pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss;
+pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
+#endif
+
+asmlinkage void __init setup_vm(void)
+{
+ extern char _start;
+ uintptr_t i;
+ uintptr_t pa = (uintptr_t) &_start;
+ pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC);
+
+ va_pa_offset = PAGE_OFFSET - pa;
+ pfn_base = PFN_DOWN(pa);
+
+ /* Sanity check alignment and size */
+ BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0);
+ BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0);
+
+#ifndef __PAGETABLE_PMD_FOLDED
+ trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd),
+ __pgprot(_PAGE_TABLE));
+ trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot);
+
+ for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
+ size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
+ swapper_pg_dir[o] =
+ pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i,
+ __pgprot(_PAGE_TABLE));
+ }
+ for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++)
+ swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot);
+#else
+ trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ pfn_pgd(PFN_DOWN(pa), prot);
+
+ for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
+ size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
+ swapper_pg_dir[o] =
+ pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot);
+ }
+#endif
+}
--
2.17.1


2019-01-19 13:30:36

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 2/6] RISC-V: Setup init_mm before parse_early_param()

We should setup init_mm before doing parse_early_param()
in setup_arch() to be consistent with setup_arch() of
other architectures such as x86, ARM, and ARM64.

Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/kernel/setup.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index f270adcc678f..577d8460d141 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -208,15 +208,15 @@ static void __init setup_bootmem(void)

void __init setup_arch(char **cmdline_p)
{
- *cmdline_p = boot_command_line;
-
- parse_early_param();
-
init_mm.start_code = (unsigned long) _stext;
init_mm.end_code = (unsigned long) _etext;
init_mm.end_data = (unsigned long) _edata;
init_mm.brk = (unsigned long) _end;

+ *cmdline_p = boot_command_line;
+
+ parse_early_param();
+
setup_bootmem();
paging_init();
unflatten_device_tree();
@@ -235,4 +235,3 @@ void __init setup_arch(char **cmdline_p)

riscv_fill_hwcap();
}
-
--
2.17.1


2019-01-19 13:30:36

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 3/6] RISC-V: Move setup_bootmem() to mm/init.c

The setup_bootmem() mainly populates memblocks and does early memory
reservations. The right location for this function is mm/init.c.

Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
arch/riscv/include/asm/pgtable.h | 1 +
arch/riscv/kernel/setup.c | 48 ++++----------------------------
arch/riscv/mm/init.c | 40 ++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 16301966d65b..35893810cba3 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -404,6 +404,7 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
#define kern_addr_valid(addr) (1) /* FIXME */
#endif

+extern void setup_bootmem(void);
extern void paging_init(void);

static inline void pgtable_cache_init(void)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 577d8460d141..ab29a66a17fc 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -163,49 +163,6 @@ void __init parse_dtb(unsigned int hartid, void *dtb)
#endif
}

-static void __init setup_bootmem(void)
-{
- struct memblock_region *reg;
- phys_addr_t mem_size = 0;
-
- /* Find the memory region containing the kernel */
- for_each_memblock(memory, reg) {
- phys_addr_t vmlinux_end = __pa(_end);
- phys_addr_t end = reg->base + reg->size;
-
- if (reg->base <= vmlinux_end && vmlinux_end <= end) {
- /*
- * Reserve from the start of the region to the end of
- * the kernel
- */
- memblock_reserve(reg->base, vmlinux_end - reg->base);
- mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
- }
- }
- BUG_ON(mem_size == 0);
-
- set_max_mapnr(PFN_DOWN(mem_size));
- max_low_pfn = memblock_end_of_DRAM();
-
-#ifdef CONFIG_BLK_DEV_INITRD
- setup_initrd();
-#endif /* CONFIG_BLK_DEV_INITRD */
-
- early_init_fdt_reserve_self();
- early_init_fdt_scan_reserved_mem();
- memblock_allow_resize();
- memblock_dump_all();
-
- for_each_memblock(memory, reg) {
- unsigned long start_pfn = memblock_region_memory_base_pfn(reg);
- unsigned long end_pfn = memblock_region_memory_end_pfn(reg);
-
- memblock_set_node(PFN_PHYS(start_pfn),
- PFN_PHYS(end_pfn - start_pfn),
- &memblock.memory, 0);
- }
-}
-
void __init setup_arch(char **cmdline_p)
{
init_mm.start_code = (unsigned long) _stext;
@@ -218,6 +175,11 @@ void __init setup_arch(char **cmdline_p)
parse_early_param();

setup_bootmem();
+
+#ifdef CONFIG_BLK_DEV_INITRD
+ setup_initrd();
+#endif /* CONFIG_BLK_DEV_INITRD */
+
paging_init();
unflatten_device_tree();

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index f354486f9b78..d0965979ee70 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -16,6 +16,7 @@
#include <linux/memblock.h>
#include <linux/swap.h>
#include <linux/sizes.h>
+#include <linux/of_fdt.h>

#include <asm/tlbflush.h>
#include <asm/sections.h>
@@ -62,3 +63,42 @@ void free_initmem(void)
{
free_initmem_default(0);
}
+
+void __init setup_bootmem(void)
+{
+ struct memblock_region *reg;
+ phys_addr_t mem_size = 0;
+
+ /* Find the memory region containing the kernel */
+ for_each_memblock(memory, reg) {
+ phys_addr_t vmlinux_end = __pa(_end);
+ phys_addr_t end = reg->base + reg->size;
+
+ if (reg->base <= vmlinux_end && vmlinux_end <= end) {
+ /*
+ * Reserve from the start of the region to the end of
+ * the kernel
+ */
+ memblock_reserve(reg->base, vmlinux_end - reg->base);
+ mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
+ }
+ }
+ BUG_ON(mem_size == 0);
+
+ set_max_mapnr(PFN_DOWN(mem_size));
+ max_low_pfn = memblock_end_of_DRAM();
+
+ early_init_fdt_reserve_self();
+ early_init_fdt_scan_reserved_mem();
+ memblock_allow_resize();
+ memblock_dump_all();
+
+ for_each_memblock(memory, reg) {
+ unsigned long start_pfn = memblock_region_memory_base_pfn(reg);
+ unsigned long end_pfn = memblock_region_memory_end_pfn(reg);
+
+ memblock_set_node(PFN_PHYS(start_pfn),
+ PFN_PHYS(end_pfn - start_pfn),
+ &memblock.memory, 0);
+ }
+}
--
2.17.1


2019-01-19 13:30:55

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 1/6] RISC-V: Move free_initrd_mem() to kernel/setup.c

We move free_initrd_mem() to kernel/setup.c so that all initrd
related functions are in one place.

Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
arch/riscv/kernel/setup.c | 4 ++++
arch/riscv/mm/init.c | 7 -------
2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 6e079e94b638..f270adcc678f 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -96,6 +96,10 @@ static void __init setup_initrd(void)
initrd_start = 0;
initrd_end = 0;
}
+
+void free_initrd_mem(unsigned long start, unsigned long end)
+{
+}
#endif /* CONFIG_BLK_DEV_INITRD */

pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 1d9bfaff60bc..f354486f9b78 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -14,7 +14,6 @@
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/memblock.h>
-#include <linux/initrd.h>
#include <linux/swap.h>
#include <linux/sizes.h>

@@ -63,9 +62,3 @@ void free_initmem(void)
{
free_initmem_default(0);
}
-
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
--
2.17.1


2019-01-19 13:32:13

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

This patch implements keepinitrd kernel parameter. By default,
keepinitrd=1 but users can pass "keepinitrd=0" to free-up
initrd memory at boot-time in free_initrd_mem() function.

The keepinitrd kernel parameter is already implemented by
unicore32, arm, and arm64 architectures and it is documented
at: Documentation/admin-guide/kernel-parameters.txt

Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/kernel/setup.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 9cd583b6d1cd..46e547dd8245 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -97,8 +97,20 @@ static void __init setup_initrd(void)
initrd_end = 0;
}

-void free_initrd_mem(unsigned long start, unsigned long end)
+static int keep_initrd __initdata;
+
+static int __init keepinitrd_setup(char *__unused)
+{
+ keep_initrd = 1;
+ return 1;
+}
+
+__setup("keepinitrd", keepinitrd_setup);
+
+void __init free_initrd_mem(unsigned long start, unsigned long end)
{
+ if (!keep_initrd)
+ memblock_free(__pa(start), end - start);
}
#endif /* CONFIG_BLK_DEV_INITRD */

--
2.17.1


2019-01-19 13:32:33

by Anup Patel

[permalink] [raw]
Subject: [PATCH v2 5/6] RISC-V: Implement compile-time fixed mappings

This patch implements compile-time virtual to physical
mappings. These compile-time fixed mappings can be used
by earlycon, ACPI, and early ioremap for creating fixed
mappings when FIX_EARLYCON_MEM=y.

To start with, we have enabled compile-time fixed
mappings for earlycon.

Signed-off-by: Anup Patel <[email protected]>
---
arch/riscv/Kconfig | 3 +++
arch/riscv/include/asm/fixmap.h | 44 +++++++++++++++++++++++++++++++++
arch/riscv/mm/init.c | 34 +++++++++++++++++++++++++
3 files changed, 81 insertions(+)
create mode 100644 arch/riscv/include/asm/fixmap.h

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index feeeaa60697c..c18bba5d0e32 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -89,6 +89,9 @@ config GENERIC_CSUM
config GENERIC_HWEIGHT
def_bool y

+config FIX_EARLYCON_MEM
+ def_bool y
+
config PGTABLE_LEVELS
int
default 3 if 64BIT
diff --git a/arch/riscv/include/asm/fixmap.h b/arch/riscv/include/asm/fixmap.h
new file mode 100644
index 000000000000..57afe604b495
--- /dev/null
+++ b/arch/riscv/include/asm/fixmap.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 Western Digital Corporation or its affiliates.
+ */
+
+#ifndef _ASM_RISCV_FIXMAP_H
+#define _ASM_RISCV_FIXMAP_H
+
+#include <linux/kernel.h>
+#include <linux/sizes.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+
+/*
+ * Here we define all the compile-time 'special' virtual addresses.
+ * The point is to have a constant address at compile time, but to
+ * set the physical address only in the boot process.
+ *
+ * These 'compile-time allocated' memory buffers are page-sized. Use
+ * set_fixmap(idx,phys) to associate physical memory with fixmap indices.
+ */
+enum fixed_addresses {
+ FIX_HOLE,
+ FIX_EARLYCON_MEM_BASE,
+ __end_of_fixed_addresses
+};
+
+#define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE)
+#define FIXADDR_TOP (PAGE_OFFSET)
+#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
+
+#define FIXMAP_PAGE_IO PAGE_KERNEL
+
+#define __early_set_fixmap __set_fixmap
+
+#define __late_set_fixmap __set_fixmap
+#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
+
+extern void __set_fixmap(enum fixed_addresses idx,
+ phys_addr_t phys, pgprot_t prot);
+
+#include <asm-generic/fixmap.h>
+
+#endif /* _ASM_RISCV_FIXMAP_H */
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index f8e396dc80a4..4c627b8d53c7 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -18,6 +18,7 @@
#include <linux/sizes.h>
#include <linux/of_fdt.h>

+#include <asm/fixmap.h>
#include <asm/tlbflush.h>
#include <asm/sections.h>
#include <asm/pgtable.h>
@@ -110,8 +111,28 @@ pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT)
pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss;
pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
+pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss;
#endif

+pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
+
+void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot)
+{
+ unsigned long addr = __fix_to_virt(idx);
+ pte_t *ptep;
+
+ BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses);
+
+ ptep = &fixmap_pte[pte_index(addr)];
+
+ if (pgprot_val(prot)) {
+ set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot));
+ } else {
+ pte_clear(&init_mm, addr, ptep);
+ local_flush_tlb_page(addr);
+ }
+}
+
asmlinkage void __init setup_vm(void)
{
extern char _start;
@@ -134,20 +155,33 @@ asmlinkage void __init setup_vm(void)

for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
+
swapper_pg_dir[o] =
pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i,
__pgprot(_PAGE_TABLE));
}
for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++)
swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot);
+
+ swapper_pg_dir[(FIXADDR_START >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ pfn_pgd(PFN_DOWN((uintptr_t)fixmap_pmd),
+ __pgprot(_PAGE_TABLE));
+ fixmap_pmd[(FIXADDR_START >> PMD_SHIFT) % PTRS_PER_PMD] =
+ pfn_pmd(PFN_DOWN((uintptr_t)fixmap_pte),
+ __pgprot(_PAGE_TABLE));
#else
trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
pfn_pgd(PFN_DOWN(pa), prot);

for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
+
swapper_pg_dir[o] =
pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot);
}
+
+ swapper_pg_dir[(FIXADDR_START >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ pfn_pgd(PFN_DOWN((uintptr_t)fixmap_pte),
+ __pgprot(_PAGE_TABLE));
#endif
}
--
2.17.1


2019-02-11 06:29:17

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] Fixmap support and MM cleanups

Hi All,

Any comments on this series ??

Regards,
Anup

2019-02-12 07:06:22

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/6] RISC-V: Setup init_mm before parse_early_param()

On Sat, Jan 19, 2019 at 01:28:07PM +0000, Anup Patel wrote:
> We should setup init_mm before doing parse_early_param()
> in setup_arch() to be consistent with setup_arch() of
> other architectures such as x86, ARM, and ARM64.

Please use up all 72 lines in all your commit logs..

Otherwise looks fine:

Reviewed-by: Christoph Hellwig <[email protected]>

2019-02-12 07:07:32

by Christoph Hellwig

[permalink] [raw]

2019-02-12 07:08:36

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Sat, Jan 19, 2019 at 01:28:59PM +0000, Anup Patel wrote:
> This patch implements keepinitrd kernel parameter. By default,
> keepinitrd=1 but users can pass "keepinitrd=0" to free-up
> initrd memory at boot-time in free_initrd_mem() function.
>
> The keepinitrd kernel parameter is already implemented by
> unicore32, arm, and arm64 architectures and it is documented
> at: Documentation/admin-guide/kernel-parameters.txt

But why do we need it? Is there any good reason every not to free
the initrd / initramfs memory when it is not used?

2019-02-12 10:25:05

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Tue, Feb 12, 2019 at 12:38 PM Christoph Hellwig <[email protected]> wrote:
>
> On Sat, Jan 19, 2019 at 01:28:59PM +0000, Anup Patel wrote:
> > This patch implements keepinitrd kernel parameter. By default,
> > keepinitrd=1 but users can pass "keepinitrd=0" to free-up
> > initrd memory at boot-time in free_initrd_mem() function.
> >
> > The keepinitrd kernel parameter is already implemented by
> > unicore32, arm, and arm64 architectures and it is documented
> > at: Documentation/admin-guide/kernel-parameters.txt
>
> But why do we need it? Is there any good reason every not to free
> the initrd / initramfs memory when it is not used?

If it is initramfs (i.e. CPIO image) then contents of CPIO archive
are extracted to create a ramfs instance.

If it is initrd (i.e. some filesystem image) then RAM block device
is created in-place at initrd location. (Please correct me if I am
wrong about initrd here).

So in case of initrd we might not want to free-up the RAM but
we can certainly free-up in case of initramfs.

Regards,
Anup

2019-02-12 10:38:14

by Andreas Schwab

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Feb 12 2019, Anup Patel <[email protected]> wrote:

> So in case of initrd we might not want to free-up the RAM but
> we can certainly free-up in case of initramfs.

But the default should be keepinitrd=0, shoudn't it?

Andreas.

--
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

2019-02-12 13:55:28

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Tue, Feb 12, 2019 at 4:07 PM Andreas Schwab <[email protected]> wrote:
>
> On Feb 12 2019, Anup Patel <[email protected]> wrote:
>
> > So in case of initrd we might not want to free-up the RAM but
> > we can certainly free-up in case of initramfs.
>
> But the default should be keepinitrd=0, shoudn't it?

Actually, it is keepinitrd=0 by default but the commit description
is reverse. I will fix the commit description.

Regards,
Anup

2019-02-12 19:43:11

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Tue, Feb 12, 2019 at 03:53:21PM +0530, Anup Patel wrote:
> If it is initramfs (i.e. CPIO image) then contents of CPIO archive
> are extracted to create a ramfs instance.
>
> If it is initrd (i.e. some filesystem image) then RAM block device
> is created in-place at initrd location. (Please correct me if I am
> wrong about initrd here).

No. If it is an initrd image we still copy it into the rootfs first,
and then load it into a ram disk. Take a look at
init/initramfs.c:populate_rootfs() and
init/do_mounts_initrd.c:initrd_load().

> So in case of initrd we might not want to free-up the RAM but
> we can certainly free-up in case of initramfs.

No, in either case we do not need the original initramfs/initrd
memory. I suspect arm has this as a workaround for some weird
legacy boot issue, but I can't see any reason why we would not want
to free the memory on riscv.

2019-02-12 22:29:41

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Sat, 19 Jan 2019 05:28:59 PST (-0800), [email protected] wrote:
> This patch implements keepinitrd kernel parameter. By default,
> keepinitrd=1 but users can pass "keepinitrd=0" to free-up
> initrd memory at boot-time in free_initrd_mem() function.
>
> The keepinitrd kernel parameter is already implemented by
> unicore32, arm, and arm64 architectures and it is documented
> at: Documentation/admin-guide/kernel-parameters.txt

All I see is

"

keepinitrd [HW,ARM]

"

which is pretty lacking for documentation and should be improved...

I'm happy to take this as it stands for the next merge window, as if you hadn't
mentioned documentation then I wouldn't have looked :)

> Signed-off-by: Anup Patel <[email protected]>
> ---
> arch/riscv/kernel/setup.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index 9cd583b6d1cd..46e547dd8245 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -97,8 +97,20 @@ static void __init setup_initrd(void)
> initrd_end = 0;
> }
>
> -void free_initrd_mem(unsigned long start, unsigned long end)
> +static int keep_initrd __initdata;
> +
> +static int __init keepinitrd_setup(char *__unused)
> +{
> + keep_initrd = 1;
> + return 1;
> +}
> +
> +__setup("keepinitrd", keepinitrd_setup);
> +
> +void __init free_initrd_mem(unsigned long start, unsigned long end)
> {
> + if (!keep_initrd)
> + memblock_free(__pa(start), end - start);
> }
> #endif /* CONFIG_BLK_DEV_INITRD */
>
> --
> 2.17.1

2019-02-13 02:20:06

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] Fixmap support and MM cleanups

On Sat, 19 Jan 2019 05:27:53 PST (-0800), Anup Patel wrote:
> This patchset does:
> 1. Moves MM related code from kernel/setup.c to mm/init.c
> 2. Implements compile-time fixed mappings
>
> Using fixed mappings available, we can now get earlyprints
> even without SBI calls. For example, we can use kernel
> parameter "earlycon=uart8250,mmio,0x10000000" to get early
> prints on QEMU virt machine without using SBI calls.
>
> The patchset is tested on QEMU virt machine. It is based on
> Linux-5.0-rc2 and can be found at riscv_fixmap_v2 branch of:
> https://github.com/avpatel/linux.git.
>
> Changes since v1:
> - Use more characters per line in changelog of PATCH3
> - Removed #ifndef __ASSEMBLY__ from PATCH5
> - Use more characters per line in commets of PATCH5
> - Added PATCH6 to implement keepinitrd kernel parameter
>
> Anup Patel (6):
> RISC-V: Move free_initrd_mem() to kernel/setup.c
> RISC-V: Setup init_mm before parse_early_param()
> RISC-V: Move setup_bootmem() to mm/init.c
> RISC-V: Move setup_vm() to mm/init.c
> RISC-V: Implement compile-time fixed mappings
> RISC-V: Implement keepinitrd kernel parameter
>
> arch/riscv/Kconfig | 3 +
> arch/riscv/include/asm/fixmap.h | 44 +++++++++++
> arch/riscv/include/asm/pgtable.h | 1 +
> arch/riscv/kernel/setup.c | 114 ++++++----------------------
> arch/riscv/mm/init.c | 124 ++++++++++++++++++++++++++++++-
> 5 files changed, 189 insertions(+), 97 deletions(-)
> create mode 100644 arch/riscv/include/asm/fixmap.h

I'm getting some git issue when trying to merge the third patch via email

$ mhng-pipe-show_stdout 4 | git am -s
Applying: RISC-V: Move setup_bootmem() to mm/init.c
error: patch failed: arch/riscv/kernel/setup.c:163
error: arch/riscv/kernel/setup.c: patch does not apply
Patch failed at 0001 RISC-V: Move setup_bootmem() to mm/init.c
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

can you send a PR with a signed tag? I'll include this as part of the next
merge window.

Reviewed-by: Palmer Dabbelt <[email protected]>

Thanks!

2019-02-13 09:18:28

by Anup Patel

[permalink] [raw]
Subject: RE: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter



> -----Original Message-----
> From: [email protected] [mailto:linux-kernel-
> [email protected]] On Behalf Of Christoph Hellwig
> Sent: Wednesday, February 13, 2019 12:15 AM
> To: Anup Patel <[email protected]>
> Cc: Christoph Hellwig <[email protected]>; Palmer Dabbelt
> <[email protected]>; Anup Patel <[email protected]>; linux-
> [email protected]; Atish Patra <[email protected]>; Albert Ou
> <[email protected]>; Paul Walmsley <[email protected]>;
> [email protected]
> Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter
>
> On Tue, Feb 12, 2019 at 03:53:21PM +0530, Anup Patel wrote:
> > If it is initramfs (i.e. CPIO image) then contents of CPIO archive are
> > extracted to create a ramfs instance.
> >
> > If it is initrd (i.e. some filesystem image) then RAM block device is
> > created in-place at initrd location. (Please correct me if I am wrong
> > about initrd here).
>
> No. If it is an initrd image we still copy it into the rootfs first, and then load it
> into a ram disk. Take a look at
> init/initramfs.c:populate_rootfs() and
> init/do_mounts_initrd.c:initrd_load().
>
> > So in case of initrd we might not want to free-up the RAM but we can
> > certainly free-up in case of initramfs.
>
> No, in either case we do not need the original initramfs/initrd memory. I
> suspect arm has this as a workaround for some weird legacy boot issue, but I
> can't see any reason why we would not want to free the memory on riscv.

Sure, the keepinitrd=0 by default so it will always free-up initrd by default.
Please look at v3 patchset.

Of course, we need separate patch to update documentation of keepinitrd.

Regards,
Anup

2019-02-13 09:31:58

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter

On Wed, Feb 13, 2019 at 03:43:06AM +0000, Anup Patel wrote:
> Sure, the keepinitrd=0 by default so it will always free-up initrd by default.
> Please look at v3 patchset.
>
> Of course, we need separate patch to update documentation of keepinitrd.

No, we need to not just blindly copy what arm did for historic reasons
unless we have a very good reason of our own.

In addition to not having a real need for any of this in a new setup,
it also is duplicated by the retain_initrd parameter which is
implemented in generic code - and for that the commit message at least
has a rationale related to kexec:

https://lkml.org/lkml/2006/12/7/15

2019-02-13 09:33:14

by Anup Patel

[permalink] [raw]
Subject: RE: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter



> -----Original Message-----
> From: Christoph Hellwig [mailto:[email protected]]
> Sent: Wednesday, February 13, 2019 11:25 AM
> To: Anup Patel <[email protected]>
> Cc: Christoph Hellwig <[email protected]>; Anup Patel
> <[email protected]>; Palmer Dabbelt <[email protected]>; linux-
> [email protected]; Atish Patra <[email protected]>; Albert Ou
> <[email protected]>; Paul Walmsley <[email protected]>;
> [email protected]
> Subject: Re: [PATCH v2 6/6] RISC-V: Implement keepinitrd kernel parameter
>
> On Wed, Feb 13, 2019 at 03:43:06AM +0000, Anup Patel wrote:
> > Sure, the keepinitrd=0 by default so it will always free-up initrd by default.
> > Please look at v3 patchset.
> >
> > Of course, we need separate patch to update documentation of
> keepinitrd.
>
> No, we need to not just blindly copy what arm did for historic reasons unless
> we have a very good reason of our own.
>
> In addition to not having a real need for any of this in a new setup, it also is
> duplicated by the retain_initrd parameter which is implemented in generic
> code - and for that the commit message at least has a rationale related to
> kexec:
>
> https://lkml.org/lkml/2006/12/7/15

Sure, I will re-work this patch to always free-up initrd.

Regards,
Anup

2019-02-13 12:57:18

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] Fixmap support and MM cleanups

On Wed, Feb 13, 2019 at 4:45 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Sat, 19 Jan 2019 05:27:53 PST (-0800), Anup Patel wrote:
> > This patchset does:
> > 1. Moves MM related code from kernel/setup.c to mm/init.c
> > 2. Implements compile-time fixed mappings
> >
> > Using fixed mappings available, we can now get earlyprints
> > even without SBI calls. For example, we can use kernel
> > parameter "earlycon=uart8250,mmio,0x10000000" to get early
> > prints on QEMU virt machine without using SBI calls.
> >
> > The patchset is tested on QEMU virt machine. It is based on
> > Linux-5.0-rc2 and can be found at riscv_fixmap_v2 branch of:
> > https://github.com/avpatel/linux.git.
> >
> > Changes since v1:
> > - Use more characters per line in changelog of PATCH3
> > - Removed #ifndef __ASSEMBLY__ from PATCH5
> > - Use more characters per line in commets of PATCH5
> > - Added PATCH6 to implement keepinitrd kernel parameter
> >
> > Anup Patel (6):
> > RISC-V: Move free_initrd_mem() to kernel/setup.c
> > RISC-V: Setup init_mm before parse_early_param()
> > RISC-V: Move setup_bootmem() to mm/init.c
> > RISC-V: Move setup_vm() to mm/init.c
> > RISC-V: Implement compile-time fixed mappings
> > RISC-V: Implement keepinitrd kernel parameter
> >
> > arch/riscv/Kconfig | 3 +
> > arch/riscv/include/asm/fixmap.h | 44 +++++++++++
> > arch/riscv/include/asm/pgtable.h | 1 +
> > arch/riscv/kernel/setup.c | 114 ++++++----------------------
> > arch/riscv/mm/init.c | 124 ++++++++++++++++++++++++++++++-
> > 5 files changed, 189 insertions(+), 97 deletions(-)
> > create mode 100644 arch/riscv/include/asm/fixmap.h
>
> I'm getting some git issue when trying to merge the third patch via email
>
> $ mhng-pipe-show_stdout 4 | git am -s
> Applying: RISC-V: Move setup_bootmem() to mm/init.c
> error: patch failed: arch/riscv/kernel/setup.c:163
> error: arch/riscv/kernel/setup.c: patch does not apply
> Patch failed at 0001 RISC-V: Move setup_bootmem() to mm/init.c
> Use 'git am --show-current-patch' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
> can you send a PR with a signed tag? I'll include this as part of the next
> merge window.
>
> Reviewed-by: Palmer Dabbelt <[email protected]>

Okay, I will prepare a PR with following patchsets:
1. Fixmap support and MM cleanups (Author: Anup Patel)
2. riscv: minor fixes and cleanups (Author: Johan Hovold)
3. RISC-V related changes from "Various SMP related fixes" (Author: Atish Patra)

All above patchsets touch same source files so this will
help you.

Regards,
Anup

2019-02-13 13:31:37

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] Fixmap support and MM cleanups

On Wed, Feb 13, 2019 at 01:51:43PM +0530, Anup Patel wrote:
> On Wed, Feb 13, 2019 at 4:45 AM Palmer Dabbelt <[email protected]> wrote:
> >
> > On Sat, 19 Jan 2019 05:27:53 PST (-0800), Anup Patel wrote:
> > > This patchset does:
> > > 1. Moves MM related code from kernel/setup.c to mm/init.c
> > > 2. Implements compile-time fixed mappings

> > > arch/riscv/Kconfig | 3 +
> > > arch/riscv/include/asm/fixmap.h | 44 +++++++++++
> > > arch/riscv/include/asm/pgtable.h | 1 +
> > > arch/riscv/kernel/setup.c | 114 ++++++----------------------
> > > arch/riscv/mm/init.c | 124 ++++++++++++++++++++++++++++++-
> > > 5 files changed, 189 insertions(+), 97 deletions(-)
> > > create mode 100644 arch/riscv/include/asm/fixmap.h
> >
> > I'm getting some git issue when trying to merge the third patch via email
> >
> > $ mhng-pipe-show_stdout 4 | git am -s
> > Applying: RISC-V: Move setup_bootmem() to mm/init.c
> > error: patch failed: arch/riscv/kernel/setup.c:163
> > error: arch/riscv/kernel/setup.c: patch does not apply
> > Patch failed at 0001 RISC-V: Move setup_bootmem() to mm/init.c
> > Use 'git am --show-current-patch' to see the failed patch
> > When you have resolved this problem, run "git am --continue".
> > If you prefer to skip this patch, run "git am --skip" instead.
> > To restore the original branch and stop patching, run "git am --abort".
> >
> > can you send a PR with a signed tag? I'll include this as part of the next
> > merge window.
> >
> > Reviewed-by: Palmer Dabbelt <[email protected]>
>
> Okay, I will prepare a PR with following patchsets:
> 1. Fixmap support and MM cleanups (Author: Anup Patel)
> 2. riscv: minor fixes and cleanups (Author: Johan Hovold)
> 3. RISC-V related changes from "Various SMP related fixes" (Author: Atish Patra)
>
> All above patchsets touch same source files so this will
> help you.

I'd suggest keeping these separate. Your series failed to apply, and it
looks like you've now posted a v4 to address that.

If your series is merged before mine, I'm sure any conflicts are
trivial, or I can always respin.

Atish's series might need another revision, so that one should not be
included either.

Johan

2019-02-14 10:06:35

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] Fixmap support and MM cleanups

On Wed, 13 Feb 2019 00:21:43 PST (-0800), [email protected] wrote:
> On Wed, Feb 13, 2019 at 4:45 AM Palmer Dabbelt <[email protected]> wrote:
>>
>> On Sat, 19 Jan 2019 05:27:53 PST (-0800), Anup Patel wrote:
>> > This patchset does:
>> > 1. Moves MM related code from kernel/setup.c to mm/init.c
>> > 2. Implements compile-time fixed mappings
>> >
>> > Using fixed mappings available, we can now get earlyprints
>> > even without SBI calls. For example, we can use kernel
>> > parameter "earlycon=uart8250,mmio,0x10000000" to get early
>> > prints on QEMU virt machine without using SBI calls.
>> >
>> > The patchset is tested on QEMU virt machine. It is based on
>> > Linux-5.0-rc2 and can be found at riscv_fixmap_v2 branch of:
>> > https://github.com/avpatel/linux.git.
>> >
>> > Changes since v1:
>> > - Use more characters per line in changelog of PATCH3
>> > - Removed #ifndef __ASSEMBLY__ from PATCH5
>> > - Use more characters per line in commets of PATCH5
>> > - Added PATCH6 to implement keepinitrd kernel parameter
>> >
>> > Anup Patel (6):
>> > RISC-V: Move free_initrd_mem() to kernel/setup.c
>> > RISC-V: Setup init_mm before parse_early_param()
>> > RISC-V: Move setup_bootmem() to mm/init.c
>> > RISC-V: Move setup_vm() to mm/init.c
>> > RISC-V: Implement compile-time fixed mappings
>> > RISC-V: Implement keepinitrd kernel parameter
>> >
>> > arch/riscv/Kconfig | 3 +
>> > arch/riscv/include/asm/fixmap.h | 44 +++++++++++
>> > arch/riscv/include/asm/pgtable.h | 1 +
>> > arch/riscv/kernel/setup.c | 114 ++++++----------------------
>> > arch/riscv/mm/init.c | 124 ++++++++++++++++++++++++++++++-
>> > 5 files changed, 189 insertions(+), 97 deletions(-)
>> > create mode 100644 arch/riscv/include/asm/fixmap.h
>>
>> I'm getting some git issue when trying to merge the third patch via email
>>
>> $ mhng-pipe-show_stdout 4 | git am -s
>> Applying: RISC-V: Move setup_bootmem() to mm/init.c
>> error: patch failed: arch/riscv/kernel/setup.c:163
>> error: arch/riscv/kernel/setup.c: patch does not apply
>> Patch failed at 0001 RISC-V: Move setup_bootmem() to mm/init.c
>> Use 'git am --show-current-patch' to see the failed patch
>> When you have resolved this problem, run "git am --continue".
>> If you prefer to skip this patch, run "git am --skip" instead.
>> To restore the original branch and stop patching, run "git am --abort".
>>
>> can you send a PR with a signed tag? I'll include this as part of the next
>> merge window.
>>
>> Reviewed-by: Palmer Dabbelt <[email protected]>
>
> Okay, I will prepare a PR with following patchsets:
> 1. Fixmap support and MM cleanups (Author: Anup Patel)
> 2. riscv: minor fixes and cleanups (Author: Johan Hovold)
> 3. RISC-V related changes from "Various SMP related fixes" (Author: Atish Patra)
>
> All above patchsets touch same source files so this will
> help you.

Thanks. There's also a handful of comments from Christoph that I agree with
about the keepinitrd stuff.

2019-02-14 17:07:27

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] Fixmap support and MM cleanups

On Thu, Feb 14, 2019 at 6:07 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Wed, 13 Feb 2019 00:21:43 PST (-0800), [email protected] wrote:
> > On Wed, Feb 13, 2019 at 4:45 AM Palmer Dabbelt <[email protected]> wrote:
> >>
> >> On Sat, 19 Jan 2019 05:27:53 PST (-0800), Anup Patel wrote:
> >> > This patchset does:
> >> > 1. Moves MM related code from kernel/setup.c to mm/init.c
> >> > 2. Implements compile-time fixed mappings
> >> >
> >> > Using fixed mappings available, we can now get earlyprints
> >> > even without SBI calls. For example, we can use kernel
> >> > parameter "earlycon=uart8250,mmio,0x10000000" to get early
> >> > prints on QEMU virt machine without using SBI calls.
> >> >
> >> > The patchset is tested on QEMU virt machine. It is based on
> >> > Linux-5.0-rc2 and can be found at riscv_fixmap_v2 branch of:
> >> > https://github.com/avpatel/linux.git.
> >> >
> >> > Changes since v1:
> >> > - Use more characters per line in changelog of PATCH3
> >> > - Removed #ifndef __ASSEMBLY__ from PATCH5
> >> > - Use more characters per line in commets of PATCH5
> >> > - Added PATCH6 to implement keepinitrd kernel parameter
> >> >
> >> > Anup Patel (6):
> >> > RISC-V: Move free_initrd_mem() to kernel/setup.c
> >> > RISC-V: Setup init_mm before parse_early_param()
> >> > RISC-V: Move setup_bootmem() to mm/init.c
> >> > RISC-V: Move setup_vm() to mm/init.c
> >> > RISC-V: Implement compile-time fixed mappings
> >> > RISC-V: Implement keepinitrd kernel parameter
> >> >
> >> > arch/riscv/Kconfig | 3 +
> >> > arch/riscv/include/asm/fixmap.h | 44 +++++++++++
> >> > arch/riscv/include/asm/pgtable.h | 1 +
> >> > arch/riscv/kernel/setup.c | 114 ++++++----------------------
> >> > arch/riscv/mm/init.c | 124 ++++++++++++++++++++++++++++++-
> >> > 5 files changed, 189 insertions(+), 97 deletions(-)
> >> > create mode 100644 arch/riscv/include/asm/fixmap.h
> >>
> >> I'm getting some git issue when trying to merge the third patch via email
> >>
> >> $ mhng-pipe-show_stdout 4 | git am -s
> >> Applying: RISC-V: Move setup_bootmem() to mm/init.c
> >> error: patch failed: arch/riscv/kernel/setup.c:163
> >> error: arch/riscv/kernel/setup.c: patch does not apply
> >> Patch failed at 0001 RISC-V: Move setup_bootmem() to mm/init.c
> >> Use 'git am --show-current-patch' to see the failed patch
> >> When you have resolved this problem, run "git am --continue".
> >> If you prefer to skip this patch, run "git am --skip" instead.
> >> To restore the original branch and stop patching, run "git am --abort".
> >>
> >> can you send a PR with a signed tag? I'll include this as part of the next
> >> merge window.
> >>
> >> Reviewed-by: Palmer Dabbelt <[email protected]>
> >
> > Okay, I will prepare a PR with following patchsets:
> > 1. Fixmap support and MM cleanups (Author: Anup Patel)
> > 2. riscv: minor fixes and cleanups (Author: Johan Hovold)
> > 3. RISC-V related changes from "Various SMP related fixes" (Author: Atish Patra)
> >
> > All above patchsets touch same source files so this will
> > help you.
>
> Thanks. There's also a handful of comments from Christoph that I agree with
> about the keepinitrd stuff.

I have sent PR with Fixmap patches only.

Johan and Atish will rebase their patches based on your tree.

Regards,
Anup