xref: /linux/arch/sh/mm/numa.c (revision 89713ce5518eda6b370c7a17edbcab4f97a39f68)
1 /*
2  * arch/sh/mm/numa.c - Multiple node support for SH machines
3  *
4  *  Copyright (C) 2007  Paul Mundt
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 #include <linux/module.h>
11 #include <linux/memblock.h>
12 #include <linux/mm.h>
13 #include <linux/numa.h>
14 #include <linux/pfn.h>
15 #include <asm/sections.h>
16 
17 /*
18  * On SH machines the conventional approach is to stash system RAM
19  * in node 0, and other memory blocks in to node 1 and up, ordered by
20  * latency. Each node's pgdat is node-local at the beginning of the node,
21  * immediately followed by the node mem map.
22  */
23 void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
24 {
25 	unsigned long start_pfn, end_pfn;
26 
27 	/* Don't allow bogus node assignment */
28 	BUG_ON(nid >= MAX_NUMNODES || nid <= 0);
29 
30 	start_pfn = PFN_DOWN(start);
31 	end_pfn = PFN_DOWN(end);
32 
33 	pmb_bolt_mapping((unsigned long)__va(start), start, end - start,
34 			 PAGE_KERNEL);
35 
36 	memblock_add(start, end - start);
37 
38 	__add_active_range(nid, start_pfn, end_pfn);
39 
40 	/* Node-local pgdat */
41 	NODE_DATA(nid) = memblock_alloc_node(sizeof(struct pglist_data),
42 					     SMP_CACHE_BYTES, nid);
43 	if (!NODE_DATA(nid))
44 		panic("%s: Failed to allocate %zu bytes align=0x%x nid=%d\n",
45 		      __func__, sizeof(struct pglist_data), SMP_CACHE_BYTES,
46 		      nid);
47 
48 	NODE_DATA(nid)->node_start_pfn = start_pfn;
49 	NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
50 
51 	/* It's up */
52 	node_set_online(nid);
53 }
54