treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / powerpc / include / asm / topology.h
blob2f7e1ea5089e9830b0b963c71c2eb5ecde7bdaac
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 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);
46 extern int numa_update_cpu_topology(bool cpus_locked);
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;
65 #else
67 static inline int early_cpu_to_node(int cpu) { return 0; }
69 static inline void dump_numa_cpu_topology(void) {}
71 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
73 return 0;
76 static inline void sysfs_remove_device_from_node(struct device *dev,
77 int nid)
81 static inline int numa_update_cpu_topology(bool cpus_locked)
83 return 0;
86 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
88 static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
90 return 0;
93 #endif /* CONFIG_NUMA */
95 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
96 extern int start_topology_update(void);
97 extern int stop_topology_update(void);
98 extern int prrn_is_enabled(void);
99 extern int find_and_online_cpu_nid(int cpu);
100 extern int timed_topology_update(int nsecs);
101 extern void __init shared_proc_topology_init(void);
102 #else
103 static inline int start_topology_update(void)
105 return 0;
107 static inline int stop_topology_update(void)
109 return 0;
111 static inline int prrn_is_enabled(void)
113 return 0;
115 static inline int find_and_online_cpu_nid(int cpu)
117 return 0;
119 static inline int timed_topology_update(int nsecs)
121 return 0;
124 #ifdef CONFIG_SMP
125 static inline void shared_proc_topology_init(void) {}
126 #endif
127 #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
129 #include <asm-generic/topology.h>
131 #ifdef CONFIG_SMP
132 #include <asm/cputable.h>
134 #ifdef CONFIG_PPC64
135 #include <asm/smp.h>
137 #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
138 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
139 #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
140 #define topology_core_id(cpu) (cpu_to_core_id(cpu))
142 int dlpar_cpu_readd(int cpu);
143 #endif
144 #endif
146 #endif /* __KERNEL__ */
147 #endif /* _ASM_POWERPC_TOPOLOGY_H */