Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / powerpc / include / asm / topology.h
blob9f421641a35c8240cbacf192f6a1b22b4f33c63c
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;
10 #ifdef CONFIG_NUMA
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 ? \
21 cpu_all_mask : \
22 node_to_cpumask_map[node])
24 struct pci_bus;
25 #ifdef CONFIG_PCI
26 extern int pcibus_to_node(struct pci_bus *bus);
27 #else
28 static inline int pcibus_to_node(struct pci_bus *bus)
30 return -1;
32 #endif
34 #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
35 cpu_all_mask : \
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 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)
54 int nid;
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;
64 #else
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)
72 return 0;
75 static inline void sysfs_remove_device_from_node(struct device *dev,
76 int nid)
80 static inline int numa_update_cpu_topology(bool cpus_locked)
82 return 0;
85 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
87 #endif /* CONFIG_NUMA */
89 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
90 extern int start_topology_update(void);
91 extern int stop_topology_update(void);
92 extern int prrn_is_enabled(void);
93 extern int find_and_online_cpu_nid(int cpu);
94 #else
95 static inline int start_topology_update(void)
97 return 0;
99 static inline int stop_topology_update(void)
101 return 0;
103 static inline int prrn_is_enabled(void)
105 return 0;
107 static inline int find_and_online_cpu_nid(int cpu)
109 return 0;
111 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
113 #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_NEED_MULTIPLE_NODES)
114 #if defined(CONFIG_PPC_SPLPAR)
115 extern int timed_topology_update(int nsecs);
116 #else
117 #define timed_topology_update(nsecs)
118 #endif /* CONFIG_PPC_SPLPAR */
119 #endif /* CONFIG_HOTPLUG_CPU || CONFIG_NEED_MULTIPLE_NODES */
121 #include <asm-generic/topology.h>
123 #ifdef CONFIG_SMP
124 #include <asm/cputable.h>
126 #ifdef CONFIG_PPC64
127 #include <asm/smp.h>
129 #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
130 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
131 #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
132 #define topology_core_id(cpu) (cpu_to_core_id(cpu))
133 #endif
134 #endif
136 #endif /* __KERNEL__ */
137 #endif /* _ASM_POWERPC_TOPOLOGY_H */