linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of/flattree: use callback to setup initrd from /chosen
@ 2009-12-22  9:39 Jeremy Kerr
  2009-12-22 10:47 ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Kerr @ 2009-12-22  9:39 UTC (permalink / raw)
  To: Grant Likely, devicetree-discuss; +Cc: microblaze-uclinux, linuxppc-dev

At present, the fdt code sets the kernel-wide initrd_start and
initrd_end variables when parsing /chosen. On ARM, we only set these
once the bootmem has been reserved.

This change adds an arch callback to setup the initrd from the device
tree:

 void early_init_dt_setup_initrd_arch(unsigned long start,
				      unsigned long end);

The arch-specific code can then setup the initrd however it likes.

Compiled on powerpc, with CONFIG_BLK_DEV_INITRD=y and =n.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>

---
 arch/microblaze/kernel/prom.c |   10 ++++++++++
 arch/powerpc/kernel/prom.c    |   10 ++++++++++
 drivers/of/fdt.c              |   15 +++++----------
 include/linux/of_fdt.h        |   10 ++++++++++
 4 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 15853de..4fb5d87 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -101,6 +101,16 @@ void __init early_init_devtree_arch(void)
 	/* No Microblaze specific code here */
 }
 
+#ifdef CONFIG_BLK_DEV_INITRD
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+		unsigned long end)
+{
+	initrd_start = (unsigned long)__va(start);
+	initrd_end = (unsigned long)__va(end);
+	initrd_below_start_ok = 1;
+}
+#endif
+
 /*******
  *
  * New implementation of the OF "find" APIs, return a refcounted
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 6fea025..236b02c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -467,6 +467,16 @@ int __init early_init_dt_scan_memory_arch(unsigned long node, const char *uname,
 }
 #endif /* CONFIG_PPC_PSERIES */
 
+#ifdef CONFIG_BLK_DEV_INITRD
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+		unsigned long end)
+{
+	initrd_start = (unsigned long)__va(start);
+	initrd_end = (unsigned long)__va(end);
+	initrd_below_start_ok = 1;
+}
+#endif
+
 void __init early_reserve_mem(void)
 {
 	u64 base, size;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7cb386c..ad0b09a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -398,28 +398,23 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
  */
 void __init early_init_dt_check_for_initrd(unsigned long node)
 {
-	unsigned long len;
+	unsigned long start, end, len;
 	__be32 *prop;
 
 	pr_debug("Looking for initrd properties... ");
 
 	prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len);
 	if (prop) {
-		initrd_start = (unsigned long)
-				__va(of_read_ulong(prop, len/4));
+		start = of_read_ulong(prop, len/4);
 
 		prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len);
 		if (prop) {
-			initrd_end = (unsigned long)
-				__va(of_read_ulong(prop, len/4));
-			initrd_below_start_ok = 1;
-		} else {
-			initrd_start = 0;
+			end = of_read_ulong(prop, len/4);
+			early_init_dt_setup_initrd_arch(start, end);
 		}
 	}
 
-	pr_debug("initrd_start=0x%lx  initrd_end=0x%lx\n",
-		 initrd_start, initrd_end);
+	pr_debug("initrd_start=0x%lx  initrd_end=0x%lx\n", start, end);
 }
 #else
 inline void early_init_dt_check_for_initrd(unsigned long node)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 77ae0a4..4aba9a6 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -81,6 +81,16 @@ extern void early_reserve_mem(void);
 extern void early_init_devtree_arch(void);
 extern u64 dt_mem_next_cell(int s, __be32 **cellp);
 
+/*
+ * If BLK_DEV_INITRD, the fdt early init code will call this function,
+ * to be provided by the arch code. start and end are specified as
+ * physical addresses.
+ */
+#ifdef CONFIG_BLK_DEV_INITRD
+extern void early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end);
+#endif
+
 /* With CONFIG_HAVE_LMB, we can just use the lmb_ functions to add & allocate
  * memory; otherwise, the arch has to provide its own functions to do this.
  */

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

* Re: [PATCH] of/flattree: use callback to setup initrd from /chosen
  2009-12-22  9:39 [PATCH] of/flattree: use callback to setup initrd from /chosen Jeremy Kerr
@ 2009-12-22 10:47 ` Michael Ellerman
  2009-12-22 10:54   ` Jeremy Kerr
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2009-12-22 10:47 UTC (permalink / raw)
  To: Jeremy Kerr; +Cc: microblaze-uclinux, devicetree-discuss, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 897 bytes --]

On Tue, 2009-12-22 at 17:39 +0800, Jeremy Kerr wrote:
> At present, the fdt code sets the kernel-wide initrd_start and
> initrd_end variables when parsing /chosen. On ARM, we only set these
> once the bootmem has been reserved.
> 
> This change adds an arch callback to setup the initrd from the device
> tree:
> 
>  void early_init_dt_setup_initrd_arch(unsigned long start,
> 				      unsigned long end);

arch_early_init_dt_setup_initrd() makes more sense to me, but ..

> +#ifdef CONFIG_BLK_DEV_INITRD
> +void __init early_init_dt_setup_initrd_arch(unsigned long start,
> +		unsigned long end)
> +{
> +	initrd_start = (unsigned long)__va(start);
> +	initrd_end = (unsigned long)__va(end);
> +	initrd_below_start_ok = 1;
> +}
> +#endif

Given you have two identical implementations why not make that the
default and make it weak, and let ARM override it.

cheers



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] of/flattree: use callback to setup initrd from /chosen
  2009-12-22 10:47 ` Michael Ellerman
@ 2009-12-22 10:54   ` Jeremy Kerr
  2009-12-22 13:17     ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Kerr @ 2009-12-22 10:54 UTC (permalink / raw)
  To: michael; +Cc: microblaze-uclinux, devicetree-discuss, linuxppc-dev

Hi Michael,

> >  void early_init_dt_setup_initrd_arch(unsigned long start,
> > 				      unsigned long end);
> 
> arch_early_init_dt_setup_initrd() makes more sense to me, but ..

<foo>_arch has been the general convention for arch-specific hooks in 
drivers/of/.

> > +#ifdef CONFIG_BLK_DEV_INITRD
> > +void __init early_init_dt_setup_initrd_arch(unsigned long start,
> > +		unsigned long end)
> > +{
> > +	initrd_start = (unsigned long)__va(start);
> > +	initrd_end = (unsigned long)__va(end);
> > +	initrd_below_start_ok = 1;
> > +}
> > +#endif
> 
> Given you have two identical implementations why not make that the
> default and make it weak, and let ARM override it.

Yeah, that would be good too; just been avoiding weak as a potential source of 
magic voodoo complexity. Grant - up to you on this one.

Cheers,


Jeremy

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

* Re: [PATCH] of/flattree: use callback to setup initrd from /chosen
  2009-12-22 10:54   ` Jeremy Kerr
@ 2009-12-22 13:17     ` Michael Ellerman
  2010-01-13  6:43       ` Grant Likely
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2009-12-22 13:17 UTC (permalink / raw)
  To: Jeremy Kerr; +Cc: microblaze-uclinux, devicetree-discuss, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

On Tue, 2009-12-22 at 18:54 +0800, Jeremy Kerr wrote:
> Hi Michael,
> 
> > >  void early_init_dt_setup_initrd_arch(unsigned long start,
> > > 				      unsigned long end);
> > 
> > arch_early_init_dt_setup_initrd() makes more sense to me, but ..
> 
> <foo>_arch has been the general convention for arch-specific hooks in 
> drivers/of/.

Yuck, doh, guess I should have read those patches before they went in :)

> > > +#ifdef CONFIG_BLK_DEV_INITRD
> > > +void __init early_init_dt_setup_initrd_arch(unsigned long start,
> > > +		unsigned long end)
> > > +{
> > > +	initrd_start = (unsigned long)__va(start);
> > > +	initrd_end = (unsigned long)__va(end);
> > > +	initrd_below_start_ok = 1;
> > > +}
> > > +#endif
> > 
> > Given you have two identical implementations why not make that the
> > default and make it weak, and let ARM override it.
> 
> Yeah, that would be good too; just been avoiding weak as a potential source of 
> magic voodoo complexity. Grant - up to you on this one.

Yeah, depends on what toolchains you're supporting, modern ones should
be OK but it can be troublesome.

cheers



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] of/flattree: use callback to setup initrd from /chosen
  2009-12-22 13:17     ` Michael Ellerman
@ 2010-01-13  6:43       ` Grant Likely
  2010-01-13 11:03         ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Grant Likely @ 2010-01-13  6:43 UTC (permalink / raw)
  To: michael; +Cc: microblaze-uclinux, Jeremy Kerr, linuxppc-dev, devicetree-discuss

On Tue, Dec 22, 2009 at 6:17 AM, Michael Ellerman
<michael@ellerman.id.au> wrote:
> On Tue, 2009-12-22 at 18:54 +0800, Jeremy Kerr wrote:
>> Hi Michael,
>>
>> > > =A0void early_init_dt_setup_initrd_arch(unsigned long start,
>> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsi=
gned long end);
>> >
>> > arch_early_init_dt_setup_initrd() makes more sense to me, but ..
>>
>> <foo>_arch has been the general convention for arch-specific hooks in
>> drivers/of/.
>
> Yuck, doh, guess I should have read those patches before they went in :)

It's not necessarily permanent.  My first goal is to get the common
code merged.  Then I want to look closely at it for patterns and
refactor how the common code calls out to arch specific hooks (or
maybe turn it around and have arch code calling out to the common
bits).

>
>> > > +#ifdef CONFIG_BLK_DEV_INITRD
>> > > +void __init early_init_dt_setup_initrd_arch(unsigned long start,
>> > > + =A0 =A0 =A0 =A0 unsigned long end)
>> > > +{
>> > > + initrd_start =3D (unsigned long)__va(start);
>> > > + initrd_end =3D (unsigned long)__va(end);
>> > > + initrd_below_start_ok =3D 1;
>> > > +}
>> > > +#endif
>> >
>> > Given you have two identical implementations why not make that the
>> > default and make it weak, and let ARM override it.
>>
>> Yeah, that would be good too; just been avoiding weak as a potential sou=
rce of
>> magic voodoo complexity. Grant - up to you on this one.
>
> Yeah, depends on what toolchains you're supporting, modern ones should
> be OK but it can be troublesome.

I'll look at this.

g.


--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH] of/flattree: use callback to setup initrd from /chosen
  2010-01-13  6:43       ` Grant Likely
@ 2010-01-13 11:03         ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2010-01-13 11:03 UTC (permalink / raw)
  To: Grant Likely
  Cc: microblaze-uclinux, Jeremy Kerr, linuxppc-dev, devicetree-discuss

[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]

On Tue, 2010-01-12 at 23:43 -0700, Grant Likely wrote:
> On Tue, Dec 22, 2009 at 6:17 AM, Michael Ellerman
> <michael@ellerman.id.au> wrote:
> > On Tue, 2009-12-22 at 18:54 +0800, Jeremy Kerr wrote:
> >> Hi Michael,
> >>
> >> > >  void early_init_dt_setup_initrd_arch(unsigned long start,
> >> > >                                 unsigned long end);
> >> >
> >> > arch_early_init_dt_setup_initrd() makes more sense to me, but ..
> >>
> >> <foo>_arch has been the general convention for arch-specific hooks in
> >> drivers/of/.
> >
> > Yuck, doh, guess I should have read those patches before they went in :)
> 
> It's not necessarily permanent.  My first goal is to get the common
> code merged.  Then I want to look closely at it for patterns and
> refactor how the common code calls out to arch specific hooks (or
> maybe turn it around and have arch code calling out to the common
> bits).

Sure, no biggy. There is lots of precedent for arch hooks to be called
arch_foo() or topic_arch_foo(), but it's not the end of the world.

cheers



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2010-01-13 11:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22  9:39 [PATCH] of/flattree: use callback to setup initrd from /chosen Jeremy Kerr
2009-12-22 10:47 ` Michael Ellerman
2009-12-22 10:54   ` Jeremy Kerr
2009-12-22 13:17     ` Michael Ellerman
2010-01-13  6:43       ` Grant Likely
2010-01-13 11:03         ` Michael Ellerman

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).