topology.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. static inline int cpu_to_node(int cpu)
  14. {
  15. int nid;
  16. nid = numa_cpu_lookup_table[cpu];
  17. /*
  18. * During early boot, the numa-cpu lookup table might not have been
  19. * setup for all CPUs yet. In such cases, default to node 0.
  20. */
  21. return (nid < 0) ? 0 : nid;
  22. }
  23. #define parent_node(node) (node)
  24. #define cpumask_of_node(node) ((node) == -1 ? \
  25. cpu_all_mask : \
  26. node_to_cpumask_map[node])
  27. struct pci_bus;
  28. #ifdef CONFIG_PCI
  29. extern int pcibus_to_node(struct pci_bus *bus);
  30. #else
  31. static inline int pcibus_to_node(struct pci_bus *bus)
  32. {
  33. return -1;
  34. }
  35. #endif
  36. #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
  37. cpu_all_mask : \
  38. cpumask_of_node(pcibus_to_node(bus)))
  39. extern int __node_distance(int, int);
  40. #define node_distance(a, b) __node_distance(a, b)
  41. extern void __init dump_numa_cpu_topology(void);
  42. extern int sysfs_add_device_to_node(struct device *dev, int nid);
  43. extern void sysfs_remove_device_from_node(struct device *dev, int nid);
  44. #else
  45. static inline void dump_numa_cpu_topology(void) {}
  46. static inline int sysfs_add_device_to_node(struct device *dev, int nid)
  47. {
  48. return 0;
  49. }
  50. static inline void sysfs_remove_device_from_node(struct device *dev,
  51. int nid)
  52. {
  53. }
  54. #endif /* CONFIG_NUMA */
  55. #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
  56. extern int start_topology_update(void);
  57. extern int stop_topology_update(void);
  58. extern int prrn_is_enabled(void);
  59. #else
  60. static inline int start_topology_update(void)
  61. {
  62. return 0;
  63. }
  64. static inline int stop_topology_update(void)
  65. {
  66. return 0;
  67. }
  68. static inline int prrn_is_enabled(void)
  69. {
  70. return 0;
  71. }
  72. #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
  73. #include <asm-generic/topology.h>
  74. #ifdef CONFIG_SMP
  75. #include <asm/cputable.h>
  76. #ifdef CONFIG_PPC64
  77. #include <asm/smp.h>
  78. #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
  79. #define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
  80. #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
  81. #define topology_core_id(cpu) (cpu_to_core_id(cpu))
  82. #endif
  83. #endif
  84. #endif /* __KERNEL__ */
  85. #endif /* _ASM_POWERPC_TOPOLOGY_H */