diff mbox

[U-Boot,v3,2/8] SPL: Port SPL framework to powerpc

Message ID 1348650074-25878-3-git-send-email-sr@denx.de
State Superseded
Delegated to: Scott Wood
Headers show

Commit Message

Stefan Roese Sept. 26, 2012, 9:01 a.m. UTC
This patch enables the SPL framework to be used on powerpc platforms
and not only ARM.

Signed-off-by: Stefan Roese <sr@denx.de>
---
Changes in v2:
- Rebased on Tom's SPL framework patches v4
- Add option to skip copying of the mkimage header

 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/spl.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c          | 10 ++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/powerpc/lib/spl.c

Comments

Scott Wood Sept. 28, 2012, 11:13 p.m. UTC | #1
On 09/26/2012 04:01:08 AM, Stefan Roese wrote:
> This patch enables the SPL framework to be used on powerpc platforms
> and not only ARM.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> Changes in v2:
> - Rebased on Tom's SPL framework patches v4
> - Add option to skip copying of the mkimage header
> 
>  arch/powerpc/lib/Makefile |  1 +
>  arch/powerpc/lib/spl.c    | 42  
> ++++++++++++++++++++++++++++++++++++++++++
>  common/spl/spl.c          | 10 ++++++++++
>  3 files changed, 53 insertions(+)
>  create mode 100644 arch/powerpc/lib/spl.c
> 
> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
> index 965f9ea..9bcbdde 100644
> --- a/arch/powerpc/lib/Makefile
> +++ b/arch/powerpc/lib/Makefile
> @@ -50,6 +50,7 @@ COBJS-y	+= cache.o
>  COBJS-y	+= extable.o
>  COBJS-y	+= interrupts.o
>  COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
> +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
>  COBJS-y	+= time.o

Won't this build spl.o into the main U-Boot as well?

> +/*
> + * This function jumps to an image with argument. Normally an FDT or  
> ATAGS
> + * image.
> + * arg: Pointer to paramter image in RAM
> + */
> +#ifdef CONFIG_SPL_OS_BOOT
> +void __noreturn jump_to_image_linux(void *arg)
> +{
> +	debug("Entering kernel arg pointer: 0x%p\n", arg);
> +	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,  
> ulong r6,
> +					  ulong r7, ulong r8, ulong r9)
> +		__attribute__ ((noreturn));
> +	image_entry_arg_t image_entry =
> +		(image_entry_arg_t)spl_image.entry_point;
> +
> +	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
> +}

At what point does the image get cache-flushed?

-Scott
Tom Rini Sept. 28, 2012, 11:32 p.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/28/12 16:13, Scott Wood wrote:
> On 09/26/2012 04:01:08 AM, Stefan Roese wrote:
>> This patch enables the SPL framework to be used on powerpc
>> platforms and not only ARM.
>> 
>> Signed-off-by: Stefan Roese <sr@denx.de> --- Changes in v2: -
>> Rebased on Tom's SPL framework patches v4 - Add option to skip
>> copying of the mkimage header
>> 
>> arch/powerpc/lib/Makefile |  1 + arch/powerpc/lib/spl.c    | 42 
>> ++++++++++++++++++++++++++++++++++++++++++ common/spl/spl.c
>> | 10 ++++++++++ 3 files changed, 53 insertions(+) create mode
>> 100644 arch/powerpc/lib/spl.c
>> 
>> diff --git a/arch/powerpc/lib/Makefile
>> b/arch/powerpc/lib/Makefile index 965f9ea..9bcbdde 100644 ---
>> a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@
>> -50,6 +50,7 @@ COBJS-y    += cache.o COBJS-y    += extable.o 
>> COBJS-y    += interrupts.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o 
>> +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o COBJS-y    += time.o
> 
> Won't this build spl.o into the main U-Boot as well?

True and probably uncaught as PowerPC uses -ffunction-sections /
- --gc-sections on main U-Boot.

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQZjOOAAoJENk4IS6UOR1We/UQAKmSBzEcGwjNzG9LqZhrRATj
8eMp/mep10saPAoaf8iUjqn+gWtAuvTdP9a0Nd4wkHUFtlvh7PPx6SQ1PNTf1V+z
VkOaXxplN52p0Ba/PKKEU4RFd9kdtxLrH+HM8mzz6ktzvwFT8lnCGY//C0OW8vk5
FLTeZafyde1OY5igGA2t/+Lu4CM3Dl1o7wMqcy7nNTucAMGgBjvZueOF7SWFAT7F
4mjxjIq9Co1NOIE9kCR4nmoJpRgvLZ2nBZpv2NDkXjKEr/6G2CSgDxBUG+Q2nGFG
HaBQv4yDfBEPCjUKWm+pq8BMYg/M+WuJZ02NNbGG09PeB8C+a26oYiy9KEPA+i5F
tTaBqgTNGIayqsYtOhQXEQntMudP1FTwCxQ2QMXuu3K5kY+foi5V/HdZ3Iy3Wl9W
WigE2+FBRfMPlvZT+s7qQ54UVOJgylRvld7e0jt/kcwTMF8WG3CauzqzgMbADz9C
Fr7J+cqij0JMCvE2E3/1Q8N4WIcnwBlM7R7TXVzd8cb3u/WHoLGVwhgLWGz3dg/E
/Ko+k4S/E0f3NWRX9pd1ygEveYNi4qVf8vWIaNMetjJputhHsToPtY8iid0TgOxt
oXGlOtOxHHkr5YFV3GIO6gmDWBzwTYrOCS9clrWZUq1fTgKxbsIythoOg0YIhA+U
Olz0yRI+lzUOkTOV1ZGc
=VYvH
-----END PGP SIGNATURE-----
Stefan Roese Oct. 2, 2012, 10:20 a.m. UTC | #3
On 09/29/2012 01:13 AM, Scott Wood wrote:
> On 09/26/2012 04:01:08 AM, Stefan Roese wrote:
>> This patch enables the SPL framework to be used on powerpc platforms
>> and not only ARM.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> ---
>> Changes in v2:
>> - Rebased on Tom's SPL framework patches v4
>> - Add option to skip copying of the mkimage header
>>
>>  arch/powerpc/lib/Makefile |  1 +
>>  arch/powerpc/lib/spl.c    | 42  
>> ++++++++++++++++++++++++++++++++++++++++++
>>  common/spl/spl.c          | 10 ++++++++++
>>  3 files changed, 53 insertions(+)
>>  create mode 100644 arch/powerpc/lib/spl.c
>>
>> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
>> index 965f9ea..9bcbdde 100644
>> --- a/arch/powerpc/lib/Makefile
>> +++ b/arch/powerpc/lib/Makefile
>> @@ -50,6 +50,7 @@ COBJS-y	+= cache.o
>>  COBJS-y	+= extable.o
>>  COBJS-y	+= interrupts.o
>>  COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
>> +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
>>  COBJS-y	+= time.o
> 
> Won't this build spl.o into the main U-Boot as well?

Yes. I'll fix it in the next patchset version.

>> +/*
>> + * This function jumps to an image with argument. Normally an FDT or  
>> ATAGS
>> + * image.
>> + * arg: Pointer to paramter image in RAM
>> + */
>> +#ifdef CONFIG_SPL_OS_BOOT
>> +void __noreturn jump_to_image_linux(void *arg)
>> +{
>> +	debug("Entering kernel arg pointer: 0x%p\n", arg);
>> +	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,  
>> ulong r6,
>> +					  ulong r7, ulong r8, ulong r9)
>> +		__attribute__ ((noreturn));
>> +	image_entry_arg_t image_entry =
>> +		(image_entry_arg_t)spl_image.entry_point;
>> +
>> +	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
>> +}
> 
> At what point does the image get cache-flushed?

Not at all right now. MPC5200 has dcache disabled, at least in the SPL.
Other PowerPC architectures might add a cache flush here if needed at
some time. Okay?

Thanks,
Stefan
Scott Wood Oct. 2, 2012, 8:08 p.m. UTC | #4
On 10/02/2012 05:20:54 AM, Stefan Roese wrote:
> On 09/29/2012 01:13 AM, Scott Wood wrote:
> > On 09/26/2012 04:01:08 AM, Stefan Roese wrote:
> >> This patch enables the SPL framework to be used on powerpc  
> platforms
> >> and not only ARM.
> >>
> >> Signed-off-by: Stefan Roese <sr@denx.de>
> >> ---
> >> Changes in v2:
> >> - Rebased on Tom's SPL framework patches v4
> >> - Add option to skip copying of the mkimage header
> >>
> >>  arch/powerpc/lib/Makefile |  1 +
> >>  arch/powerpc/lib/spl.c    | 42
> >> ++++++++++++++++++++++++++++++++++++++++++
> >>  common/spl/spl.c          | 10 ++++++++++
> >>  3 files changed, 53 insertions(+)
> >>  create mode 100644 arch/powerpc/lib/spl.c
> >>
> >> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
> >> index 965f9ea..9bcbdde 100644
> >> --- a/arch/powerpc/lib/Makefile
> >> +++ b/arch/powerpc/lib/Makefile
> >> @@ -50,6 +50,7 @@ COBJS-y	+= cache.o
> >>  COBJS-y	+= extable.o
> >>  COBJS-y	+= interrupts.o
> >>  COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
> >> +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
> >>  COBJS-y	+= time.o
> >
> > Won't this build spl.o into the main U-Boot as well?
> 
> Yes. I'll fix it in the next patchset version.
> 
> >> +/*
> >> + * This function jumps to an image with argument. Normally an FDT  
> or
> >> ATAGS
> >> + * image.
> >> + * arg: Pointer to paramter image in RAM
> >> + */
> >> +#ifdef CONFIG_SPL_OS_BOOT
> >> +void __noreturn jump_to_image_linux(void *arg)
> >> +{
> >> +	debug("Entering kernel arg pointer: 0x%p\n", arg);
> >> +	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,
> >> ulong r6,
> >> +					  ulong r7, ulong r8, ulong r9)
> >> +		__attribute__ ((noreturn));
> >> +	image_entry_arg_t image_entry =
> >> +		(image_entry_arg_t)spl_image.entry_point;
> >> +
> >> +	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
> >> +}
> >
> > At what point does the image get cache-flushed?
> 
> Not at all right now. MPC5200 has dcache disabled, at least in the  
> SPL.
> Other PowerPC architectures might add a cache flush here if needed at
> some time. Okay?

Or they might forget to do so and have weird bugs.

Why not just call flush_cache() on the image now?  Non-SPL does this in  
common code, not even PPC-specific.

-Scott
Stefan Roese Oct. 4, 2012, 7:36 a.m. UTC | #5
On 10/02/2012 10:08 PM, Scott Wood wrote:
>>>> +void __noreturn jump_to_image_linux(void *arg)
>>>> +{
>>>> +	debug("Entering kernel arg pointer: 0x%p\n", arg);
>>>> +	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,
>>>> ulong r6,
>>>> +					  ulong r7, ulong r8, ulong r9)
>>>> +		__attribute__ ((noreturn));
>>>> +	image_entry_arg_t image_entry =
>>>> +		(image_entry_arg_t)spl_image.entry_point;
>>>> +
>>>> +	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
>>>> +}
>>>
>>> At what point does the image get cache-flushed?
>>
>> Not at all right now. MPC5200 has dcache disabled, at least in the  
>> SPL.
>> Other PowerPC architectures might add a cache flush here if needed at
>> some time. Okay?
> 
> Or they might forget to do so and have weird bugs.
> 
> Why not just call flush_cache() on the image now?  Non-SPL does this in  
> common code, not even PPC-specific.

Okay, probably better to add this code now. But shouldn't we add this
code to the common SPL framework code then? Right before calling
jump_to_image_linux()?

Tom? Should I prepare a patch adding this cache flushing to
common/spl/spl.c?

Thanks,
Stefan
Scott Wood Oct. 4, 2012, 5:14 p.m. UTC | #6
On 10/04/2012 02:36:34 AM, Stefan Roese wrote:
> On 10/02/2012 10:08 PM, Scott Wood wrote:
> >>>> +void __noreturn jump_to_image_linux(void *arg)
> >>>> +{
> >>>> +	debug("Entering kernel arg pointer: 0x%p\n", arg);
> >>>> +	typedef void (*image_entry_arg_t)(void *, ulong r4,  
> ulong r5,
> >>>> ulong r6,
> >>>> +					  ulong r7, ulong r8,  
> ulong r9)
> >>>> +		__attribute__ ((noreturn));
> >>>> +	image_entry_arg_t image_entry =
> >>>> +		(image_entry_arg_t)spl_image.entry_point;
> >>>> +
> >>>> +	image_entry(arg, 0, 0, EPAPR_MAGIC,  
> CONFIG_SYS_BOOTMAPSZ, 0, 0);
> >>>> +}
> >>>
> >>> At what point does the image get cache-flushed?
> >>
> >> Not at all right now. MPC5200 has dcache disabled, at least in the
> >> SPL.
> >> Other PowerPC architectures might add a cache flush here if needed  
> at
> >> some time. Okay?
> >
> > Or they might forget to do so and have weird bugs.
> >
> > Why not just call flush_cache() on the image now?  Non-SPL does  
> this in
> > common code, not even PPC-specific.
> 
> Okay, probably better to add this code now. But shouldn't we add this
> code to the common SPL framework code then? Right before calling
> jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that  
knows the image start/end, not just the entry point).  This is just the  
patch that prompted me to ask the question.

-Scott
Stefan Roese Oct. 5, 2012, 1:15 p.m. UTC | #7
On 10/04/2012 07:14 PM, Scott Wood wrote:
> On 10/04/2012 02:36:34 AM, Stefan Roese wrote:
>> On 10/02/2012 10:08 PM, Scott Wood wrote:
>>>>>> +void __noreturn jump_to_image_linux(void *arg)
>>>>>> +{
>>>>>> +	debug("Entering kernel arg pointer: 0x%p\n", arg);
>>>>>> +	typedef void (*image_entry_arg_t)(void *, ulong r4,  
>> ulong r5,
>>>>>> ulong r6,
>>>>>> +					  ulong r7, ulong r8,  
>> ulong r9)
>>>>>> +		__attribute__ ((noreturn));
>>>>>> +	image_entry_arg_t image_entry =
>>>>>> +		(image_entry_arg_t)spl_image.entry_point;
>>>>>> +
>>>>>> +	image_entry(arg, 0, 0, EPAPR_MAGIC,  
>> CONFIG_SYS_BOOTMAPSZ, 0, 0);
>>>>>> +}
>>>>>
>>>>> At what point does the image get cache-flushed?
>>>>
>>>> Not at all right now. MPC5200 has dcache disabled, at least in the
>>>> SPL.
>>>> Other PowerPC architectures might add a cache flush here if needed  
>> at
>>>> some time. Okay?
>>>
>>> Or they might forget to do so and have weird bugs.
>>>
>>> Why not just call flush_cache() on the image now?  Non-SPL does  
>> this in
>>> common code, not even PPC-specific.
>>
>> Okay, probably better to add this code now. But shouldn't we add this
>> code to the common SPL framework code then? Right before calling
>> jump_to_image_linux()?
> 
> Sure, I didn't mean it should go here (it needs to be somewhere that  
> knows the image start/end, not just the entry point).  This is just the  
> patch that prompted me to ask the question.

I see.

Tom, whats your input on this? Do you see any problems about putting a
flush_cache() into the common SPL framework code? Are any of the ARM
platforms currently using this framework already running with d-cache
enabled?

Should I post a patch?

Thanks,
Stefan
Tom Rini Oct. 5, 2012, 3:22 p.m. UTC | #8
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/05/12 06:15, Stefan Roese wrote:
> On 10/04/2012 07:14 PM, Scott Wood wrote:
>> On 10/04/2012 02:36:34 AM, Stefan Roese wrote:
>>> On 10/02/2012 10:08 PM, Scott Wood wrote:
>>>>>>> +void __noreturn jump_to_image_linux(void *arg) +{ +
>>>>>>> debug("Entering kernel arg pointer: 0x%p\n", arg); +
>>>>>>> typedef void (*image_entry_arg_t)(void *, ulong r4,
>>> ulong r5,
>>>>>>> ulong r6, +					  ulong r7, ulong r8,
>>> ulong r9)
>>>>>>> +		__attribute__ ((noreturn)); +	image_entry_arg_t
>>>>>>> image_entry = +
>>>>>>> (image_entry_arg_t)spl_image.entry_point; + +
>>>>>>> image_entry(arg, 0, 0, EPAPR_MAGIC,
>>> CONFIG_SYS_BOOTMAPSZ, 0, 0);
>>>>>>> +}
>>>>>> 
>>>>>> At what point does the image get cache-flushed?
>>>>> 
>>>>> Not at all right now. MPC5200 has dcache disabled, at least
>>>>> in the SPL. Other PowerPC architectures might add a cache
>>>>> flush here if needed
>>> at
>>>>> some time. Okay?
>>>> 
>>>> Or they might forget to do so and have weird bugs.
>>>> 
>>>> Why not just call flush_cache() on the image now?  Non-SPL
>>>> does
>>> this in
>>>> common code, not even PPC-specific.
>>> 
>>> Okay, probably better to add this code now. But shouldn't we
>>> add this code to the common SPL framework code then? Right
>>> before calling jump_to_image_linux()?
>> 
>> Sure, I didn't mean it should go here (it needs to be somewhere
>> that knows the image start/end, not just the entry point).  This
>> is just the patch that prompted me to ask the question.
> 
> I see.
> 
> Tom, whats your input on this? Do you see any problems about
> putting a flush_cache() into the common SPL framework code? Are any
> of the ARM platforms currently using this framework already running
> with d-cache enabled?

On ARM, jump_to_image_linux() calls cleanup_before_linux() to take
care of flushing, etc.  So the PowerPC jump_to_image_linux should take
care of what it needs to take care of.

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQbvs/AAoJENk4IS6UOR1WXB4P/0g4rlsgzs1QBqRnM7oo/gDx
k3yNcN4jz7eHkY+X0hdgd8IqH8znqvptbr6D0w7/a35ZNqe0YZGqjQVI6DOh6QPx
oVSDYuywbP9arA83sYy44Ucf/acn/vYuvFqHoM7PTukUGcX3pdG5V4qiGnHe0H/B
4cp0iyY9wvt/eSrB6P7ZB2rse+fnQswBVEQ20Lkinr2ZkXcQMxiUHixfmxtQSV+b
SSHnd1XjSeIrLGHw4HlyoDYjZ8DQc4Zw/Sc/9fGnuwOiir4K743VXhU5hao4fQWp
F8OQgLaVkxxkALkwfdYS1G+vUgfzCxvWTxG3x/9oXUPh8VcXkqwhK3CXcnvLGAs8
3gu33UFzgMAFfd5bthwgKx50K9dTVSUWRsOu3lDUDi3jYZNoRpxcatQ5dWV1IW2V
UGgBQ4e7UE0h3SvQocnHbJAm+qcLyT6USH2xTyWRqi129OwKbuYM4nDH/nrYW11I
K7VY+tCqP9hoReuzVzFzsfBdaAzS9A+Z3uejYzfKaolnFvp8Bz4HVLdDQ9XBnddv
3flO7M4cO35xroBQ2QltibUkI5tgp3lmsVBuMUj5CQ7uojdjHoUNjfRKAKkKJYVp
07vlraRqNiqO1w7WoJCb3rLyH5P/9gZYoMkRsmtjA/Upg4FV+ntQgzDINANGE7e9
Lqd5K3EBnDLeLXt1bdWY
=5wlk
-----END PGP SIGNATURE-----
Scott Wood Oct. 5, 2012, 4:05 p.m. UTC | #9
On 10/05/2012 10:22:40 AM, Tom Rini wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 10/05/12 06:15, Stefan Roese wrote:
> > On 10/04/2012 07:14 PM, Scott Wood wrote:
> >> On 10/04/2012 02:36:34 AM, Stefan Roese wrote:
> >>> On 10/02/2012 10:08 PM, Scott Wood wrote:
> >>>>>>> +void __noreturn jump_to_image_linux(void *arg) +{ +
> >>>>>>> debug("Entering kernel arg pointer: 0x%p\n", arg); +
> >>>>>>> typedef void (*image_entry_arg_t)(void *, ulong r4,
> >>> ulong r5,
> >>>>>>> ulong r6, +					  ulong r7,  
> ulong r8,
> >>> ulong r9)
> >>>>>>> +		__attribute__ ((noreturn)); +	 
> image_entry_arg_t
> >>>>>>> image_entry = +
> >>>>>>> (image_entry_arg_t)spl_image.entry_point; + +
> >>>>>>> image_entry(arg, 0, 0, EPAPR_MAGIC,
> >>> CONFIG_SYS_BOOTMAPSZ, 0, 0);
> >>>>>>> +}
> >>>>>>
> >>>>>> At what point does the image get cache-flushed?
> >>>>>
> >>>>> Not at all right now. MPC5200 has dcache disabled, at least
> >>>>> in the SPL. Other PowerPC architectures might add a cache
> >>>>> flush here if needed
> >>> at
> >>>>> some time. Okay?
> >>>>
> >>>> Or they might forget to do so and have weird bugs.
> >>>>
> >>>> Why not just call flush_cache() on the image now?  Non-SPL
> >>>> does
> >>> this in
> >>>> common code, not even PPC-specific.
> >>>
> >>> Okay, probably better to add this code now. But shouldn't we
> >>> add this code to the common SPL framework code then? Right
> >>> before calling jump_to_image_linux()?
> >>
> >> Sure, I didn't mean it should go here (it needs to be somewhere
> >> that knows the image start/end, not just the entry point).  This
> >> is just the patch that prompted me to ask the question.
> >
> > I see.
> >
> > Tom, whats your input on this? Do you see any problems about
> > putting a flush_cache() into the common SPL framework code? Are any
> > of the ARM platforms currently using this framework already running
> > with d-cache enabled?
> 
> On ARM, jump_to_image_linux() calls cleanup_before_linux() to take
> care of flushing, etc.  So the PowerPC jump_to_image_linux should take
> care of what it needs to take care of.

It seems that most implementations of cleanup_before_linux() -- which  
is quite misnamed as we need to do this stuff no matter what we're  
loading -- disable and flush the entire cache.  Are there any  
implementations that just flush the range that the image was loaded  
into?  Is that information available at that point?

What if we're loading main U-Boot and not Linux?  Does  
cleanup_before_linux() still get called?

Normal U-Boot does this from generic code, why not SPL?  It should  
become a no-op on platforms that don't need it.

-Scott
Stefan Roese Oct. 5, 2012, 5:03 p.m. UTC | #10
On 10/05/2012 05:22 PM, Tom Rini wrote:

<snip>

>>>> Okay, probably better to add this code now. But shouldn't we
>>>> add this code to the common SPL framework code then? Right
>>>> before calling jump_to_image_linux()?
>>>
>>> Sure, I didn't mean it should go here (it needs to be somewhere
>>> that knows the image start/end, not just the entry point).  This
>>> is just the patch that prompted me to ask the question.
>>
>> I see.
>>
>> Tom, whats your input on this? Do you see any problems about
>> putting a flush_cache() into the common SPL framework code? Are any
>> of the ARM platforms currently using this framework already running
>> with d-cache enabled?
> 
> On ARM, jump_to_image_linux() calls cleanup_before_linux() to take
> care of flushing, etc.  So the PowerPC jump_to_image_linux should take
> care of what it needs to take care of.

Hmmm. Why not move this cleanup_xxx stuff into the common code as well?
Is it really that platform specific? Cache flushing is a common problem.

So basically a "+1" for Scotts comments. But I would suggest to address
this in a follow up patch, to consolidate all this cleanup/cache_flush
stuff. Okay?

Thanks,
Stefan
Tom Rini Oct. 5, 2012, 5:33 p.m. UTC | #11
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/05/12 10:03, Stefan Roese wrote:
> On 10/05/2012 05:22 PM, Tom Rini wrote:
> 
> <snip>
> 
>>>>> Okay, probably better to add this code now. But shouldn't
>>>>> we add this code to the common SPL framework code then?
>>>>> Right before calling jump_to_image_linux()?
>>>> 
>>>> Sure, I didn't mean it should go here (it needs to be
>>>> somewhere that knows the image start/end, not just the entry
>>>> point).  This is just the patch that prompted me to ask the
>>>> question.
>>> 
>>> I see.
>>> 
>>> Tom, whats your input on this? Do you see any problems about 
>>> putting a flush_cache() into the common SPL framework code? Are
>>> any of the ARM platforms currently using this framework already
>>> running with d-cache enabled?
>> 
>> On ARM, jump_to_image_linux() calls cleanup_before_linux() to
>> take care of flushing, etc.  So the PowerPC jump_to_image_linux
>> should take care of what it needs to take care of.
> 
> Hmmm. Why not move this cleanup_xxx stuff into the common code as
> well? Is it really that platform specific? Cache flushing is a
> common problem.
> 
> So basically a "+1" for Scotts comments. But I would suggest to
> address this in a follow up patch, to consolidate all this
> cleanup/cache_flush stuff. Okay?

OK, so my quick check of things shows that in SPL, arm isn't ever
enabling the dcache (at least CONFIG_SPL_FRAMEWORK), we just make sure
that yes, really, we're good to go for Linux kernel booting.  That's
why we haven't had this as a general issue yet.  So in sum, yes,
please come up with patches to get things in a more consistent state.
 It should probably be re-naming cleanup_before_linux as well and
calling that as in some cases we need to do a little more than
i/d_disable, flush (see the v7 one).  Thanks!

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQbxnlAAoJENk4IS6UOR1WzcMP+wY7gH6kE9ryBF+Aem78dz/O
5nCBzQJg6GSpab6S4qUFGutmh0GVqMhTgA5cQrlzNt7JvZNboe15bf/u91g6RNCv
q2saJzYj8wQJ7DrUQtAoNA/jdI5zLTQ8jE0Zbg8kD/MszP5NipMH7SHZTfoedVfx
dAqoDpmXFbsp70E8/rtnlhP+8z5kxrw9xzZwRvtjb1oAT8w707frge4Yfa/lz2Xo
vd55/CzdUYwJRKgJmdSzYjGmV+nBER6IDl76LiVg4C/xVbcc8qjO8Ebja2j8Cftr
cuJ7ith/RLpMNqPQ/yNwA25MK3yBL1AA+XGADjMhMv4VjzbapRkDveUOFYzORlko
jdjEOfR4g0onerjHGTkysIqIchvxPOatDm0a0+kw+JronCh9aJMJOZ0xjaBdEQ9Q
xQDA+U+o45+YKFTuAAOisehJ5hmgnmqV2yH4my7CR/NcJvaV1vbq0DN1O9gIRvWU
x1wUKWH/MtOs/SdIDXF+nIwI7LBK96YyTERIaOwpa01YuTkc8m6frGJZYZO1yaQU
sACj3e8mQmXkkXXy6eKiY/aJLnMep1ZNOf/JobzSN+R92g01yED88T38/aqZWt80
0+N2vFmLZvg4CLWWdUbVNxU7mv14b2kCc2bI5m7zuTXdXccTausaZ9r3WZgBnY3R
RPYJc0MosHUmXEozty2y
=3AZY
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 965f9ea..9bcbdde 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -50,6 +50,7 @@  COBJS-y	+= cache.o
 COBJS-y	+= extable.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o
 
 # Workaround for local bus unaligned access problems
diff --git a/arch/powerpc/lib/spl.c b/arch/powerpc/lib/spl.c
new file mode 100644
index 0000000..502c93b
--- /dev/null
+++ b/arch/powerpc/lib/spl.c
@@ -0,0 +1,42 @@ 
+/*
+ * Copyright 2012 Stefan Roese <sr@denx.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#include <common.h>
+#include <config.h>
+#include <spl.h>
+#include <image.h>
+#include <linux/compiler.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function jumps to an image with argument. Normally an FDT or ATAGS
+ * image.
+ * arg: Pointer to paramter image in RAM
+ */
+#ifdef CONFIG_SPL_OS_BOOT
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5, ulong r6,
+					  ulong r7, ulong r8, ulong r9)
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}
+#endif /* CONFIG_SPL_OS_BOOT */
diff --git a/common/spl/spl.c b/common/spl/spl.c
index c640f87..e568c49 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -74,6 +74,16 @@  __weak int spl_start_uboot(void)
 }
 #endif
 
+/*
+ * Weak default function for board specific cleanup/preparation before
+ * Linux boot. Some boards/platforms might now need it, so just provide
+ * an empty stub here.
+ */
+__weak void spl_board_prepare_for_linux(void)
+{
+	/* Nothing to do! */
+}
+
 void spl_parse_image_header(const struct image_header *header)
 {
 	u32 header_size = sizeof(struct image_header);