topology.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/sh/kernel/topology.c
  4. *
  5. * Copyright (C) 2007 Paul Mundt
  6. */
  7. #include <linux/cpu.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/init.h>
  10. #include <linux/percpu.h>
  11. #include <linux/topology.h>
  12. #include <linux/node.h>
  13. #include <linux/nodemask.h>
  14. #include <linux/export.h>
  15. static DEFINE_PER_CPU(struct cpu, cpu_devices);
  16. cpumask_t cpu_core_map[NR_CPUS];
  17. EXPORT_SYMBOL(cpu_core_map);
  18. static cpumask_t cpu_coregroup_map(int cpu)
  19. {
  20. /*
  21. * Presently all SH-X3 SMP cores are multi-cores, so just keep it
  22. * simple until we have a method for determining topology..
  23. */
  24. return *cpu_possible_mask;
  25. }
  26. const struct cpumask *cpu_coregroup_mask(int cpu)
  27. {
  28. return &cpu_core_map[cpu];
  29. }
  30. int arch_update_cpu_topology(void)
  31. {
  32. unsigned int cpu;
  33. for_each_possible_cpu(cpu)
  34. cpu_core_map[cpu] = cpu_coregroup_map(cpu);
  35. return 0;
  36. }
  37. static int __init topology_init(void)
  38. {
  39. int i, ret;
  40. for_each_present_cpu(i) {
  41. struct cpu *c = &per_cpu(cpu_devices, i);
  42. c->hotpluggable = 1;
  43. ret = register_cpu(c, i);
  44. if (unlikely(ret))
  45. printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n",
  46. __func__, i, ret);
  47. }
  48. #if defined(CONFIG_NUMA) && !defined(CONFIG_SMP)
  49. /*
  50. * In the UP case, make sure the CPU association is still
  51. * registered under each node. Without this, sysfs fails
  52. * to make the connection between nodes other than node0
  53. * and cpu0.
  54. */
  55. for_each_online_node(i)
  56. if (i != numa_node_id())
  57. register_cpu_under_node(raw_smp_processor_id(), i);
  58. #endif
  59. return 0;
  60. }
  61. subsys_initcall(topology_init);