blob: c82912a61d74f26a3d3b1b3e47913c899329ecf6 [file] [log] [blame]
Paul Mundt05a11782007-06-07 11:29:37 +09001/*
2 * arch/sh/kernel/topology.c
3 *
4 * Copyright (C) 2007 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
Paul Mundt7a302a92007-05-14 12:50:43 +090010#include <linux/cpu.h>
11#include <linux/cpumask.h>
12#include <linux/init.h>
13#include <linux/percpu.h>
Nobuhiro Iwamatsu6988d642011-08-26 05:05:41 +000014#include <linux/topology.h>
Paul Mundtd22d9b32007-06-01 14:21:13 +090015#include <linux/node.h>
16#include <linux/nodemask.h>
Paul Gortmakerf7be3452011-07-31 19:20:02 -040017#include <linux/export.h>
Paul Mundt7a302a92007-05-14 12:50:43 +090018
19static DEFINE_PER_CPU(struct cpu, cpu_devices);
20
Paul Mundt896f0c02009-10-16 18:00:02 +090021cpumask_t cpu_core_map[NR_CPUS];
Aurelien Jarno24ee7d72011-01-18 20:55:34 +000022EXPORT_SYMBOL(cpu_core_map);
Paul Mundt896f0c02009-10-16 18:00:02 +090023
Rich Felkerccc7d5a2016-03-29 22:50:02 +000024static cpumask_t cpu_coregroup_map(int cpu)
Paul Mundt896f0c02009-10-16 18:00:02 +090025{
26 /*
27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it
28 * simple until we have a method for determining topology..
29 */
Rusty Russell004f4ce2012-02-15 15:28:04 +103030 return *cpu_possible_mask;
Paul Mundt896f0c02009-10-16 18:00:02 +090031}
32
Rich Felkerccc7d5a2016-03-29 22:50:02 +000033const struct cpumask *cpu_coregroup_mask(int cpu)
Paul Mundt896f0c02009-10-16 18:00:02 +090034{
35 return &cpu_core_map[cpu];
36}
37
38int arch_update_cpu_topology(void)
39{
40 unsigned int cpu;
41
42 for_each_possible_cpu(cpu)
43 cpu_core_map[cpu] = cpu_coregroup_map(cpu);
44
45 return 0;
46}
47
Paul Mundt7a302a92007-05-14 12:50:43 +090048static int __init topology_init(void)
49{
50 int i, ret;
51
Paul Mundtd22d9b32007-06-01 14:21:13 +090052#ifdef CONFIG_NEED_MULTIPLE_NODES
53 for_each_online_node(i)
54 register_one_node(i);
55#endif
56
Paul Mundt7a302a92007-05-14 12:50:43 +090057 for_each_present_cpu(i) {
Paul Mundt9e8c5be2010-04-26 18:20:29 +090058 struct cpu *c = &per_cpu(cpu_devices, i);
59
60 c->hotpluggable = 1;
61
62 ret = register_cpu(c, i);
Paul Mundt7a302a92007-05-14 12:50:43 +090063 if (unlikely(ret))
64 printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n",
Harvey Harrison866e6b92008-03-04 15:23:47 -080065 __func__, i, ret);
Paul Mundt7a302a92007-05-14 12:50:43 +090066 }
67
Paul Mundt05a11782007-06-07 11:29:37 +090068#if defined(CONFIG_NUMA) && !defined(CONFIG_SMP)
69 /*
70 * In the UP case, make sure the CPU association is still
71 * registered under each node. Without this, sysfs fails
72 * to make the connection between nodes other than node0
73 * and cpu0.
74 */
75 for_each_online_node(i)
76 if (i != numa_node_id())
77 register_cpu_under_node(raw_smp_processor_id(), i);
78#endif
79
Paul Mundt7a302a92007-05-14 12:50:43 +090080 return 0;
81}
82subsys_initcall(topology_init);