xref: /openbmc/linux/arch/sh/mm/numa.c (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1b241cb0cSPaul Mundt /*
2b241cb0cSPaul Mundt  * arch/sh/mm/numa.c - Multiple node support for SH machines
3b241cb0cSPaul Mundt  *
4b241cb0cSPaul Mundt  *  Copyright (C) 2007  Paul Mundt
5b241cb0cSPaul Mundt  *
6b241cb0cSPaul Mundt  * This file is subject to the terms and conditions of the GNU General Public
7b241cb0cSPaul Mundt  * License.  See the file "COPYING" in the main directory of this archive
8b241cb0cSPaul Mundt  * for more details.
9b241cb0cSPaul Mundt  */
10b241cb0cSPaul Mundt #include <linux/module.h>
1195f72d1eSYinghai Lu #include <linux/memblock.h>
12b241cb0cSPaul Mundt #include <linux/mm.h>
13b241cb0cSPaul Mundt #include <linux/numa.h>
14b241cb0cSPaul Mundt #include <linux/pfn.h>
15b241cb0cSPaul Mundt #include <asm/sections.h>
16b241cb0cSPaul Mundt 
17b241cb0cSPaul Mundt struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
18b241cb0cSPaul Mundt EXPORT_SYMBOL_GPL(node_data);
19b241cb0cSPaul Mundt 
20b241cb0cSPaul Mundt /*
21b241cb0cSPaul Mundt  * On SH machines the conventional approach is to stash system RAM
22b241cb0cSPaul Mundt  * in node 0, and other memory blocks in to node 1 and up, ordered by
23b241cb0cSPaul Mundt  * latency. Each node's pgdat is node-local at the beginning of the node,
24b241cb0cSPaul Mundt  * immediately followed by the node mem map.
25b241cb0cSPaul Mundt  */
setup_bootmem_node(int nid,unsigned long start,unsigned long end)26b241cb0cSPaul Mundt void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
27b241cb0cSPaul Mundt {
285084f61aSMatt Fleming 	unsigned long start_pfn, end_pfn;
29b241cb0cSPaul Mundt 
30b241cb0cSPaul Mundt 	/* Don't allow bogus node assignment */
31ded00142SDan Carpenter 	BUG_ON(nid >= MAX_NUMNODES || nid <= 0);
32b241cb0cSPaul Mundt 
3381cf09edSAlexander Kuleshov 	start_pfn = PFN_DOWN(start);
3481cf09edSAlexander Kuleshov 	end_pfn = PFN_DOWN(end);
35b241cb0cSPaul Mundt 
3609e11723SPaul Mundt 	pmb_bolt_mapping((unsigned long)__va(start), start, end - start,
3709e11723SPaul Mundt 			 PAGE_KERNEL);
3809e11723SPaul Mundt 
3995f72d1eSYinghai Lu 	memblock_add(start, end - start);
405084f61aSMatt Fleming 
410146ba78SMagnus Damm 	__add_active_range(nid, start_pfn, end_pfn);
42b241cb0cSPaul Mundt 
43b241cb0cSPaul Mundt 	/* Node-local pgdat */
4447f1e926SMike Rapoport 	NODE_DATA(nid) = memblock_alloc_node(sizeof(struct pglist_data),
4547f1e926SMike Rapoport 					     SMP_CACHE_BYTES, nid);
46*8a7f97b9SMike Rapoport 	if (!NODE_DATA(nid))
47*8a7f97b9SMike Rapoport 		panic("%s: Failed to allocate %zu bytes align=0x%x nid=%d\n",
48*8a7f97b9SMike Rapoport 		      __func__, sizeof(struct pglist_data), SMP_CACHE_BYTES,
49*8a7f97b9SMike Rapoport 		      nid);
50b241cb0cSPaul Mundt 
51b241cb0cSPaul Mundt 	NODE_DATA(nid)->node_start_pfn = start_pfn;
52b241cb0cSPaul Mundt 	NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
53b241cb0cSPaul Mundt 
54b241cb0cSPaul Mundt 	/* It's up */
55b241cb0cSPaul Mundt 	node_set_online(nid);
56b241cb0cSPaul Mundt }
57