6 #define KMSG_COMPONENT "cpu"
7 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/device.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
20 #include <asm/sysinfo.h>
22 #define PTF_HORIZONTAL (0UL)
23 #define PTF_VERTICAL (1UL)
24 #define PTF_CHECK (2UL)
32 static int topology_enabled = 1;
35 static void set_topology_timer(
void);
65 if (cpumask_empty(&mask))
84 cpumask_set_cpu(lcpu, &book->
mask);
86 cpumask_set_cpu(lcpu, &core->
mask);
88 if (one_core_per_cpu) {
100 static void clear_masks(
void)
106 cpumask_clear(&info->
mask);
111 cpumask_clear(&info->
mask);
142 add_cpus_to_mask(&tle->
cpu, book, core, 0);
167 core = add_cpus_to_mask(&tle->
cpu, book, core, 1);
182 spin_lock_irq(&topology_lock);
187 __tl_to_cores_z10(info);
190 __tl_to_cores_generic(info);
192 spin_unlock_irq(&topology_lock);
195 static void topology_update_polarization_simple(
void)
205 static
int ptf(
unsigned long fc)
210 " .insn rre,0xb9a20000,%1,%1\n"
235 static void update_cpu_core_map(
void)
242 cpu_core_map[
cpu] = cpu_group_map(&core_info, cpu);
243 cpu_book_map[
cpu] = cpu_group_map(&book_info, cpu);
245 spin_unlock_irqrestore(&topology_lock, flags);
251 stsi(info, 15, 1, 3);
253 stsi(info, 15, 1, 2);
263 update_cpu_core_map();
264 topology_update_polarization_simple();
269 update_cpu_core_map();
287 static void topology_timer_fn(
unsigned long ignored)
291 set_topology_timer();
299 static void set_topology_timer(
void)
301 if (atomic_add_unless(&topology_poll, -1, 0))
317 set_topology_timer();
320 static int __init early_parse_topology(
char *
p)
324 topology_enabled = 0;
337 nr_masks =
max(nr_masks, 1);
338 for (i = 0; i < nr_masks; i++) {
354 pr_info(
"The CPU configuration topology of the machine is:");
358 alloc_masks(info, &core_info, 1);
359 alloc_masks(info, &book_info, 2);
362 static int cpu_management;
371 count =
sprintf(buf,
"%d\n", cpu_management);
384 if (
sscanf(buf,
"%d %c", &val, &delim) != 1)
386 if (val != 0 && val != 1)
391 if (cpu_management == val)
396 cpu_management =
val;
401 return rc ? rc :
count;
403 static DEVICE_ATTR(dispatching, 0644, dispatching_show,
414 case POLARIZATION_HRZ:
415 count =
sprintf(buf,
"horizontal\n");
418 count =
sprintf(buf,
"vertical:low\n");
421 count =
sprintf(buf,
"vertical:medium\n");
424 count =
sprintf(buf,
"vertical:high\n");
427 count =
sprintf(buf,
"unknown\n");
435 static struct attribute *topology_cpu_attrs[] = {
436 &dev_attr_polarization.attr,
441 .attrs = topology_cpu_attrs,
449 static int __init topology_init(
void)
452 topology_update_polarization_simple();
455 set_topology_timer();
457 update_cpu_core_map();