linux/arch/powerpc/include/asm/topology.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef _ASM_POWERPC_TOPOLOGY_H
   3#define _ASM_POWERPC_TOPOLOGY_H
   4#ifdef __KERNEL__
   5
   6
   7struct device;
   8struct device_node;
   9
  10#ifdef CONFIG_NUMA
  11
  12/*
  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().
  15 */
  16#define RECLAIM_DISTANCE 10
  17
  18#include <asm/mmzone.h>
  19
  20#define cpumask_of_node(node) ((node) == -1 ?                           \
  21                               cpu_all_mask :                           \
  22                               node_to_cpumask_map[node])
  23
  24struct pci_bus;
  25#ifdef CONFIG_PCI
  26extern int pcibus_to_node(struct pci_bus *bus);
  27#else
  28static inline int pcibus_to_node(struct pci_bus *bus)
  29{
  30        return -1;
  31}
  32#endif
  33
  34#define cpumask_of_pcibus(bus)  (pcibus_to_node(bus) == -1 ?            \
  35                                 cpu_all_mask :                         \
  36                                 cpumask_of_node(pcibus_to_node(bus)))
  37
  38extern int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc);
  39extern int __node_distance(int, int);
  40#define node_distance(a, b) __node_distance(a, b)
  41
  42extern void __init dump_numa_cpu_topology(void);
  43
  44extern int sysfs_add_device_to_node(struct device *dev, int nid);
  45extern void sysfs_remove_device_from_node(struct device *dev, int nid);
  46
  47static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node)
  48{
  49        numa_cpu_lookup_table[cpu] = node;
  50}
  51
  52static 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}
  64#else
  65
  66static inline int early_cpu_to_node(int cpu) { return 0; }
  67
  68static inline void dump_numa_cpu_topology(void) {}
  69
  70static inline int sysfs_add_device_to_node(struct device *dev, int nid)
  71{
  72        return 0;
  73}
  74
  75static inline void sysfs_remove_device_from_node(struct device *dev,
  76                                                int nid)
  77{
  78}
  79
  80static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
  81
  82static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
  83{
  84        return 0;
  85}
  86
  87#endif /* CONFIG_NUMA */
  88
  89#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
  90extern int find_and_online_cpu_nid(int cpu);
  91#else
  92static inline int find_and_online_cpu_nid(int cpu)
  93{
  94        return 0;
  95}
  96
  97#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
  98
  99#include <asm-generic/topology.h>
 100
 101#ifdef CONFIG_SMP
 102#include <asm/cputable.h>
 103
 104#ifdef CONFIG_PPC64
 105#include <asm/smp.h>
 106
 107#ifdef CONFIG_PPC_SPLPAR
 108int get_physical_package_id(int cpu);
 109#define topology_physical_package_id(cpu)       (get_physical_package_id(cpu))
 110#else
 111#define topology_physical_package_id(cpu)       (cpu_to_chip_id(cpu))
 112#endif
 113
 114#define topology_sibling_cpumask(cpu)   (per_cpu(cpu_sibling_map, cpu))
 115#define topology_core_cpumask(cpu)      (per_cpu(cpu_core_map, cpu))
 116#define topology_core_id(cpu)           (cpu_to_core_id(cpu))
 117
 118#endif
 119#endif
 120
 121#endif /* __KERNEL__ */
 122#endif  /* _ASM_POWERPC_TOPOLOGY_H */
 123