blob: cca406fdbe51fcf9985320c10988a02025b099bc [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _ASM_S390_TOPOLOGY_H
3#define _ASM_S390_TOPOLOGY_H
4
Heiko Carstensdbd70fb2008-04-17 07:46:12 +02005#include <linux/cpumask.h>
Philipp Hachtmann3a368f72014-03-06 18:25:13 +01006#include <asm/numa.h>
Heiko Carstensdbd70fb2008-04-17 07:46:12 +02007
Heiko Carstens78609132012-09-03 14:11:32 +02008struct sysinfo_15_1_x;
Heiko Carstens83a24e32011-12-27 11:27:09 +01009struct cpu;
10
Heiko Carstens9236b4d2015-12-28 13:20:43 +010011#ifdef CONFIG_SCHED_TOPOLOGY
Heiko Carstens83a24e32011-12-27 11:27:09 +010012
Heiko Carstensd1e575082012-11-12 10:03:25 +010013struct cpu_topology_s390 {
Martin Schwidefsky10ad34b2015-01-14 17:52:10 +010014 unsigned short thread_id;
Heiko Carstensd1e575082012-11-12 10:03:25 +010015 unsigned short core_id;
16 unsigned short socket_id;
17 unsigned short book_id;
Heiko Carstensadac0f12016-05-25 10:25:50 +020018 unsigned short drawer_id;
Philipp Hachtmann3a368f72014-03-06 18:25:13 +010019 unsigned short node_id;
Martin Schwidefsky1887aa072017-09-22 14:17:41 +020020 unsigned short dedicated : 1;
Martin Schwidefsky10ad34b2015-01-14 17:52:10 +010021 cpumask_t thread_mask;
Heiko Carstensd1e575082012-11-12 10:03:25 +010022 cpumask_t core_mask;
23 cpumask_t book_mask;
Heiko Carstensadac0f12016-05-25 10:25:50 +020024 cpumask_t drawer_mask;
Heiko Carstensd1e575082012-11-12 10:03:25 +010025};
Heiko Carstens658e5ce2012-11-10 11:04:27 +010026
Heiko Carstens30fc4ca2016-12-02 10:38:37 +010027extern struct cpu_topology_s390 cpu_topology[NR_CPUS];
Heiko Carstens8c9105802016-12-03 09:50:21 +010028extern cpumask_t cpus_with_topology;
Heiko Carstensd1e575082012-11-12 10:03:25 +010029
Heiko Carstens30fc4ca2016-12-02 10:38:37 +010030#define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id)
31#define topology_thread_id(cpu) (cpu_topology[cpu].thread_id)
32#define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_mask)
33#define topology_core_id(cpu) (cpu_topology[cpu].core_id)
34#define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_mask)
35#define topology_book_id(cpu) (cpu_topology[cpu].book_id)
36#define topology_book_cpumask(cpu) (&cpu_topology[cpu].book_mask)
37#define topology_drawer_id(cpu) (cpu_topology[cpu].drawer_id)
38#define topology_drawer_cpumask(cpu) (&cpu_topology[cpu].drawer_mask)
Martin Schwidefsky1887aa072017-09-22 14:17:41 +020039#define topology_cpu_dedicated(cpu) (cpu_topology[cpu].dedicated)
Heiko Carstensd1e575082012-11-12 10:03:25 +010040
41#define mc_capable() 1
Heiko Carstensd00aa4e2008-04-30 13:38:40 +020042
Heiko Carstens8c9105802016-12-03 09:50:21 +010043void topology_init_early(void);
Heiko Carstens83a24e32011-12-27 11:27:09 +010044int topology_cpu_init(struct cpu *);
Heiko Carstensc10fde02008-04-17 07:46:13 +020045int topology_set_cpu_management(int fc);
46void topology_schedule_update(void);
Heiko Carstens96f4a702010-10-25 16:10:54 +020047void store_topology(struct sysinfo_15_1_x *info);
Heiko Carstensd68bddb2011-12-27 11:27:16 +010048void topology_expect_change(void);
Vincent Guittot2dfd7472014-04-11 11:44:38 +020049const struct cpumask *cpu_coregroup_mask(int cpu);
Heiko Carstensc10fde02008-04-17 07:46:13 +020050
Heiko Carstens9236b4d2015-12-28 13:20:43 +010051#else /* CONFIG_SCHED_TOPOLOGY */
Heiko Carstens83a24e32011-12-27 11:27:09 +010052
Heiko Carstens8c9105802016-12-03 09:50:21 +010053static inline void topology_init_early(void) { }
Heiko Carstens83a24e32011-12-27 11:27:09 +010054static inline void topology_schedule_update(void) { }
55static inline int topology_cpu_init(struct cpu *cpu) { return 0; }
Thomas Richter38389ec2017-11-16 14:26:36 +010056static inline int topology_cpu_dedicated(int cpu_nr) { return 0; }
Heiko Carstensd68bddb2011-12-27 11:27:16 +010057static inline void topology_expect_change(void) { }
Heiko Carstens83a24e32011-12-27 11:27:09 +010058
Heiko Carstens9236b4d2015-12-28 13:20:43 +010059#endif /* CONFIG_SCHED_TOPOLOGY */
Heiko Carstens83a24e32011-12-27 11:27:09 +010060
61#define POLARIZATION_UNKNOWN (-1)
Heiko Carstensc10fde02008-04-17 07:46:13 +020062#define POLARIZATION_HRZ (0)
63#define POLARIZATION_VL (1)
64#define POLARIZATION_VM (2)
65#define POLARIZATION_VH (3)
66
Philipp Hachtmann3a368f72014-03-06 18:25:13 +010067#define SD_BOOK_INIT SD_CPU_INIT
68
69#ifdef CONFIG_NUMA
70
71#define cpu_to_node cpu_to_node
72static inline int cpu_to_node(int cpu)
73{
Heiko Carstens30fc4ca2016-12-02 10:38:37 +010074 return cpu_topology[cpu].node_id;
Philipp Hachtmann3a368f72014-03-06 18:25:13 +010075}
76
77/* Returns a pointer to the cpumask of CPUs on node 'node'. */
78#define cpumask_of_node cpumask_of_node
79static inline const struct cpumask *cpumask_of_node(int node)
80{
Martin Schwidefsky22be9cd2015-09-22 14:21:16 +020081 return &node_to_cpumask_map[node];
Philipp Hachtmann3a368f72014-03-06 18:25:13 +010082}
83
Philipp Hachtmann3a368f72014-03-06 18:25:13 +010084#define pcibus_to_node(bus) __pcibus_to_node(bus)
85
86#define node_distance(a, b) __node_distance(a, b)
87
88#else /* !CONFIG_NUMA */
89
90#define numa_node_id numa_node_id
91static inline int numa_node_id(void)
92{
93 return 0;
94}
95
96#endif /* CONFIG_NUMA */
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#include <asm-generic/topology.h>
99
100#endif /* _ASM_S390_TOPOLOGY_H */