1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_TOPOLOGY_H
3 #define _ASM_POWERPC_TOPOLOGY_H
13 * If zone_reclaim_mode is enabled, a RECLAIM_DISTANCE of 10 will mean that
14 * all zones on all nodes will be eligible for zone_reclaim().
16 #define RECLAIM_DISTANCE 10
18 #include <asm/mmzone.h>
20 #define cpumask_of_node(node) ((node) == -1 ? \
22 node_to_cpumask_map[node])
26 extern int pcibus_to_node(struct pci_bus *bus);
28 static inline int pcibus_to_node(struct pci_bus *bus)
34 #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
36 cpumask_of_node(pcibus_to_node(bus)))
38 extern int __node_distance(int, int);
39 #define node_distance(a, b) __node_distance(a, b)
41 extern void __init dump_numa_cpu_topology(void);
43 extern int sysfs_add_device_to_node(struct device *dev, int nid);
44 extern void sysfs_remove_device_from_node(struct device *dev, int nid);
45 extern int numa_update_cpu_topology(bool cpus_locked);
47 static inline int early_cpu_to_node(int cpu)
51 nid = numa_cpu_lookup_table[cpu];
54 * Fall back to node 0 if nid is unset (it should be, except bugs).
55 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
57 return (nid < 0) ? 0 : nid;
61 static inline int early_cpu_to_node(int cpu) { return 0; }
63 static inline void dump_numa_cpu_topology(void) {}
65 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
70 static inline void sysfs_remove_device_from_node(struct device *dev,
75 static inline int numa_update_cpu_topology(bool cpus_locked)
79 #endif /* CONFIG_NUMA */
81 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
82 extern int start_topology_update(void);
83 extern int stop_topology_update(void);
84 extern int prrn_is_enabled(void);
86 static inline int start_topology_update(void)
90 static inline int stop_topology_update(void)
94 static inline int prrn_is_enabled(void)
98 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
100 #include <asm-generic/topology.h>
103 #include <asm/cputable.h>
108 #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
109 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
110 #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
111 #define topology_core_id(cpu) (cpu_to_core_id(cpu))
115 #endif /* __KERNEL__ */
116 #endif /* _ASM_POWERPC_TOPOLOGY_H */