Skip to content

Commit cca079e

Browse files
rpptdavem330
authored andcommitted
sparc32: switch to NO_BOOTMEM
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. Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 60ef861 commit cca079e

2 files changed

Lines changed: 21 additions & 58 deletions

File tree

‎arch/sparc/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ config SPARC
4545
select LOCKDEP_SMALL if LOCKDEP
4646
select NEED_DMA_MAP_STATE
4747
select NEED_SG_DMA_LENGTH
48+
select HAVE_MEMBLOCK
49+
select NO_BOOTMEM
4850

4951
config SPARC32
5052
def_bool !64BIT
@@ -62,7 +64,6 @@ config SPARC64
6264
select HAVE_KRETPROBES
6365
select HAVE_KPROBES
6466
select HAVE_RCU_TABLE_FREE if SMP
65-
select HAVE_MEMBLOCK
6667
select HAVE_MEMBLOCK_NODE_MAP
6768
select HAVE_ARCH_TRANSPARENT_HUGEPAGE
6869
select HAVE_DYNAMIC_FTRACE
@@ -81,7 +82,6 @@ config SPARC64
8182
select IRQ_PREFLOW_FASTEOI
8283
select ARCH_HAVE_NMI_SAFE_CMPXCHG
8384
select HAVE_C_RECORDMCOUNT
84-
select NO_BOOTMEM
8585
select HAVE_ARCH_AUDITSYSCALL
8686
select ARCH_SUPPORTS_ATOMIC_RMW
8787
select HAVE_NMI

‎arch/sparc/mm/init_32.c‎

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/init.h>
2424
#include <linux/highmem.h>
2525
#include <linux/bootmem.h>
26+
#include <linux/memblock.h>
2627
#include <linux/pagemap.h>
2728
#include <linux/poison.h>
2829
#include <linux/gfp.h>
@@ -103,11 +104,14 @@ static unsigned long calc_max_low_pfn(void)
103104

104105
unsigned long __init bootmem_init(unsigned long *pages_avail)
105106
{
106-
unsigned long bootmap_size, start_pfn;
107-
unsigned long end_of_phys_memory = 0UL;
108-
unsigned long bootmap_pfn, bytes_avail, size;
107+
unsigned long start_pfn, bytes_avail, size;
108+
unsigned long end_of_phys_memory = 0;
109+
unsigned long high_pages = 0;
109110
int i;
110111

112+
memblock_set_bottom_up(true);
113+
memblock_allow_resize();
114+
111115
bytes_avail = 0UL;
112116
for (i = 0; sp_banks[i].num_bytes != 0; i++) {
113117
end_of_phys_memory = sp_banks[i].base_addr +
@@ -124,12 +128,15 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
124128
if (sp_banks[i].num_bytes == 0) {
125129
sp_banks[i].base_addr = 0xdeadbeef;
126130
} else {
131+
memblock_add(sp_banks[i].base_addr,
132+
sp_banks[i].num_bytes);
127133
sp_banks[i+1].num_bytes = 0;
128134
sp_banks[i+1].base_addr = 0xdeadbeef;
129135
}
130136
break;
131137
}
132138
}
139+
memblock_add(sp_banks[i].base_addr, sp_banks[i].num_bytes);
133140
}
134141

135142
/* Start with page aligned address of last symbol in kernel
@@ -140,8 +147,6 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
140147
/* Now shift down to get the real physical page frame number. */
141148
start_pfn >>= PAGE_SHIFT;
142149

143-
bootmap_pfn = start_pfn;
144-
145150
max_pfn = end_of_phys_memory >> PAGE_SHIFT;
146151

147152
max_low_pfn = max_pfn;
@@ -150,12 +155,15 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
150155
if (max_low_pfn > pfn_base + (SRMMU_MAXMEM >> PAGE_SHIFT)) {
151156
highstart_pfn = pfn_base + (SRMMU_MAXMEM >> PAGE_SHIFT);
152157
max_low_pfn = calc_max_low_pfn();
158+
high_pages = calc_highpages();
153159
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
154-
calc_highpages() >> (20 - PAGE_SHIFT));
160+
high_pages >> (20 - PAGE_SHIFT));
155161
}
156162

157163
#ifdef CONFIG_BLK_DEV_INITRD
158-
/* Now have to check initial ramdisk, so that bootmap does not overwrite it */
164+
/* Now have to check initial ramdisk, so that it won't pass
165+
* the end of memory
166+
*/
159167
if (sparc_ramdisk_image) {
160168
if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE)
161169
sparc_ramdisk_image -= KERNBASE;
@@ -167,68 +175,23 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
167175
initrd_end, end_of_phys_memory);
168176
initrd_start = 0;
169177
}
170-
if (initrd_start) {
171-
if (initrd_start >= (start_pfn << PAGE_SHIFT) &&
172-
initrd_start < (start_pfn << PAGE_SHIFT) + 2 * PAGE_SIZE)
173-
bootmap_pfn = PAGE_ALIGN (initrd_end) >> PAGE_SHIFT;
174-
}
175-
}
176-
#endif
177-
/* Initialize the boot-time allocator. */
178-
bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, pfn_base,
179-
max_low_pfn);
180-
181-
/* Now register the available physical memory with the
182-
* allocator.
183-
*/
184-
*pages_avail = 0;
185-
for (i = 0; sp_banks[i].num_bytes != 0; i++) {
186-
unsigned long curr_pfn, last_pfn;
187-
188-
curr_pfn = sp_banks[i].base_addr >> PAGE_SHIFT;
189-
if (curr_pfn >= max_low_pfn)
190-
break;
191-
192-
last_pfn = (sp_banks[i].base_addr + sp_banks[i].num_bytes) >> PAGE_SHIFT;
193-
if (last_pfn > max_low_pfn)
194-
last_pfn = max_low_pfn;
195-
196-
/*
197-
* .. finally, did all the rounding and playing
198-
* around just make the area go away?
199-
*/
200-
if (last_pfn <= curr_pfn)
201-
continue;
202-
203-
size = (last_pfn - curr_pfn) << PAGE_SHIFT;
204-
*pages_avail += last_pfn - curr_pfn;
205-
206-
free_bootmem(sp_banks[i].base_addr, size);
207178
}
208179

209-
#ifdef CONFIG_BLK_DEV_INITRD
210180
if (initrd_start) {
211181
/* Reserve the initrd image area. */
212182
size = initrd_end - initrd_start;
213-
reserve_bootmem(initrd_start, size, BOOTMEM_DEFAULT);
214-
*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
183+
memblock_reserve(initrd_start, size);
215184

216185
initrd_start = (initrd_start - phys_base) + PAGE_OFFSET;
217186
initrd_end = (initrd_end - phys_base) + PAGE_OFFSET;
218187
}
219188
#endif
220189
/* Reserve the kernel text/data/bss. */
221190
size = (start_pfn << PAGE_SHIFT) - phys_base;
222-
reserve_bootmem(phys_base, size, BOOTMEM_DEFAULT);
223-
*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
191+
memblock_reserve(phys_base, size);
224192

225-
/* Reserve the bootmem map. We do not account for it
226-
* in pages_avail because we will release that memory
227-
* in free_all_bootmem.
228-
*/
229-
size = bootmap_size;
230-
reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size, BOOTMEM_DEFAULT);
231-
*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
193+
size = memblock_phys_mem_size() - memblock_reserved_size();
194+
*pages_avail = (size >> PAGE_SHIFT) - high_pages;
232195

233196
return max_pfn;
234197
}

0 commit comments

Comments
 (0)