Skip to contentSkip to conversation

sparc32: switch to NO_BOOTMEM

PATCH Superseded Mike Rapoport 3 participants 7 messages Aug 6, 2018 – Aug 21, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover sparc32: switch to NO_BOOTMEM

Hi,

These patches convert sparc32 to use memblock + nobootmem.
I've made the conversion as simple as possible, just enough to allow moving HAVE_MEMBLOCK and NO_BOOTMEM to the common SPARC configuration.

v2 changes:
* split whitespace changes to a separate patch
* address Sam's comments [1]

[1] https://lkml.org/lkml/2018/8/2/403

Mike Rapoport (3):
sparc: mm/init_32: kill trailing whitespace
sparc32: switch to NO_BOOTMEM
sparc32: split ramdisk detection and reservation to a helper function

 arch/sparc/Kconfig      |   4 +-
 arch/sparc/mm/init_32.c | 127 ++++++++++++++++++------------------------------
 2 files changed, 50 insertions(+), 81 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/3 sparc: mm/init_32: kill trailing whitespace

---
 arch/sparc/mm/init_32.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/sparc/mm/init_32.c +3 -3
index 95fe4f0..3ec10b2 100644
@@ -133,7 +133,7 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
 	}
 
 	/* Start with page aligned address of last symbol in kernel
-	 * image.  
+	 * image.
 	 */
 	start_pfn  = (unsigned long)__pa(PAGE_ALIGN((unsigned long) &_end));
 
@@ -214,7 +214,7 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
 		*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
 
 		initrd_start = (initrd_start - phys_base) + PAGE_OFFSET;
-		initrd_end = (initrd_end - phys_base) + PAGE_OFFSET;		
+		initrd_end = (initrd_end - phys_base) + PAGE_OFFSET;
 	}
 #endif
 	/* Reserve the kernel text/data/bss. */
@@ -322,7 +322,7 @@ void __init mem_init(void)
 
 		map_high_region(start_pfn, end_pfn);
 	}
-	
+
 	mem_init_print_info(NULL);
 }
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/3 sparc32: switch to NO_BOOTMEM

In reply to Mike Rapoport

Each populated sparc_phys_bank is added to memblock.memory. The reserve_bootmem() calls are replaced with memblock_reserve(), and the bootmem bitmap initialization is droppped.

---
 arch/sparc/Kconfig      |  4 +--
 arch/sparc/mm/init_32.c | 75 +++++++++++++------------------------------------
 2 files changed, 21 insertions(+), 58 deletions(-)
arch/sparc/Kconfig +2 -2
index 0f535de..0a874c8 100644
@@ -45,6 +45,8 @@ config SPARC
 	select LOCKDEP_SMALL if LOCKDEP
 	select NEED_DMA_MAP_STATE
 	select NEED_SG_DMA_LENGTH
+	select HAVE_MEMBLOCK
+	select NO_BOOTMEM
 
 config SPARC32
 	def_bool !64BIT
@@ -60,7 +62,6 @@ config SPARC64
 	select HAVE_KRETPROBES
 	select HAVE_KPROBES
 	select HAVE_RCU_TABLE_FREE if SMP
-	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
 	select HAVE_DYNAMIC_FTRACE
@@ -79,7 +80,6 @@ config SPARC64
 	select IRQ_PREFLOW_FASTEOI
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select HAVE_C_RECORDMCOUNT
-	select NO_BOOTMEM
 	select HAVE_ARCH_AUDITSYSCALL
 	select ARCH_SUPPORTS_ATOMIC_RMW
 	select HAVE_NMI
arch/sparc/mm/init_32.c +19 -56

135 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 3/3 sparc32: split ramdisk detection and reservation to a helper function

In reply to Mike Rapoport

The detection and reservation of ramdisk memory were separated to allow bootmem bitmap initialization after the ramdisk boundaries are detected. Since the bootmem initialization is removed, the reservation of ramdisk memory is done immediately after its boundaries are found.

Split the entire block into a separate helper function.

---
 arch/sparc/mm/init_32.c | 56 +++++++++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 25 deletions(-)
arch/sparc/mm/init_32.c +31 -25
index e786fe0..92634d4 100644
@@ -102,6 +102,36 @@ static unsigned long calc_max_low_pfn(void)
 	return tmp;
 }
 
+static void __init find_ramdisk(unsigned long end_of_phys_memory)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+	unsigned long size;
+
+	/* Now have to check initial ramdisk, so that it won't pass
+	 * the end of memory
+	 */
+	if (sparc_ramdisk_image) {
+		if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE)
+			sparc_ramdisk_image -= KERNBASE;
+		initrd_start = sparc_ramdisk_image + phys_base;
+		initrd_end = initrd_start + sparc_ramdisk_size;
+		if (initrd_end > end_of_phys_memory) {
+			printk(KERN_CRIT "initrd extends beyond end of memory "
+			       "(0x%016lx > 0x%016lx)\ndisabling initrd\n",
+			       initrd_end, end_of_phys_memory);
+			initrd_start = 0;
+		} else {
+			/* Reserve the initrd image area. */
+			size = initrd_end - initrd_start;
+			memblock_reserve(initrd_start, size);
+
+			initrd_start = (initrd_start - phys_base) + PAGE_OFFSET;
+			initrd_end = (initrd_end - phys_base) + PAGE_OFFSET;
+		}
+	}
+#endif
+}
+
 unsigned long __init bootmem_init(unsigned long *pages_avail)
 {
 	unsigned long start_pfn, bytes_avail, size;
@@ -160,32 +190,8 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
 		    high_pages >> (20 - PAGE_SHIFT));
 	}
 
-#ifdef CONFIG_BLK_DEV_INITRD
-	/* Now have to check initial ramdisk, so that it won't pass
-	 * the end of memory
-	 */
-	if (sparc_ramdisk_image) {
-		if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE)
-			sparc_ramdisk_image -= KERNBASE;
-		initrd_start = sparc_ramdisk_image + phys_base;
-		initrd_end = initrd_start + sparc_ramdisk_size;
-		if (initrd_end > end_of_phys_memory) {
-			printk(KERN_CRIT "initrd extends beyond end of memory "
-		                 	 "(0x%016lx > 0x%016lx)\ndisabling initrd\n",
-			       initrd_end, end_of_phys_memory);
-			initrd_start = 0;
-		}
-	}
-
-	if (initrd_start) {
-		/* Reserve the initrd image area. */
-		size = initrd_end - initrd_start;
-		memblock_reserve(initrd_start, size);
+	find_ramdisk(end_of_phys_memory);
 
-		initrd_start = (initrd_start - phys_base) + PAGE_OFFSET;
-		initrd_end = (initrd_end - phys_base) + PAGE_OFFSET;
-	}
-#endif
 	/* Reserve the kernel text/data/bss. */
 	size = (start_pfn << PAGE_SHIFT) - phys_base;
 	memblock_reserve(phys_base, size);
Signature · 1 line
2.7.4
Reviewed-by on v2 3/3
#5 lore raw

Re: [PATCH v2 3/3] sparc32: split ramdisk detection and reservation to a helper function

In reply to Mike Rapoport
Quoted 9 lines · Mike Rapoport

The detection and reservation of ramdisk memory were separated to allow bootmem bitmap initialization after the ramdisk boundaries are detected. Since the bootmem initialization is removed, the reservation of ramdisk memory is done immediately after its boundaries are found.

Split the entire block into a separate helper function.

maintainer
#6 lore raw
In reply to Mike Rapoport

From: Mike Rapoport <[email protected]>
Date: Mon, 6 Aug 2018 13:52:32 +0300

Quoted 9 lines

These patches convert sparc32 to use memblock + nobootmem.
I've made the conversion as simple as possible, just enough to allow moving HAVE_MEMBLOCK and NO_BOOTMEM to the common SPARC configuration.

v2 changes:
* split whitespace changes to a separate patch
* address Sam's comments [1]

[1] https://lkml.org/lkml/2018/8/2/403

Series applied, thank you.