]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - arch/powerpc/include/asm/topology.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-kernels.git] / arch / powerpc / include / asm / topology.h
CommitLineData
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 7struct device;
953039c8
JK
8struct 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 24struct pci_bus;
11faa658 25#ifdef CONFIG_PCI
357518fa 26extern int pcibus_to_node(struct pci_bus *bus);
11faa658
AB
27#else
28static 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
38extern int __node_distance(int, int);
39#define node_distance(a, b) __node_distance(a, b)
40
4b703a23
AB
41extern void __init dump_numa_cpu_topology(void);
42
8a25a2fd
KS
43extern int sysfs_add_device_to_node(struct device *dev, int nid);
44extern void sysfs_remove_device_from_node(struct device *dev, int nid);
3e401f7a 45extern int numa_update_cpu_topology(bool cpus_locked);
953039c8 46
ba4a648f
ME
47static 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}
39bf990e 59#else
1da177e4 60
ba4a648f
ME
61static inline int early_cpu_to_node(int cpu) { return 0; }
62
4b703a23
AB
63static inline void dump_numa_cpu_topology(void) {}
64
8a25a2fd 65static inline int sysfs_add_device_to_node(struct device *dev, int nid)
953039c8
JK
66{
67 return 0;
68}
69
8a25a2fd 70static inline void sysfs_remove_device_from_node(struct device *dev,
953039c8
JK
71 int nid)
72{
73}
3e401f7a
TJB
74
75static inline int numa_update_cpu_topology(bool cpus_locked)
76{
77 return 0;
78}
aa6b5446 79#endif /* CONFIG_NUMA */
953039c8 80
5d7d8072
BH
81#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
82extern int start_topology_update(void);
83extern int stop_topology_update(void);
e04fa612 84extern int prrn_is_enabled(void);
5d7d8072
BH
85#else
86static inline int start_topology_update(void)
87{
88 return 0;
89}
90static inline int stop_topology_update(void)
91{
92 return 0;
93}
e04fa612
NF
94static inline int prrn_is_enabled(void)
95{
96 return 0;
97}
5d7d8072
BH
98#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
99
1da177e4
LT
100#include <asm-generic/topology.h>
101
5c45bf27
SS
102#ifdef CONFIG_SMP
103#include <asm/cputable.h>
056f4faa
SR
104
105#ifdef CONFIG_PPC64
106#include <asm/smp.h>
107
15863ff3 108#define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
06931e62 109#define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
cc1ba8ea 110#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
e9efed3b 111#define topology_core_id(cpu) (cpu_to_core_id(cpu))
056f4faa 112#endif
5c45bf27
SS
113#endif
114
88ced031 115#endif /* __KERNEL__ */
dd56fdf2 116#endif /* _ASM_POWERPC_TOPOLOGY_H */