^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_ALPHA_TOPOLOGY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_ALPHA_TOPOLOGY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/threads.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/numa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/machvec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifdef CONFIG_NUMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static inline int cpu_to_node(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) int node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) if (!alpha_mv.cpuid_to_nid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) node = alpha_mv.cpuid_to_nid(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #ifdef DEBUG_NUMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) BUG_ON(node < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern struct cpumask node_to_cpumask_map[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /* FIXME: This is dumb, recalculating every time. But simple. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static const struct cpumask *cpumask_of_node(int node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) if (node == NUMA_NO_NODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return cpu_all_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) cpumask_clear(&node_to_cpumask_map[node]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) for_each_online_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) if (cpu_to_node(cpu) == node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) cpumask_set_cpu(cpu, node_to_cpumask_map[node]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return &node_to_cpumask_map[node];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define cpumask_of_pcibus(bus) (cpu_online_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #endif /* !CONFIG_NUMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) # include <asm-generic/topology.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #endif /* _ASM_ALPHA_TOPOLOGY_H */