aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2018-05-11 09:45:59 -0400
committerRich Felker <dalias@libc.org>2018-05-11 13:35:46 -0400
commitac21fc2dcb405cf250ad3f1228f64f64930d9211 (patch)
tree86b533b87054557d15fa45d89df957f1389d053e
parentb9826a4929bbd4dcb245429fd7434145c4fcdc9b (diff)
sh: switch to NO_BOOTMEM
Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc") inadvertently switched the DT unflattening allocations from memblock to bootmem which doesn't work because the unflattening happens before bootmem is initialized. Swapping the order of bootmem init and unflattening could also fix this, but removing bootmem is desired. So enable NO_BOOTMEM on SH like other architectures have done. Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc") Reported-by: Rich Felker <dalias@libc.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Rich Felker <dalias@libc.org>
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/kernel/setup.c1
-rw-r--r--arch/sh/mm/init.c68
-rw-r--r--arch/sh/mm/numa.c19
4 files changed, 7 insertions, 82 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 97fe29316476..1851eaeee131 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -9,6 +9,7 @@ config SUPERH
9 select HAVE_IDE if HAS_IOPORT_MAP 9 select HAVE_IDE if HAS_IOPORT_MAP
10 select HAVE_MEMBLOCK 10 select HAVE_MEMBLOCK
11 select HAVE_MEMBLOCK_NODE_MAP 11 select HAVE_MEMBLOCK_NODE_MAP
12 select NO_BOOTMEM
12 select ARCH_DISCARD_MEMBLOCK 13 select ARCH_DISCARD_MEMBLOCK
13 select HAVE_OPROFILE 14 select HAVE_OPROFILE
14 select HAVE_GENERIC_DMA_COHERENT 15 select HAVE_GENERIC_DMA_COHERENT
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index d34e998b809f..c286cf5da6e7 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -11,7 +11,6 @@
11#include <linux/ioport.h> 11#include <linux/ioport.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/initrd.h> 13#include <linux/initrd.h>
14#include <linux/bootmem.h>
15#include <linux/console.h> 14#include <linux/console.h>
16#include <linux/root_dev.h> 15#include <linux/root_dev.h>
17#include <linux/utsname.h> 16#include <linux/utsname.h>
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index ce0bbaa7e404..4034035fbede 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -211,59 +211,15 @@ void __init allocate_pgdat(unsigned int nid)
211 211
212 NODE_DATA(nid) = __va(phys); 212 NODE_DATA(nid) = __va(phys);
213 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); 213 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
214
215 NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
216#endif 214#endif
217 215
218 NODE_DATA(nid)->node_start_pfn = start_pfn; 216 NODE_DATA(nid)->node_start_pfn = start_pfn;
219 NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; 217 NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
220} 218}
221 219
222static void __init bootmem_init_one_node(unsigned int nid)
223{
224 unsigned long total_pages, paddr;
225 unsigned long end_pfn;
226 struct pglist_data *p;
227
228 p = NODE_DATA(nid);
229
230 /* Nothing to do.. */
231 if (!p->node_spanned_pages)
232 return;
233
234 end_pfn = pgdat_end_pfn(p);
235
236 total_pages = bootmem_bootmap_pages(p->node_spanned_pages);
237
238 paddr = memblock_alloc(total_pages << PAGE_SHIFT, PAGE_SIZE);
239 if (!paddr)
240 panic("Can't allocate bootmap for nid[%d]\n", nid);
241
242 init_bootmem_node(p, paddr >> PAGE_SHIFT, p->node_start_pfn, end_pfn);
243
244 free_bootmem_with_active_regions(nid, end_pfn);
245
246 /*
247 * XXX Handle initial reservations for the system memory node
248 * only for the moment, we'll refactor this later for handling
249 * reservations in other nodes.
250 */
251 if (nid == 0) {
252 struct memblock_region *reg;
253
254 /* Reserve the sections we're already using. */
255 for_each_memblock(reserved, reg) {
256 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
257 }
258 }
259
260 sparse_memory_present_with_active_regions(nid);
261}
262
263static void __init do_init_bootmem(void) 220static void __init do_init_bootmem(void)
264{ 221{
265 struct memblock_region *reg; 222 struct memblock_region *reg;
266 int i;
267 223
268 /* Add active regions with valid PFNs. */ 224 /* Add active regions with valid PFNs. */
269 for_each_memblock(memory, reg) { 225 for_each_memblock(memory, reg) {
@@ -279,9 +235,12 @@ static void __init do_init_bootmem(void)
279 235
280 plat_mem_setup(); 236 plat_mem_setup();
281 237
282 for_each_online_node(i) 238 for_each_memblock(memory, reg) {
283 bootmem_init_one_node(i); 239 int nid = memblock_get_region_node(reg);
284 240
241 memory_present(nid, memblock_region_memory_base_pfn(reg),
242 memblock_region_memory_end_pfn(reg));
243 }
285 sparse_init(); 244 sparse_init();
286} 245}
287 246
@@ -322,7 +281,6 @@ void __init paging_init(void)
322{ 281{
323 unsigned long max_zone_pfns[MAX_NR_ZONES]; 282 unsigned long max_zone_pfns[MAX_NR_ZONES];
324 unsigned long vaddr, end; 283 unsigned long vaddr, end;
325 int nid;
326 284
327 sh_mv.mv_mem_init(); 285 sh_mv.mv_mem_init();
328 286
@@ -377,21 +335,7 @@ void __init paging_init(void)
377 kmap_coherent_init(); 335 kmap_coherent_init();
378 336
379 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 337 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
380 338 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
381 for_each_online_node(nid) {
382 pg_data_t *pgdat = NODE_DATA(nid);
383 unsigned long low, start_pfn;
384
385 start_pfn = pgdat->bdata->node_min_pfn;
386 low = pgdat->bdata->node_low_pfn;
387
388 if (max_zone_pfns[ZONE_NORMAL] < low)
389 max_zone_pfns[ZONE_NORMAL] = low;
390
391 printk("Node %u: start_pfn = 0x%lx, low = 0x%lx\n",
392 nid, start_pfn, low);
393 }
394
395 free_area_init_nodes(max_zone_pfns); 339 free_area_init_nodes(max_zone_pfns);
396} 340}
397 341
diff --git a/arch/sh/mm/numa.c b/arch/sh/mm/numa.c
index 05713d190247..830e8b3684e4 100644
--- a/arch/sh/mm/numa.c
+++ b/arch/sh/mm/numa.c
@@ -8,7 +8,6 @@
8 * for more details. 8 * for more details.
9 */ 9 */
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/bootmem.h>
12#include <linux/memblock.h> 11#include <linux/memblock.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
14#include <linux/numa.h> 13#include <linux/numa.h>
@@ -26,9 +25,7 @@ EXPORT_SYMBOL_GPL(node_data);
26 */ 25 */
27void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end) 26void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
28{ 27{
29 unsigned long bootmap_pages;
30 unsigned long start_pfn, end_pfn; 28 unsigned long start_pfn, end_pfn;
31 unsigned long bootmem_paddr;
32 29
33 /* Don't allow bogus node assignment */ 30 /* Don't allow bogus node assignment */
34 BUG_ON(nid >= MAX_NUMNODES || nid <= 0); 31 BUG_ON(nid >= MAX_NUMNODES || nid <= 0);
@@ -48,25 +45,9 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
48 SMP_CACHE_BYTES, end)); 45 SMP_CACHE_BYTES, end));
49 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); 46 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
50 47
51 NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
52 NODE_DATA(nid)->node_start_pfn = start_pfn; 48 NODE_DATA(nid)->node_start_pfn = start_pfn;
53 NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; 49 NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
54 50
55 /* Node-local bootmap */
56 bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
57 bootmem_paddr = memblock_alloc_base(bootmap_pages << PAGE_SHIFT,
58 PAGE_SIZE, end);
59 init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
60 start_pfn, end_pfn);
61
62 free_bootmem_with_active_regions(nid, end_pfn);
63
64 /* Reserve the pgdat and bootmap space with the bootmem allocator */
65 reserve_bootmem_node(NODE_DATA(nid), start_pfn << PAGE_SHIFT,
66 sizeof(struct pglist_data), BOOTMEM_DEFAULT);
67 reserve_bootmem_node(NODE_DATA(nid), bootmem_paddr,
68 bootmap_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
69
70 /* It's up */ 51 /* It's up */
71 node_set_online(nid); 52 node_set_online(nid);
72 53