Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cpu: Register a generic CPU device on architectures that currently do…

… not

frv, h8300, m68k, microblaze, openrisc, score, um and xtensa currently
do not register a CPU device.  Add the config option GENERIC_CPU_DEVICES
which causes a generic CPU device to be registered for each present CPU,
and make all these architectures select it.

Richard Weinberger <richard@nod.at> covered UML and suggested using
per_cpu.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information...
commit 9f13a1fd452f11c18004ba2422a6384b424ec8a9 1 parent 024f784
authored January 10, 2012 torvalds committed January 11, 2012
1  arch/frv/Kconfig
@@ -8,6 +8,7 @@ config FRV
8 8
 	select HAVE_GENERIC_HARDIRQS
9 9
 	select GENERIC_IRQ_SHOW
10 10
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
  11
+	select GENERIC_CPU_DEVICES
11 12
 
12 13
 config ZONE_DMA
13 14
 	bool
1  arch/h8300/Kconfig
@@ -4,6 +4,7 @@ config H8300
4 4
 	select HAVE_IDE
5 5
 	select HAVE_GENERIC_HARDIRQS
6 6
 	select GENERIC_IRQ_SHOW
  7
+	select GENERIC_CPU_DEVICES
7 8
 
8 9
 config SYMBOL_PREFIX
9 10
 	string
1  arch/m68k/Kconfig
@@ -6,6 +6,7 @@ config M68K
6 6
 	select HAVE_GENERIC_HARDIRQS
7 7
 	select GENERIC_IRQ_SHOW
8 8
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
  9
+	select GENERIC_CPU_DEVICES
9 10
 
10 11
 config RWSEM_GENERIC_SPINLOCK
11 12
 	bool
1  arch/microblaze/Kconfig
@@ -18,6 +18,7 @@ config MICROBLAZE
18 18
 	select GENERIC_IRQ_PROBE
19 19
 	select GENERIC_IRQ_SHOW
20 20
 	select GENERIC_PCI_IOMAP
  21
+	select GENERIC_CPU_DEVICES
21 22
 
22 23
 config SWAP
23 24
 	def_bool n
1  arch/openrisc/Kconfig
@@ -15,6 +15,7 @@ config OPENRISC
15 15
 	select GENERIC_IRQ_PROBE
16 16
 	select GENERIC_IRQ_SHOW
17 17
 	select GENERIC_IOMAP
  18
+	select GENERIC_CPU_DEVICES
18 19
 
19 20
 config MMU
20 21
 	def_bool y
1  arch/score/Kconfig
@@ -8,6 +8,7 @@ config SCORE
8 8
        select HAVE_MEMBLOCK
9 9
        select HAVE_MEMBLOCK_NODE_MAP
10 10
        select ARCH_DISCARD_MEMBLOCK
  11
+       select GENERIC_CPU_DEVICES
11 12
 
12 13
 choice
13 14
 	prompt "System type"
1  arch/um/Kconfig.common
@@ -8,6 +8,7 @@ config UML
8 8
 	default y
9 9
 	select HAVE_GENERIC_HARDIRQS
10 10
 	select GENERIC_IRQ_SHOW
  11
+	select GENERIC_CPU_DEVICES
11 12
 
12 13
 config MMU
13 14
 	bool
1  arch/xtensa/Kconfig
@@ -9,6 +9,7 @@ config XTENSA
9 9
 	select HAVE_IDE
10 10
 	select HAVE_GENERIC_HARDIRQS
11 11
 	select GENERIC_IRQ_SHOW
  12
+	select GENERIC_CPU_DEVICES
12 13
 	help
13 14
 	  Xtensa processors are 32-bit RISC machines designed by Tensilica
14 15
 	  primarily for embedded systems.  These processors are both
4  drivers/base/Kconfig
@@ -172,6 +172,10 @@ config SYS_HYPERVISOR
172 172
 	bool
173 173
 	default n
174 174
 
  175
+config GENERIC_CPU_DEVICES
  176
+	bool
  177
+	default n
  178
+
175 179
 source "drivers/base/regmap/Kconfig"
176 180
 
177 181
 config DMA_SHARED_BUFFER
19  drivers/base/cpu.c
@@ -11,6 +11,7 @@
11 11
 #include <linux/device.h>
12 12
 #include <linux/node.h>
13 13
 #include <linux/gfp.h>
  14
+#include <linux/percpu.h>
14 15
 
15 16
 #include "base.h"
16 17
 
@@ -275,11 +276,29 @@ bool cpu_is_hotpluggable(unsigned cpu)
275 276
 }
276 277
 EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
277 278
 
  279
+#ifdef CONFIG_GENERIC_CPU_DEVICES
  280
+static DEFINE_PER_CPU(struct cpu, cpu_devices);
  281
+#endif
  282
+
  283
+static void __init cpu_dev_register_generic(void)
  284
+{
  285
+#ifdef CONFIG_GENERIC_CPU_DEVICES
  286
+	int i;
  287
+
  288
+	for_each_possible_cpu(i) {
  289
+		if (register_cpu(&per_cpu(cpu_devices, i), i))
  290
+			panic("Failed to register CPU device");
  291
+	}
  292
+#endif
  293
+}
  294
+
278 295
 void __init cpu_dev_init(void)
279 296
 {
280 297
 	if (subsys_system_register(&cpu_subsys, cpu_root_attr_groups))
281 298
 		panic("Failed to register CPU subsystem");
282 299
 
  300
+	cpu_dev_register_generic();
  301
+
283 302
 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
284 303
 	sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root);
285 304
 #endif

0 notes on commit 9f13a1f

Please sign in to comment.
Something went wrong with that request. Please try again.