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 cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc);
39 extern int __node_distance(int, int);
40 #define node_distance(a, b) __node_distance(a, b)
42 extern void __init dump_numa_cpu_topology(void);
44 extern int sysfs_add_device_to_node(struct device *dev, int nid);
45 extern void sysfs_remove_device_from_node(struct device *dev, int nid);
47 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node)
49 numa_cpu_lookup_table[cpu] = node;
52 static inline int early_cpu_to_node(int cpu)
56 nid = numa_cpu_lookup_table[cpu];
59 * Fall back to node 0 if nid is unset (it should be, except bugs).
60 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
62 return (nid < 0) ? 0 : nid;
66 static inline int early_cpu_to_node(int cpu) { return 0; }
68 static inline void dump_numa_cpu_topology(void) {}
70 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
75 static inline void sysfs_remove_device_from_node(struct device *dev,
80 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
82 static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
87 #endif /* CONFIG_NUMA */
90 int of_drconf_to_nid_single(struct drmem_lmb *lmb);
92 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
93 extern int find_and_online_cpu_nid(int cpu);
94 extern int cpu_to_coregroup_id(int cpu);
96 static inline int find_and_online_cpu_nid(int cpu)
101 static inline int cpu_to_coregroup_id(int cpu)
104 return cpu_to_core_id(cpu);
110 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
112 #include <asm-generic/topology.h>
115 #include <asm/cputable.h>
120 #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
122 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
123 #define topology_core_cpumask(cpu) (cpu_cpu_mask(cpu))
124 #define topology_core_id(cpu) (cpu_to_core_id(cpu))
129 #endif /* __KERNEL__ */
130 #endif /* _ASM_POWERPC_TOPOLOGY_H */