Skip to contentSkip to conversation

riscv: Implement free_initrd_mem.

PATCH Superseded Shea Levy 2 participants 7 messages Feb 20, 2018 – Mar 8, 2018 RISC-V

lore
Share & tools
lore

Shea Levy

author
#0 lore raw

PATCH 1/1 riscv: Implement free_initrd_mem.

---
 arch/riscv/mm/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/mm/init.c +6 -0
index c77df8142be2..1c832b541e95 100644
@@ -66,5 +66,11 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	if (start == initrd_start)
+		start = round_down(start, PAGE_SIZE);
+	if (end == initrd_end)
+		end = round_up(end, PAGE_SIZE);
+
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
Signature · 1 line
2.16.1
author
#1 lore raw

PATCH v2 1/1 riscv: Implement free_initrd_mem.

v2: Remove incorrect page alignment.

---
 arch/riscv/mm/init.c | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/mm/init.c +1 -0
index c77df8142be2..1b6daa5184e0 100644
@@ -66,5 +66,6 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
Signature · 1 line
2.16.1
#2 lore raw
In reply to Shea Levy
Quoted 11 lines · shea at shealevy.com
---
 arch/riscv/mm/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/mm/init.c +0 -0
index c77df8142be2..1c832b541e95 100644
@@ -66,5 +66,11 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD

arch/riscv/mm/init.c void free_initmem(void) · line 76

Quoted 10 lines
arch/riscv/mm/init.c +6 -0
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	if (start == initrd_start)
+		start = round_down(start, PAGE_SIZE);
+	if (end == initrd_end)
+		end = round_up(end, PAGE_SIZE);
+
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */

It looks like everyone is doing something slightly different here:

* arm64 doesn't round to a page size, and has keep_initrd.
* arm calls poison_init_mem(), and has keep_initrd.
* sparc64 doesn't round, and doesn't have a keep_initrd.
* mips doesn't round, and doesn't have a keep_initrd.
* x86 rounds end to a page size but not start, and doesn't have a keep_initrd.

It feels like this should be something generic. I'm adding linux-kernel to see what people think.

author
#3 lore raw

Hi Palmer,

Quoted 25 lines · Palmer Dabbelt
Quoted 11 lines · shea at shealevy.com
---
 arch/riscv/mm/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/mm/init.c +0 -0
index c77df8142be2..1c832b541e95 100644
@@ -66,5 +66,11 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD

arch/riscv/mm/init.c void free_initmem(void) · line 76

Quoted 10 lines
arch/riscv/mm/init.c +6 -0
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	if (start == initrd_start)
+		start = round_down(start, PAGE_SIZE);
+	if (end == initrd_end)
+		end = round_up(end, PAGE_SIZE);
+
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */

It looks like everyone is doing something slightly different here:

Quoted 8 lines

* arm64 doesn't round to a page size, and has keep_initrd.
* arm calls poison_init_mem(), and has keep_initrd.
* sparc64 doesn't round, and doesn't have a keep_initrd.
* mips doesn't round, and doesn't have a keep_initrd.
* x86 rounds end to a page size but not start, and doesn't have a keep_initrd.

It feels like this should be something generic. I'm adding linux-kernel to see what people think.

Should I try to whip up something generic?

Thanks,
Shea
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20180308/74bf8d50/attachment.sig>

#4 lore raw
Quoted 35 lines · shea at shealevy.com

Hi Palmer,

Quoted 31 lines · Palmer Dabbelt
Quoted 11 lines · shea at shealevy.com
---
 arch/riscv/mm/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/mm/init.c +0 -0
index c77df8142be2..1c832b541e95 100644
@@ -66,5 +66,11 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD

arch/riscv/mm/init.c void free_initmem(void) · line 76

Quoted 10 lines
arch/riscv/mm/init.c +6 -0
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	if (start == initrd_start)
+		start = round_down(start, PAGE_SIZE);
+	if (end == initrd_end)
+		end = round_up(end, PAGE_SIZE);
+
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */

It looks like everyone is doing something slightly different here:

* arm64 doesn't round to a page size, and has keep_initrd.
* arm calls poison_init_mem(), and has keep_initrd.
* sparc64 doesn't round, and doesn't have a keep_initrd.
* mips doesn't round, and doesn't have a keep_initrd.
* x86 rounds end to a page size but not start, and doesn't have a keep_initrd.

Quoted 4 lines
Quoted 2 lines

It feels like this should be something generic. I'm adding linux-kernel to see what people think.

Should I try to whip up something generic?

I think that'd be best. Nobody has said anything specific, but it's generally been suggested to take bits that we copy into our port and make them generic. If there's no clean way do to so then I'm OK taking this, though.

author
#5 lore raw
Quoted 36 lines · Palmer Dabbelt
Quoted 35 lines · shea at shealevy.com

Hi Palmer,

Quoted 31 lines · Palmer Dabbelt
Quoted 11 lines · shea at shealevy.com
---
 arch/riscv/mm/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/mm/init.c +0 -0
index c77df8142be2..1c832b541e95 100644
@@ -66,5 +66,11 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD

arch/riscv/mm/init.c void free_initmem(void) · line 76

Quoted 10 lines
arch/riscv/mm/init.c +6 -0
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	if (start == initrd_start)
+		start = round_down(start, PAGE_SIZE);
+	if (end == initrd_end)
+		end = round_up(end, PAGE_SIZE);
+
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */

It looks like everyone is doing something slightly different here:

* arm64 doesn't round to a page size, and has keep_initrd.
* arm calls poison_init_mem(), and has keep_initrd.
* sparc64 doesn't round, and doesn't have a keep_initrd.
* mips doesn't round, and doesn't have a keep_initrd.
* x86 rounds end to a page size but not start, and doesn't have a keep_initrd.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

It feels like this should be something generic. I'm adding linux-kernel to see what people think.

Should I try to whip up something generic?

I think that'd be best. Nobody has said anything specific, but it's generally been suggested to take bits that we copy into our port and make them generic. If there's no clean way do to so then I'm OK taking this, though.

OK, will add it to my queue.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20180308/1ab4f3cb/attachment.sig>

#6 lore raw
Quoted 41 lines · shea at shealevy.com
Quoted 39 lines · Palmer Dabbelt
Quoted 38 lines · shea at shealevy.com

Hi Palmer,

Quoted 33 lines · Palmer Dabbelt
Quoted 11 lines · shea at shealevy.com
---
 arch/riscv/mm/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/mm/init.c +0 -0
index c77df8142be2..1c832b541e95 100644
@@ -66,5 +66,11 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD

arch/riscv/mm/init.c void free_initmem(void) · line 76

Quoted 10 lines
arch/riscv/mm/init.c +6 -0
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	if (start == initrd_start)
+		start = round_down(start, PAGE_SIZE);
+	if (end == initrd_end)
+		end = round_up(end, PAGE_SIZE);
+
+	free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
 #endif /* CONFIG_BLK_DEV_INITRD */

It looks like everyone is doing something slightly different here:

* arm64 doesn't round to a page size, and has keep_initrd.
* arm calls poison_init_mem(), and has keep_initrd.
* sparc64 doesn't round, and doesn't have a keep_initrd.
* mips doesn't round, and doesn't have a keep_initrd.
* x86 rounds end to a page size but not start, and doesn't have a keep_initrd.

It feels like this should be something generic. I'm adding linux-kernel to see what people think.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Should I try to whip up something generic?

I think that'd be best. Nobody has said anything specific, but it's generally been suggested to take bits that we copy into our port and make them generic. If there's no clean way do to so then I'm OK taking this, though.

OK, will add it to my queue.

Thanks!