WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / include / asm / topology.h
blob3beeb030cd78e9bbcababbf4de178c588fbe0eee
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_TOPOLOGY_H
3 #define _ASM_POWERPC_TOPOLOGY_H
4 #ifdef __KERNEL__
7 struct device;
8 struct device_node;
9 struct drmem_lmb;
11 #ifdef CONFIG_NUMA
14 * If zone_reclaim_mode is enabled, a RECLAIM_DISTANCE of 10 will mean that
15 * all zones on all nodes will be eligible for zone_reclaim().
17 #define RECLAIM_DISTANCE 10
19 #include <asm/mmzone.h>
21 #define cpumask_of_node(node) ((node) == -1 ? \
22 cpu_all_mask : \
23 node_to_cpumask_map[node])
25 struct pci_bus;
26 #ifdef CONFIG_PCI
27 extern int pcibus_to_node(struct pci_bus *bus);
28 #else
29 static inline int pcibus_to_node(struct pci_bus *bus)
31 return -1;
33 #endif
35 #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
36 cpu_all_mask : \
37 cpumask_of_node(pcibus_to_node(bus)))
39 extern int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc);
40 extern int __node_distance(int, int);
41 #define node_distance(a, b) __node_distance(a, b)
43 extern void __init dump_numa_cpu_topology(void);
45 extern int sysfs_add_device_to_node(struct device *dev, int nid);
46 extern void sysfs_remove_device_from_node(struct device *dev, int nid);
48 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node)
50 numa_cpu_lookup_table[cpu] = node;
53 static inline int early_cpu_to_node(int cpu)
55 int nid;
57 nid = numa_cpu_lookup_table[cpu];
60 * Fall back to node 0 if nid is unset (it should be, except bugs).
61 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
63 return (nid < 0) ? 0 : nid;
66 int of_drconf_to_nid_single(struct drmem_lmb *lmb);
68 #else
70 static inline int early_cpu_to_node(int cpu) { return 0; }
72 static inline void dump_numa_cpu_topology(void) {}
74 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
76 return 0;
79 static inline void sysfs_remove_device_from_node(struct device *dev,
80 int nid)
84 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
86 static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
88 return 0;
91 static inline int of_drconf_to_nid_single(struct drmem_lmb *lmb)
93 return first_online_node;
96 #endif /* CONFIG_NUMA */
98 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
99 extern int find_and_online_cpu_nid(int cpu);
100 extern int cpu_to_coregroup_id(int cpu);
101 #else
102 static inline int find_and_online_cpu_nid(int cpu)
104 return 0;
107 static inline int cpu_to_coregroup_id(int cpu)
109 #ifdef CONFIG_SMP
110 return cpu_to_core_id(cpu);
111 #else
112 return 0;
113 #endif
116 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
118 #include <asm-generic/topology.h>
120 #ifdef CONFIG_SMP
121 #include <asm/cputable.h>
123 #ifdef CONFIG_PPC64
124 #include <asm/smp.h>
126 #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
128 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
129 #define topology_core_cpumask(cpu) (cpu_cpu_mask(cpu))
130 #define topology_core_id(cpu) (cpu_to_core_id(cpu))
132 #endif
133 #endif
135 #endif /* __KERNEL__ */
136 #endif /* _ASM_POWERPC_TOPOLOGY_H */