0001
0002 #ifndef _ASM_POWERPC_TOPOLOGY_H
0003 #define _ASM_POWERPC_TOPOLOGY_H
0004 #ifdef __KERNEL__
0005
0006
0007 struct device;
0008 struct device_node;
0009 struct drmem_lmb;
0010
0011 #ifdef CONFIG_NUMA
0012
0013
0014
0015
0016
0017 #define RECLAIM_DISTANCE 10
0018
0019 #include <asm/mmzone.h>
0020
0021 #define cpumask_of_node(node) ((node) == -1 ? \
0022 cpu_all_mask : \
0023 node_to_cpumask_map[node])
0024
0025 struct pci_bus;
0026 #ifdef CONFIG_PCI
0027 extern int pcibus_to_node(struct pci_bus *bus);
0028 #else
0029 static inline int pcibus_to_node(struct pci_bus *bus)
0030 {
0031 return -1;
0032 }
0033 #endif
0034
0035 #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
0036 cpu_all_mask : \
0037 cpumask_of_node(pcibus_to_node(bus)))
0038
0039 int cpu_relative_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc);
0040 extern int __node_distance(int, int);
0041 #define node_distance(a, b) __node_distance(a, b)
0042
0043 extern void __init dump_numa_cpu_topology(void);
0044
0045 extern int sysfs_add_device_to_node(struct device *dev, int nid);
0046 extern void sysfs_remove_device_from_node(struct device *dev, int nid);
0047
0048 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node)
0049 {
0050 numa_cpu_lookup_table[cpu] = node;
0051 }
0052
0053 static inline int early_cpu_to_node(int cpu)
0054 {
0055 int nid;
0056
0057 nid = numa_cpu_lookup_table[cpu];
0058
0059
0060
0061
0062
0063 return (nid < 0) ? 0 : nid;
0064 }
0065
0066 int of_drconf_to_nid_single(struct drmem_lmb *lmb);
0067 void update_numa_distance(struct device_node *node);
0068
0069 extern void map_cpu_to_node(int cpu, int node);
0070 #ifdef CONFIG_HOTPLUG_CPU
0071 extern void unmap_cpu_from_node(unsigned long cpu);
0072 #endif
0073
0074 #else
0075
0076 static inline int early_cpu_to_node(int cpu) { return 0; }
0077
0078 static inline void dump_numa_cpu_topology(void) {}
0079
0080 static inline int sysfs_add_device_to_node(struct device *dev, int nid)
0081 {
0082 return 0;
0083 }
0084
0085 static inline void sysfs_remove_device_from_node(struct device *dev,
0086 int nid)
0087 {
0088 }
0089
0090 static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
0091
0092 static inline int cpu_relative_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
0093 {
0094 return 0;
0095 }
0096
0097 static inline int of_drconf_to_nid_single(struct drmem_lmb *lmb)
0098 {
0099 return first_online_node;
0100 }
0101
0102 static inline void update_numa_distance(struct device_node *node) {}
0103
0104 #ifdef CONFIG_SMP
0105 static inline void map_cpu_to_node(int cpu, int node) {}
0106 #ifdef CONFIG_HOTPLUG_CPU
0107 static inline void unmap_cpu_from_node(unsigned long cpu) {}
0108 #endif
0109 #endif
0110
0111 #endif
0112
0113 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
0114 void find_and_update_cpu_nid(int cpu);
0115 extern int cpu_to_coregroup_id(int cpu);
0116 #else
0117 static inline void find_and_update_cpu_nid(int cpu) {}
0118 static inline int cpu_to_coregroup_id(int cpu)
0119 {
0120 #ifdef CONFIG_SMP
0121 return cpu_to_core_id(cpu);
0122 #else
0123 return 0;
0124 #endif
0125 }
0126
0127 #endif
0128
0129 #include <asm-generic/topology.h>
0130
0131 #ifdef CONFIG_SMP
0132 #include <asm/cputable.h>
0133
0134 #ifdef CONFIG_PPC64
0135 #include <asm/smp.h>
0136
0137 #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
0138
0139 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
0140 #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
0141 #define topology_core_id(cpu) (cpu_to_core_id(cpu))
0142
0143 #endif
0144 #endif
0145
0146 #endif
0147 #endif