numa.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Author: Jianmin Lv <lvjianmin@loongson.cn>
  4. * Huacai Chen <chenhuacai@loongson.cn>
  5. *
  6. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  7. */
  8. #ifndef _ASM_LOONGARCH_NUMA_H
  9. #define _ASM_LOONGARCH_NUMA_H
  10. #include <linux/nodemask.h>
  11. #define NODE_ADDRSPACE_SHIFT 44
  12. #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT)
  13. #define nid_to_addrbase(nid) (_ULCAST_(nid) << NODE_ADDRSPACE_SHIFT)
  14. #ifdef CONFIG_NUMA
  15. extern int numa_off;
  16. extern s16 __cpuid_to_node[CONFIG_NR_CPUS];
  17. extern nodemask_t numa_nodes_parsed __initdata;
  18. extern void __init early_numa_add_cpu(int cpuid, s16 node);
  19. extern void numa_add_cpu(unsigned int cpu);
  20. extern void numa_remove_cpu(unsigned int cpu);
  21. static inline void numa_clear_node(int cpu)
  22. {
  23. }
  24. static inline void set_cpuid_to_node(int cpuid, s16 node)
  25. {
  26. __cpuid_to_node[cpuid] = node;
  27. }
  28. extern int early_cpu_to_node(int cpu);
  29. #else
  30. static inline void early_numa_add_cpu(int cpuid, s16 node) { }
  31. static inline void numa_add_cpu(unsigned int cpu) { }
  32. static inline void numa_remove_cpu(unsigned int cpu) { }
  33. static inline void set_cpuid_to_node(int cpuid, s16 node) { }
  34. static inline int early_cpu_to_node(int cpu)
  35. {
  36. return 0;
  37. }
  38. #endif /* CONFIG_NUMA */
  39. #endif /* _ASM_LOONGARCH_NUMA_H */