Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[sfrench/cifs-2.6.git] / arch / powerpc / include / asm / topology.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_TOPOLOGY_H
3 #define _ASM_POWERPC_TOPOLOGY_H
4 #ifdef __KERNEL__
5
6
7 struct device;
8 struct device_node;
9
10 #ifdef CONFIG_NUMA
11
12 /*
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().
15  */
16 #define RECLAIM_DISTANCE 10
17
18 #include <asm/mmzone.h>
19
20 #define cpumask_of_node(node) ((node) == -1 ?                           \
21                                cpu_all_mask :                           \
22                                node_to_cpumask_map[node])
23
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)
29 {
30         return -1;
31 }
32 #endif
33
34 #define cpumask_of_pcibus(bus)  (pcibus_to_node(bus) == -1 ?            \
35                                  cpu_all_mask :                         \
36                                  cpumask_of_node(pcibus_to_node(bus)))
37
38 extern int __node_distance(int, int);
39 #define node_distance(a, b) __node_distance(a, b)
40
41 extern void __init dump_numa_cpu_topology(void);
42
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);
46
47 static inline int early_cpu_to_node(int cpu)
48 {
49         int nid;
50
51         nid = numa_cpu_lookup_table[cpu];
52
53         /*
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)).
56          */
57         return (nid < 0) ? 0 : nid;
58 }
59 #else
60
61 static inline int early_cpu_to_node(int cpu) { return 0; }
62
63 static inline void dump_numa_cpu_topology(void) {}
64
65 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
66 {
67         return 0;
68 }
69
70 static inline void sysfs_remove_device_from_node(struct device *dev,
71                                                 int nid)
72 {
73 }
74
75 static inline int numa_update_cpu_topology(bool cpus_locked)
76 {
77         return 0;
78 }
79 #endif /* CONFIG_NUMA */
80
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);
85 #else
86 static inline int start_topology_update(void)
87 {
88         return 0;
89 }
90 static inline int stop_topology_update(void)
91 {
92         return 0;
93 }
94 static inline int prrn_is_enabled(void)
95 {
96         return 0;
97 }
98 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
99
100 #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_NEED_MULTIPLE_NODES)
101 #if defined(CONFIG_PPC_SPLPAR)
102 extern int timed_topology_update(int nsecs);
103 #else
104 #define timed_topology_update(nsecs)
105 #endif /* CONFIG_PPC_SPLPAR */
106 #endif /* CONFIG_HOTPLUG_CPU || CONFIG_NEED_MULTIPLE_NODES */
107
108 #include <asm-generic/topology.h>
109
110 #ifdef CONFIG_SMP
111 #include <asm/cputable.h>
112
113 #ifdef CONFIG_PPC64
114 #include <asm/smp.h>
115
116 #define topology_physical_package_id(cpu)       (cpu_to_chip_id(cpu))
117 #define topology_sibling_cpumask(cpu)   (per_cpu(cpu_sibling_map, cpu))
118 #define topology_core_cpumask(cpu)      (per_cpu(cpu_core_map, cpu))
119 #define topology_core_id(cpu)           (cpu_to_core_id(cpu))
120 #endif
121 #endif
122
123 #endif /* __KERNEL__ */
124 #endif  /* _ASM_POWERPC_TOPOLOGY_H */