Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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