diff mbox

[v3] ARM: default machine descriptor for multiplatform

Message ID 201304191640.32139.arnd@arndb.de (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Bergmann April 19, 2013, 2:40 p.m. UTC
Since we now have default implementations for init_time and init_irq,
the init_machine callback is the only one that is not yet optional,
but since simple DT based platforms all have the same
of_platform_populate function call in there, we can consolidate them
as well, and then actually boot with a completely empty machine_desc.
Unofortunately we cannot just default to an empty init_machine: We
cannot call of_platform_populate before init_machine because that
does not work in case of auxdata, and we cannot call it after
init_machine either because the machine might need to run code
after adding the devices.

To take the final step, this adds support for booting without defining
any machine_desc whatsoever.

For the case that CONFIG_MULTIPLATFORM is enabled, it adds a
global machine descriptor that never matches any machine but is
used as a fallback if nothing else matches. We assume that without
CONFIG_MULTIPLATFORM, we only want to boot on the systems that the kernel
is built for, so we still retain the build-time warning for missing
machine descriptors and the run-time warning when the platform does not
match in that case.

In the case that we run on a multiplatform kernel and the machine
provides a fully populated device tree, we attempt to keep booting,
hoping that no machine specific callbacks are necessary.

Finally, this also removes the misguided "select ARCH_VEXPRESS" that
was only added to avoid a build error for allnoconfig kernels.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Olof Johansson <olof@lixom.net>
Cc: "Russell King - ARM Linux" <linux@arm.linux.org.uk>
Cc: Rob Herring <robherring2@gmail.com>

Comments

Rob Herring April 19, 2013, 9:32 p.m. UTC | #1
On 04/19/2013 09:40 AM, Arnd Bergmann wrote:
> Since we now have default implementations for init_time and init_irq,
> the init_machine callback is the only one that is not yet optional,
> but since simple DT based platforms all have the same
> of_platform_populate function call in there, we can consolidate them
> as well, and then actually boot with a completely empty machine_desc.
> Unofortunately we cannot just default to an empty init_machine: We
> cannot call of_platform_populate before init_machine because that
> does not work in case of auxdata, and we cannot call it after
> init_machine either because the machine might need to run code
> after adding the devices.
> 
> To take the final step, this adds support for booting without defining
> any machine_desc whatsoever.
> 
> For the case that CONFIG_MULTIPLATFORM is enabled, it adds a
> global machine descriptor that never matches any machine but is
> used as a fallback if nothing else matches. We assume that without
> CONFIG_MULTIPLATFORM, we only want to boot on the systems that the kernel
> is built for, so we still retain the build-time warning for missing
> machine descriptors and the run-time warning when the platform does not
> match in that case.
> 
> In the case that we run on a multiplatform kernel and the machine
> provides a fully populated device tree, we attempt to keep booting,
> hoping that no machine specific callbacks are necessary.
> 
> Finally, this also removes the misguided "select ARCH_VEXPRESS" that
> was only added to avoid a build error for allnoconfig kernels.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Nicolas Pitre <nico@linaro.org>
> Acked-by: Olof Johansson <olof@lixom.net>
> Cc: "Russell King - ARM Linux" <linux@arm.linux.org.uk>

[...]

>  	if (machine_desc->init_machine)
>  		machine_desc->init_machine();
> +	else
> +		of_platform_populate(NULL, of_default_bus_match_table,

This will fail to build for !OF. of_platform.h needs this:

#define of_default_bus_match_table NULL

You may need some struct forward declarations, but this commit in my
tree for 3.10 should fix those:

commit d450f445f9a654080a6be4094376c2192d9a1f36
Author: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date:   Tue Feb 19 02:58:25 2013 +0300

    <linux/of_platform.h>: fix compilation warnings with DT disabled


Rob

> +					NULL, NULL);
>  	return 0;
>  }
>  arch_initcall(customize_machine);
>
Arnd Bergmann April 19, 2013, 9:54 p.m. UTC | #2
On Friday 19 April 2013, Rob Herring wrote:
> This will fail to build for !OF. of_platform.h needs this:
> 
> #define of_default_bus_match_table NULL
> 
> You may need some struct forward declarations, but this commit in my
> tree for 3.10 should fix those:
> 
> commit d450f445f9a654080a6be4094376c2192d9a1f36
> Author: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> Date:   Tue Feb 19 02:58:25 2013 +0300
> 
>     <linux/of_platform.h>: fix compilation warnings with DT disabled
> 

Ok. I've actually stumbled over missing declarations from of_platform.h
and related files a number of times. Could we please not hide any
declarations inside of #ifdef when there is no #else alternative?

If we just show the of_default_bus_match_table declaration in the
header file, there is no need to provide the silly NULL macro,
since the of_platform_populate alternative will just ignore it.

I'll just put the code in an #ifdef for now, but I'd really prefer
to clean up this and many other locations that currently have
to do #ifdef CONFIG_OF when they really don't need to.

	Arnd
Rob Herring April 19, 2013, 10:22 p.m. UTC | #3
On 04/19/2013 04:54 PM, Arnd Bergmann wrote:
> On Friday 19 April 2013, Rob Herring wrote:
>> This will fail to build for !OF. of_platform.h needs this:
>>
>> #define of_default_bus_match_table NULL
>>
>> You may need some struct forward declarations, but this commit in my
>> tree for 3.10 should fix those:
>>
>> commit d450f445f9a654080a6be4094376c2192d9a1f36
>> Author: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>> Date:   Tue Feb 19 02:58:25 2013 +0300
>>
>>     <linux/of_platform.h>: fix compilation warnings with DT disabled
>>
> 
> Ok. I've actually stumbled over missing declarations from of_platform.h
> and related files a number of times. Could we please not hide any
> declarations inside of #ifdef when there is no #else alternative?
> 
> If we just show the of_default_bus_match_table declaration in the
> header file, there is no need to provide the silly NULL macro,
> since the of_platform_populate alternative will just ignore it.
> 
> I'll just put the code in an #ifdef for now, but I'd really prefer
> to clean up this and many other locations that currently have
> to do #ifdef CONFIG_OF when they really don't need to.

I think we can kill off CONFIG_OF_DEVICE completely. It is always
enabled when OF is (even for the oddball Sparc).

The only remaining user of of_platform_driver is ibmebus and 2 drivers.
It would be good to convert those to regular platform drivers.

Rob
Arnd Bergmann April 19, 2013, 11:11 p.m. UTC | #4
On Saturday 20 April 2013, Rob Herring wrote:
> The only remaining user of of_platform_driver is ibmebus and 2 drivers.
> It would be good to convert those to regular platform drivers.
> 

Right, I would not expect any trouble in converting ibmebus to
use a regular platform_driver. It already uses platform_device
anyway. We cannot remove ibmebus itself because it has special
DMA requirements, but we could move it to drivers/bus if the
powerpc maintainers like that.

	Arnd.
diff mbox

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1cacda4..e67d49d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1014,7 +1014,6 @@  config ARCH_MULTI_V7
 	bool "ARMv7 based platforms (Cortex-A, PJ4, Scorpion, Krait)"
 	default y
 	select ARCH_MULTI_V6_V7
-	select ARCH_VEXPRESS
 	select CPU_V7
 
 config ARCH_MULTI_V6_V7
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 70f1bde..9038c9f 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -180,6 +180,13 @@  struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
 	unsigned long dt_root;
 	const char *model;
 
+	if (IS_ENABLED(CONFIG_ARCH_MULTIPLATFORM)) {
+		DT_MACHINE_START(GENERIC_DT, "Generic DT based system")
+		MACHINE_END
+
+		mdesc_best = (struct machine_desc *)&__mach_desc_GENERIC_DT;
+	}
+
 	if (!dt_phys)
 		return NULL;
 
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index d343a6c..9e0f43d 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -18,6 +18,7 @@ 
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
 #include <linux/screen_info.h>
+#include <linux/of_platform.h>
 #include <linux/init.h>
 #include <linux/kexec.h>
 #include <linux/of_fdt.h>
@@ -660,9 +661,17 @@  struct screen_info screen_info = {
 
 static int __init customize_machine(void)
 {
-	/* customizes platform devices, or adds new ones */
+	/*
+	 * customizes platform devices, or adds new ones
+	 * On DT based machines, we fall back to populating the
+	 * machine from the device tree, if no callback is provided,
+	 * otherwise we would always need an init_machine callback.
+	 */
 	if (machine_desc->init_machine)
 		machine_desc->init_machine();
+	else
+		of_platform_populate(NULL, of_default_bus_match_table,
+					NULL, NULL);
 	return 0;
 }
 arch_initcall(customize_machine);