18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2020 Loongson Technology Corporation Limited 48c2ecf20Sopenharmony_ci * Author: lvjianmin <lvjianmin@loongson.cn> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 78c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License version 2 as 88c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _ASM_LOONGARCH_NUMA_H 128c2ecf20Sopenharmony_ci#define _ASM_LOONGARCH_NUMA_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/nodemask.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define NODE_ADDRSPACE_SHIFT 44 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT) 198c2ecf20Sopenharmony_ci#define nid_to_addrbase(nid) (_ULCAST_(nid) << NODE_ADDRSPACE_SHIFT) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#ifdef CONFIG_NUMA 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciextern int numa_off; 248c2ecf20Sopenharmony_ciextern s16 __cpuid_to_node[CONFIG_NR_CPUS]; 258c2ecf20Sopenharmony_ciextern nodemask_t numa_nodes_parsed __initdata; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct numa_memblk { 288c2ecf20Sopenharmony_ci u64 start; 298c2ecf20Sopenharmony_ci u64 end; 308c2ecf20Sopenharmony_ci int nid; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) 348c2ecf20Sopenharmony_cistruct numa_meminfo { 358c2ecf20Sopenharmony_ci int nr_blks; 368c2ecf20Sopenharmony_ci struct numa_memblk blk[NR_NODE_MEMBLKS]; 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciextern int __init numa_add_memblk(int nodeid, u64 start, u64 end); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciextern void __init early_numa_add_cpu(int cpuid, s16 node); 428c2ecf20Sopenharmony_ciextern void numa_add_cpu(unsigned int cpu); 438c2ecf20Sopenharmony_ciextern void numa_remove_cpu(unsigned int cpu); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic inline void numa_clear_node(int cpu) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic inline void set_cpuid_to_node(int cpuid, s16 node) 508c2ecf20Sopenharmony_ci{ 518c2ecf20Sopenharmony_ci __cpuid_to_node[cpuid] = node; 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ciextern int early_cpu_to_node(int cpu); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#else 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic inline void early_numa_add_cpu(int cpuid, s16 node) { } 598c2ecf20Sopenharmony_cistatic inline void numa_add_cpu(unsigned int cpu) { } 608c2ecf20Sopenharmony_cistatic inline void numa_remove_cpu(unsigned int cpu) { } 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistatic inline int early_cpu_to_node(int cpu) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci return 0; 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#endif /* CONFIG_NUMA */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#endif /* _ASM_LOONGARCH_NUMA_H */ 70