105a11784SPaul Mundt /* 205a11784SPaul Mundt * arch/sh/kernel/topology.c 305a11784SPaul Mundt * 405a11784SPaul Mundt * Copyright (C) 2007 Paul Mundt 505a11784SPaul Mundt * 605a11784SPaul Mundt * This file is subject to the terms and conditions of the GNU General Public 705a11784SPaul Mundt * License. See the file "COPYING" in the main directory of this archive 805a11784SPaul Mundt * for more details. 905a11784SPaul Mundt */ 107a302a96SPaul Mundt #include <linux/cpu.h> 117a302a96SPaul Mundt #include <linux/cpumask.h> 127a302a96SPaul Mundt #include <linux/init.h> 137a302a96SPaul Mundt #include <linux/percpu.h> 14d22d9b3aSPaul Mundt #include <linux/node.h> 15d22d9b3aSPaul Mundt #include <linux/nodemask.h> 167a302a96SPaul Mundt 177a302a96SPaul Mundt static DEFINE_PER_CPU(struct cpu, cpu_devices); 187a302a96SPaul Mundt 19896f0c0eSPaul Mundt cpumask_t cpu_core_map[NR_CPUS]; 20896f0c0eSPaul Mundt 21896f0c0eSPaul Mundt static cpumask_t cpu_coregroup_map(unsigned int cpu) 22896f0c0eSPaul Mundt { 23896f0c0eSPaul Mundt /* 24896f0c0eSPaul Mundt * Presently all SH-X3 SMP cores are multi-cores, so just keep it 25896f0c0eSPaul Mundt * simple until we have a method for determining topology.. 26896f0c0eSPaul Mundt */ 27896f0c0eSPaul Mundt return cpu_possible_map; 28896f0c0eSPaul Mundt } 29896f0c0eSPaul Mundt 30896f0c0eSPaul Mundt const struct cpumask *cpu_coregroup_mask(unsigned int cpu) 31896f0c0eSPaul Mundt { 32896f0c0eSPaul Mundt return &cpu_core_map[cpu]; 33896f0c0eSPaul Mundt } 34896f0c0eSPaul Mundt 35896f0c0eSPaul Mundt int arch_update_cpu_topology(void) 36896f0c0eSPaul Mundt { 37896f0c0eSPaul Mundt unsigned int cpu; 38896f0c0eSPaul Mundt 39896f0c0eSPaul Mundt for_each_possible_cpu(cpu) 40896f0c0eSPaul Mundt cpu_core_map[cpu] = cpu_coregroup_map(cpu); 41896f0c0eSPaul Mundt 42896f0c0eSPaul Mundt return 0; 43896f0c0eSPaul Mundt } 44896f0c0eSPaul Mundt 457a302a96SPaul Mundt static int __init topology_init(void) 467a302a96SPaul Mundt { 477a302a96SPaul Mundt int i, ret; 487a302a96SPaul Mundt 49d22d9b3aSPaul Mundt #ifdef CONFIG_NEED_MULTIPLE_NODES 50d22d9b3aSPaul Mundt for_each_online_node(i) 51d22d9b3aSPaul Mundt register_one_node(i); 52d22d9b3aSPaul Mundt #endif 53d22d9b3aSPaul Mundt 547a302a96SPaul Mundt for_each_present_cpu(i) { 55*9e8c5be8SPaul Mundt struct cpu *c = &per_cpu(cpu_devices, i); 56*9e8c5be8SPaul Mundt 57*9e8c5be8SPaul Mundt c->hotpluggable = 1; 58*9e8c5be8SPaul Mundt 59*9e8c5be8SPaul Mundt ret = register_cpu(c, i); 607a302a96SPaul Mundt if (unlikely(ret)) 617a302a96SPaul Mundt printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n", 62866e6b9eSHarvey Harrison __func__, i, ret); 637a302a96SPaul Mundt } 647a302a96SPaul Mundt 6505a11784SPaul Mundt #if defined(CONFIG_NUMA) && !defined(CONFIG_SMP) 6605a11784SPaul Mundt /* 6705a11784SPaul Mundt * In the UP case, make sure the CPU association is still 6805a11784SPaul Mundt * registered under each node. Without this, sysfs fails 6905a11784SPaul Mundt * to make the connection between nodes other than node0 7005a11784SPaul Mundt * and cpu0. 7105a11784SPaul Mundt */ 7205a11784SPaul Mundt for_each_online_node(i) 7305a11784SPaul Mundt if (i != numa_node_id()) 7405a11784SPaul Mundt register_cpu_under_node(raw_smp_processor_id(), i); 7505a11784SPaul Mundt #endif 7605a11784SPaul Mundt 777a302a96SPaul Mundt return 0; 787a302a96SPaul Mundt } 797a302a96SPaul Mundt subsys_initcall(topology_init); 80