topology.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _ASM_POWERPC_TOPOLOGY_H
  2. #define _ASM_POWERPC_TOPOLOGY_H
  3. #ifdef __KERNEL__
  4. struct device;
  5. struct device_node;
  6. #ifdef CONFIG_NUMA
  7. /*
  8. * If zone_reclaim_mode is enabled, a RECLAIM_DISTANCE of 10 will mean that
  9. * all zones on all nodes will be eligible for zone_reclaim().
  10. */
  11. #define RECLAIM_DISTANCE 10
  12. #include <asm/mmzone.h>
  13. #define parent_node(node) (node)
  14. #define cpumask_of_node(node) ((node) == -1 ? \
  15. cpu_all_mask : \
  16. node_to_cpumask_map[node])
  17. struct pci_bus;
  18. #ifdef CONFIG_PCI
  19. extern int pcibus_to_node(struct pci_bus *bus);
  20. #else
  21. static inline int pcibus_to_node(struct pci_bus *bus)
  22. {
  23. return -1;
  24. }
  25. #endif
  26. #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
  27. cpu_all_mask : \
  28. cpumask_of_node(pcibus_to_node(bus)))
  29. extern int __node_distance(int, int);
  30. #define node_distance(a, b) __node_distance(a, b)
  31. extern void __init dump_numa_cpu_topology(void);
  32. extern int sysfs_add_device_to_node(struct device *dev, int nid);
  33. extern void sysfs_remove_device_from_node(struct device *dev, int nid);
  34. static inline int early_cpu_to_node(int cpu)
  35. {
  36. int nid;
  37. nid = numa_cpu_lookup_table[cpu];
  38. /*
  39. * Fall back to node 0 if nid is unset (it should be, except bugs).
  40. * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
  41. */
  42. return (nid < 0) ? 0 : nid;
  43. }
  44. #else
  45. static inline int early_cpu_to_node(int cpu) { return 0; }
  46. static inline void dump_numa_cpu_topology(void) {}
  47. static inline int sysfs_add_device_to_node(struct device *dev, int nid)
  48. {
  49. return 0;
  50. }
  51. static inline void sysfs_remove_device_from_node(struct device *dev,
  52. int nid)
  53. {
  54. }
  55. #endif /* CONFIG_NUMA */
  56. #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
  57. extern int start_topology_update(void);
  58. extern int stop_topology_update(void);
  59. extern int prrn_is_enabled(void);
  60. #else
  61. static inline int start_topology_update(void)
  62. {
  63. return 0;
  64. }
  65. static inline int stop_topology_update(void)
  66. {
  67. return 0;
  68. }
  69. static inline int prrn_is_enabled(void)
  70. {
  71. return 0;
  72. }
  73. #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
  74. #include <asm-generic/topology.h>
  75. #ifdef CONFIG_SMP
  76. #include <asm/cputable.h>
  77. #ifdef CONFIG_PPC64
  78. #include <asm/smp.h>
  79. #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
  80. #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
  81. #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
  82. #define topology_core_id(cpu) (cpu_to_core_id(cpu))
  83. #endif
  84. #endif
  85. #endif /* __KERNEL__ */
  86. #endif /* _ASM_POWERPC_TOPOLOGY_H */