]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
dd56fdf2 | 2 | #ifndef _ASM_POWERPC_TOPOLOGY_H |
3 | #define _ASM_POWERPC_TOPOLOGY_H | |
88ced031 | 4 | #ifdef __KERNEL__ |
1da177e4 | 5 | |
1da177e4 | 6 | |
8a25a2fd | 7 | struct device; |
953039c8 JK |
8 | struct device_node; |
9 | ||
1da177e4 LT |
10 | #ifdef CONFIG_NUMA |
11 | ||
56608209 | 12 | /* |
4f9b16a6 MG |
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(). | |
56608209 AB |
15 | */ |
16 | #define RECLAIM_DISTANCE 10 | |
17 | ||
dd56fdf2 | 18 | #include <asm/mmzone.h> |
19 | ||
c81b812a AB |
20 | #define cpumask_of_node(node) ((node) == -1 ? \ |
21 | cpu_all_mask : \ | |
25863de0 | 22 | node_to_cpumask_map[node]) |
86c6f274 | 23 | |
357518fa | 24 | struct pci_bus; |
11faa658 | 25 | #ifdef CONFIG_PCI |
357518fa | 26 | extern int pcibus_to_node(struct pci_bus *bus); |
11faa658 AB |
27 | #else |
28 | static inline int pcibus_to_node(struct pci_bus *bus) | |
29 | { | |
30 | return -1; | |
31 | } | |
32 | #endif | |
357518fa | 33 | |
86c6f274 RR |
34 | #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ |
35 | cpu_all_mask : \ | |
36 | cpumask_of_node(pcibus_to_node(bus))) | |
37 | ||
41eab6f8 AB |
38 | extern int __node_distance(int, int); |
39 | #define node_distance(a, b) __node_distance(a, b) | |
40 | ||
4b703a23 AB |
41 | extern void __init dump_numa_cpu_topology(void); |
42 | ||
8a25a2fd KS |
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); | |
3e401f7a | 45 | extern int numa_update_cpu_topology(bool cpus_locked); |
953039c8 | 46 | |
bb2f2cf3 NF |
47 | static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) |
48 | { | |
49 | numa_cpu_lookup_table[cpu] = node; | |
50 | } | |
51 | ||
ba4a648f ME |
52 | static inline int early_cpu_to_node(int cpu) |
53 | { | |
54 | int nid; | |
55 | ||
56 | nid = numa_cpu_lookup_table[cpu]; | |
57 | ||
58 | /* | |
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)). | |
61 | */ | |
62 | return (nid < 0) ? 0 : nid; | |
63 | } | |
39bf990e | 64 | #else |
1da177e4 | 65 | |
ba4a648f ME |
66 | static inline int early_cpu_to_node(int cpu) { return 0; } |
67 | ||
4b703a23 AB |
68 | static inline void dump_numa_cpu_topology(void) {} |
69 | ||
8a25a2fd | 70 | static inline int sysfs_add_device_to_node(struct device *dev, int nid) |
953039c8 JK |
71 | { |
72 | return 0; | |
73 | } | |
74 | ||
8a25a2fd | 75 | static inline void sysfs_remove_device_from_node(struct device *dev, |
953039c8 JK |
76 | int nid) |
77 | { | |
78 | } | |
3e401f7a TJB |
79 | |
80 | static inline int numa_update_cpu_topology(bool cpus_locked) | |
81 | { | |
82 | return 0; | |
83 | } | |
23e72e03 CL |
84 | |
85 | static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {} | |
86 | ||
aa6b5446 | 87 | #endif /* CONFIG_NUMA */ |
953039c8 | 88 | |
5d7d8072 BH |
89 | #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR) |
90 | extern int start_topology_update(void); | |
91 | extern int stop_topology_update(void); | |
e04fa612 | 92 | extern int prrn_is_enabled(void); |
22ddbf70 | 93 | extern int timed_topology_update(int nsecs); |
5d7d8072 BH |
94 | #else |
95 | static inline int start_topology_update(void) | |
96 | { | |
97 | return 0; | |
98 | } | |
99 | static inline int stop_topology_update(void) | |
100 | { | |
101 | return 0; | |
102 | } | |
e04fa612 NF |
103 | static inline int prrn_is_enabled(void) |
104 | { | |
105 | return 0; | |
106 | } | |
22ddbf70 ME |
107 | static inline int timed_topology_update(int nsecs) |
108 | { | |
109 | return 0; | |
110 | } | |
5d7d8072 BH |
111 | #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */ |
112 | ||
1da177e4 LT |
113 | #include <asm-generic/topology.h> |
114 | ||
5c45bf27 SS |
115 | #ifdef CONFIG_SMP |
116 | #include <asm/cputable.h> | |
056f4faa SR |
117 | |
118 | #ifdef CONFIG_PPC64 | |
119 | #include <asm/smp.h> | |
120 | ||
15863ff3 | 121 | #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu)) |
06931e62 | 122 | #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu)) |
cc1ba8ea | 123 | #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu)) |
e9efed3b | 124 | #define topology_core_id(cpu) (cpu_to_core_id(cpu)) |
333429e6 NF |
125 | |
126 | int dlpar_cpu_readd(int cpu); | |
056f4faa | 127 | #endif |
5c45bf27 SS |
128 | #endif |
129 | ||
88ced031 | 130 | #endif /* __KERNEL__ */ |
dd56fdf2 | 131 | #endif /* _ASM_POWERPC_TOPOLOGY_H */ |