diff mbox series

[v3,6/6] RISC-V: Implement keepinitrd kernel parameter

Message ID 20190212135942.105008-7-anup.patel@wdc.com (mailing list archive)
State New, archived
Headers show
Series Fixmap support and MM cleanups | expand

Commit Message

Anup Patel Feb. 12, 2019, 2:01 p.m. UTC
This patch implements keepinitrd kernel parameter. By default,
keepinitrd=0 so initrd memory will be freed by default freed but
users can pass "keepinitrd=1" to keep the initrd memory.

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 <anup.patel@wdc.com>
---
 arch/riscv/kernel/setup.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Andreas Schwab Feb. 12, 2019, 2:07 p.m. UTC | #1
On Feb 12 2019, Anup Patel <Anup.Patel@wdc.com> wrote:

> This patch implements keepinitrd kernel parameter. By default,
> keepinitrd=0 so initrd memory will be freed by default freed but

-freed

Andreas.
diff mbox series

Patch

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 */