cpu: Register a generic CPU device on architectures that currently do not
authorBen Hutchings <ben@decadent.org.uk>
Tue, 10 Jan 2012 03:04:32 +0000 (03:04 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Jan 2012 23:50:11 +0000 (15:50 -0800)
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>
arch/frv/Kconfig
arch/h8300/Kconfig
arch/m68k/Kconfig
arch/microblaze/Kconfig
arch/openrisc/Kconfig
arch/score/Kconfig
arch/um/Kconfig.common
arch/xtensa/Kconfig
drivers/base/Kconfig
drivers/base/cpu.c

index bbbf7927f238005afee51476a6b9156f6c53f954..a685910d2d5ce562f36f8f4ae02811390600682c 100644 (file)
@@ -8,6 +8,7 @@ config FRV
        select HAVE_GENERIC_HARDIRQS
        select GENERIC_IRQ_SHOW
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
+       select GENERIC_CPU_DEVICES
 
 config ZONE_DMA
        bool
index d1f377f5d3b61b6f2cbeb575cb9aa02a8992d821..56e890df5053605a8eb7a66514eb096d0e110b2d 100644 (file)
@@ -4,6 +4,7 @@ config H8300
        select HAVE_IDE
        select HAVE_GENERIC_HARDIRQS
        select GENERIC_IRQ_SHOW
+       select GENERIC_CPU_DEVICES
 
 config SYMBOL_PREFIX
        string
index 99c363617f270fe3c0b6eb9f64c43a3c0d6bf0a0..ae413d4a8bb770783661104ba6d8d77ae0c3a103 100644 (file)
@@ -6,6 +6,7 @@ config M68K
        select HAVE_GENERIC_HARDIRQS
        select GENERIC_IRQ_SHOW
        select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
+       select GENERIC_CPU_DEVICES
 
 config RWSEM_GENERIC_SPINLOCK
        bool
index f0eead74fff67d1c4eb0af6eae23d1fcb26720b0..74f23a460ba2f4415a1657fd7288b318c469683d 100644 (file)
@@ -18,6 +18,7 @@ config MICROBLAZE
        select GENERIC_IRQ_PROBE
        select GENERIC_IRQ_SHOW
        select GENERIC_PCI_IOMAP
+       select GENERIC_CPU_DEVICES
 
 config SWAP
        def_bool n
index 081a54f1a93d23443f46c576f1031780f090a589..bc428b5f126c18b48d5b52e502d39eaf6241ac84 100644 (file)
@@ -15,6 +15,7 @@ config OPENRISC
        select GENERIC_IRQ_PROBE
        select GENERIC_IRQ_SHOW
        select GENERIC_IOMAP
+       select GENERIC_CPU_DEVICES
 
 config MMU
        def_bool y
index 3df65d39abc15f361df4cc61eace374af74e4c17..4b285779ac05e34559134072e6de57845abbe2ad 100644 (file)
@@ -8,6 +8,7 @@ config SCORE
        select HAVE_MEMBLOCK
        select HAVE_MEMBLOCK_NODE_MAP
        select ARCH_DISCARD_MEMBLOCK
+       select GENERIC_CPU_DEVICES
 
 choice
        prompt "System type"
index a9234838e8a29826ea947beaef7bf493bba49c40..b37ae706af3ee4e6534dea8872aaef903ac19e0f 100644 (file)
@@ -8,6 +8,7 @@ config UML
        default y
        select HAVE_GENERIC_HARDIRQS
        select GENERIC_IRQ_SHOW
+       select GENERIC_CPU_DEVICES
 
 config MMU
        bool
index c346ccdce0df55043dbdac8c87096addc0dd5b37..8a3f8351f4380d5ff8da08978ceb83fd4d19d689 100644 (file)
@@ -9,6 +9,7 @@ config XTENSA
        select HAVE_IDE
        select HAVE_GENERIC_HARDIRQS
        select GENERIC_IRQ_SHOW
+       select GENERIC_CPU_DEVICES
        help
          Xtensa processors are 32-bit RISC machines designed by Tensilica
          primarily for embedded systems.  These processors are both
index e95c67edb2cba54f4f314f36716f47bb71bfa5ae..fcbec8ac134deadb942a09d7ba5d76c681b3a596 100644 (file)
@@ -172,6 +172,10 @@ config SYS_HYPERVISOR
        bool
        default n
 
+config GENERIC_CPU_DEVICES
+       bool
+       default n
+
 source "drivers/base/regmap/Kconfig"
 
 config DMA_SHARED_BUFFER
index bba70d08be6a6b072d3d07545e694d8983bf3aff..db87e78d745940a3ba19332799930057edfd0615 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/device.h>
 #include <linux/node.h>
 #include <linux/gfp.h>
+#include <linux/percpu.h>
 
 #include "base.h"
 
@@ -275,11 +276,29 @@ bool cpu_is_hotpluggable(unsigned cpu)
 }
 EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
 
+#ifdef CONFIG_GENERIC_CPU_DEVICES
+static DEFINE_PER_CPU(struct cpu, cpu_devices);
+#endif
+
+static void __init cpu_dev_register_generic(void)
+{
+#ifdef CONFIG_GENERIC_CPU_DEVICES
+       int i;
+
+       for_each_possible_cpu(i) {
+               if (register_cpu(&per_cpu(cpu_devices, i), i))
+                       panic("Failed to register CPU device");
+       }
+#endif
+}
+
 void __init cpu_dev_init(void)
 {
        if (subsys_system_register(&cpu_subsys, cpu_root_attr_groups))
                panic("Failed to register CPU subsystem");
 
+       cpu_dev_register_generic();
+
 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
        sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root);
 #endif