linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 1/2] cpu: Do not return errors from cpu_dev_init() which will be ignored
@ 2012-01-10  2:59 Ben Hutchings
  2012-01-10  3:04 ` [PATCHv2 2/2] cpu: Register a generic CPU device on architectures that currently do not Ben Hutchings
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2012-01-10  2:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Linus Torvalds, Geert Uytterhoeven, Andrew Morton, linux-kernel,
	Linux-Arch, Thorsten Glaser, Debian kernel team, linux-m68k,
	debian-68k, Richard Weinberger

cpu_dev_init() is only called from driver_init(), which does not check
its return value.  Therefore make cpu_dev_init() return void.

We must register the CPU subsystem, so panic if this fails.

If sched_create_sysfs_power_savings_entries() fails, the damage is
contained, so ignore this (as before).

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/base/base.h |    2 +-
 drivers/base/cpu.c  |   13 +++++--------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index 7a6ae42..b858dfd 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -94,7 +94,7 @@ extern int hypervisor_init(void);
 static inline int hypervisor_init(void) { return 0; }
 #endif
 extern int platform_bus_init(void);
-extern int cpu_dev_init(void);
+extern void cpu_dev_init(void);
 
 extern int bus_add_device(struct device *dev);
 extern void bus_probe_device(struct device *dev);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 9a5578e..bba70d0 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -2,6 +2,7 @@
  * CPU subsystem support
  */
 
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -274,16 +275,12 @@ bool cpu_is_hotpluggable(unsigned cpu)
 }
 EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
 
-int __init cpu_dev_init(void)
+void __init cpu_dev_init(void)
 {
-	int err;
-
-	err = subsys_system_register(&cpu_subsys, cpu_root_attr_groups);
-	if (err)
-		return err;
+	if (subsys_system_register(&cpu_subsys, cpu_root_attr_groups))
+		panic("Failed to register CPU subsystem");
 
 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
-	err = sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root);
+	sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root);
 #endif
-	return err;
 }
-- 
1.7.8.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCHv2 2/2] cpu: Register a generic CPU device on architectures that currently do not
  2012-01-10  2:59 [PATCHv2 1/2] cpu: Do not return errors from cpu_dev_init() which will be ignored Ben Hutchings
@ 2012-01-10  3:04 ` Ben Hutchings
  2012-01-27 16:34   ` [PATCHv2 1/2] cpu: Do not return errors from cpu_dev_init() which will be ignored; " Thorsten Glaser
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2012-01-10  3:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Linus Torvalds, Geert Uytterhoeven, Andrew Morton, linux-kernel,
	Linux-Arch, Thorsten Glaser, Debian kernel team, linux-m68k,
	debian-68k, Richard Weinberger

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>
---
This is a combination of the previous version with Richard's patch for
UML.  I also changed the error path to use panic() so that nothing else
has to check for missing CPU devices.

Ben.

 arch/frv/Kconfig        |    1 +
 arch/h8300/Kconfig      |    1 +
 arch/m68k/Kconfig       |    1 +
 arch/microblaze/Kconfig |    1 +
 arch/openrisc/Kconfig   |    1 +
 arch/score/Kconfig      |    1 +
 arch/um/Kconfig.common  |    1 +
 arch/xtensa/Kconfig     |    1 +
 drivers/base/Kconfig    |    4 ++++
 drivers/base/cpu.c      |   19 +++++++++++++++++++
 10 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index bad27a6..70554ba 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -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
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index d1f377f..56e890d 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -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
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 81fdaa7..f755ecf 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -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
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index e446bab..16ca257 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -17,6 +17,7 @@ config MICROBLAZE
 	select HAVE_GENERIC_HARDIRQS
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
+	select GENERIC_CPU_DEVICES
 
 config SWAP
 	def_bool n
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index e518a5a..978e0bd 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -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
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index 8b0c946..51cbf1e 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -7,6 +7,7 @@ config SCORE
        select HAVE_MEMBLOCK
        select HAVE_MEMBLOCK_NODE_MAP
        select ARCH_DISCARD_MEMBLOCK
+       select GENERIC_CPU_DEVICES
 
 choice
 	prompt "System type"
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index a923483..b37ae70 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -8,6 +8,7 @@ config UML
 	default y
 	select HAVE_GENERIC_HARDIRQS
 	select GENERIC_IRQ_SHOW
+	select GENERIC_CPU_DEVICES
 
 config MMU
 	bool
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index c346ccd..8a3f835 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -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
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 21cf46f..4ebc5d3 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -172,6 +172,10 @@ config SYS_HYPERVISOR
 	bool
 	default n
 
+config GENERIC_CPU_DEVICES
+	bool
+	default n
+
 source "drivers/base/regmap/Kconfig"
 
 endmenu
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index bba70d0..db87e78 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -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
-- 
1.7.8.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCHv2 1/2] cpu: Do not return errors from cpu_dev_init() which will be ignored; [PATCHv2 2/2] cpu: Register a generic CPU device on architectures that currently do not
  2012-01-10  3:04 ` [PATCHv2 2/2] cpu: Register a generic CPU device on architectures that currently do not Ben Hutchings
@ 2012-01-27 16:34   ` Thorsten Glaser
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Glaser @ 2012-01-27 16:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Linus Torvalds, Geert Uytterhoeven,
	Andrew Morton, Linux-Arch, Debian kernel team, linux-m68k,
	debian-68k, Richard Weinberger

Ben Hutchings dixit:

>cpu_dev_init() is only called from driver_init(), which does not check
[…]

= and =

>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
[…]

Now that these are in the Debian Linux kernel package and a build has
been done, I can confirm the result boots on ARAnyM (m68k).

Tested-by: Thorsten Glaser <tg@debian.org>

bye,
//mirabilos
-- 
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy them.
If you don't believe in God, just consider God as Nature if you won't deny
existence.		-- Coywolf Qi Hunt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-27 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-10  2:59 [PATCHv2 1/2] cpu: Do not return errors from cpu_dev_init() which will be ignored Ben Hutchings
2012-01-10  3:04 ` [PATCHv2 2/2] cpu: Register a generic CPU device on architectures that currently do not Ben Hutchings
2012-01-27 16:34   ` [PATCHv2 1/2] cpu: Do not return errors from cpu_dev_init() which will be ignored; " Thorsten Glaser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).