cmd_boot: cleanup for 'go' command
PATCH 1/1 cmd_boot: cleanup for 'go' command
From: Kuo-Jung Su <[email protected]>
With MMU/D-Cache enabled, data might be retained at cache rather than at DRAM when we execute 'go' command, and some of the bare-metal softwares would always invalidate the entire data cache at start-up, and causes data lost issue.
This patch is designed to fixed this issue.
It has been verified at ARM based systems, and should also work at other platforms.
--- common/cmd_boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
common/cmd_boot.c +10 -0
@@ -50,6 +50,16 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("## Starting application at 0x%08lX ...\n" , addr); +#ifdef CONFIG_USE_IRQ +disable_interrupts (); +#endif +#ifndef CONFIG_SYS_DCACHE_OFF +flush_dcache_all (); +#endif +#ifndef CONFIG_SYS_ICACHE_OFF +invalidate_icache_all (); +#endif +/* * pass address parameter as argv[0] (aka command name), * and all remaining args
Signature · 1 line
1.7.9.5
PATCH 1/1 cmd_boot: cleanup for 'go' command
Dear Kuo-Jung Su,
Quoted 10 lines · In message <[email protected]> you wrote:
From: Kuo-Jung Su <[email protected]>
With MMU/D-Cache enabled, data might be retained at cache rather than at DRAM when we execute 'go' command, and some of the bare-metal softwares would always invalidate the entire data cache at start-up, and causes data lost issue.
This patch is designed to fixed this issue.
It has been verified at ARM based systems, and should also work at other platforms.
Your patch desription does not match the actual code.
common/cmd_boot.c static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 55
Quoted 9 lines
common/cmd_boot.c +3
-0@@ -50,6 +50,16 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("## Starting application at 0x%08lX ...\n" , addr); +#ifdef CONFIG_USE_IRQ +disable_interrupts (); +#endif
You do not mention in the commit message that you disable interrupts. This must not be done. There are many cases where interrupts are actually needed by the running code.
NAK for this part.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Perl script is correct if it's halfway readable and gets the job
done before your boss fires you.
- L. Wall & R. L. Schwartz, _Programming Perl_PATCH 1/1 cmd_boot: cleanup for 'go' command
2013/4/26 Wolfgang Denk <[email protected]>:
Quoted 10 lines
Dear Kuo-Jung Su,
Quoted 7 lines · In message <[email protected]> you wrote:
From: Kuo-Jung Su <[email protected]>
With MMU/D-Cache enabled, data might be retained at cache rather than at DRAM when we execute 'go' command, and some of the bare-metal softwares would always invalidate the entire data cache at start-up, and causes data lost issue.
Quoted 6 lines
Quoted 3 lines
This patch is designed to fixed this issue.
It has been verified at ARM based systems, and should also work at other platforms.Your patch desription does not match the actual code.
Got it, thanks
Quoted 6 lines
Quoted 6 lines
common/cmd_boot.c +0
-0@@ -50,6 +50,16 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("## Starting application at 0x%08lX ...\n" , addr);
Quoted 8 lines
common/cmd_boot.c static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 55
Quoted 3 lines
common/cmd_boot.c +3
-0+#ifdef CONFIG_USE_IRQ +disable_interrupts (); +#endif You do not mention in the commit message that you disable interrupts. This must not be done. There are many cases where interrupts are actually needed by the running code.
Got it, thanks
Quoted 6 lines
NAK for this part.
Best regards,
Wolfgang Denk
Quoted 7 lines
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A Perl script is correct if it's halfway readable and gets the job done before your boss fires you.
- L. Wall & R. L. Schwartz,_ProgrammingPerl_
--
Best wishes,
Kuo-Jung Su
PATCH v2 1/1 cmd_boot: cleanup for 'go' command
In reply to Kuo-Jung SuFrom: Kuo-Jung Su <[email protected]>
With MMU/D-Cache enabled, data might be retained at d-cache rather than at DRAM when we execute 'go' command, and some of the bare-metal softwares would always invalidate the entire data cache at start-up, and then leads to a data lost issue. Furthermore, the U-Boot not only relocates itself but also updates symbol table at start-up, which means the i-cache might also be dirty, so it would be better to invalidates the i-cache alone with d-cache flush.
This patch is designed to fix the issues above.
It has been verified at ARM based systems, and should also work at other platforms.
---
Changes for v2:
- Update the commit log to state that i-cache is also invalidated.
- DO NOT disable interrupts.
common/cmd_boot.c | 7 +++++++ 1 file changed, 7 insertions(+)
common/cmd_boot.c +7 -0
@@ -50,6 +50,13 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("## Starting application at 0x%08lX ...\n" , addr); +#ifndef CONFIG_SYS_DCACHE_OFF +flush_dcache_all (); +#endif +#ifndef CONFIG_SYS_ICACHE_OFF +invalidate_icache_all (); +#endif +/* * pass address parameter as argv[0] (aka command name), * and all remaining args
--
1.7.9.5
PATCH v2 1/1 cmd_boot: cleanup for 'go' command
Quoted 11 lines · Kuo-Jung Su
From: Kuo-Jung Su <[email protected]>
With MMU/D-Cache enabled, data might be retained at d-cache rather than at DRAM when we execute 'go' command, and some of the bare-metal softwares would always invalidate the entire data cache at start-up, and then leads to a data lost issue. Furthermore, the U-Boot not only relocates itself but also updates symbol table at start-up, which means the i-cache might also be dirty, so it would be better to invalidates the i-cache alone with d-cache flush.
Quoted 3 lines
This patch is designed to fix the issues above.
It has been verified at ARM based systems, and should also work at other platforms.
This patch has a few not trivially solvable problems. First, the only weak version of invalidate_icache_all is in common/cmd_cache.c. The only defined version of the function is for ARMv7 CPUs. So, everyone that is not ARMv7 and does not have CONFIG_CMD_CACHE will not build now.
And I'm not seeing a globally defined CONFIG to say "Yes, we are ARMv7" or "Yes, we have icache to invalidate".
This actually seems related to the cache flush issue that Freescale folks brought up a few weeks ago. Or maybe that's my pre-coffee brain talking.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130510/4e21768f/attachment.pgp>
PATCH v2 1/1 cmd_boot: cleanup for 'go' command
Quoted 23 lines · Tom Rini
Quoted 11 lines · Kuo-Jung Su
From: Kuo-Jung Su <[email protected]>
With MMU/D-Cache enabled, data might be retained at d-cache rather than at DRAM when we execute 'go' command, and some of the bare-metal softwares would always invalidate the entire data cache at start-up, and then leads to a data lost issue. Furthermore, the U-Boot not only relocates itself but also updates symbol table at start-up, which means the i-cache might also be dirty, so it would be better to invalidates the i-cache alone with d-cache flush.
Quoted 3 lines
This patch is designed to fix the issues above.
It has been verified at ARM based systems, and should also work at other platforms.This patch has a few not trivially solvable problems. First, the only weak version of
invalidate_icache_allis incommon/cmd_cache.c. The only defined version of the function is for ARMv7 CPUs. So, everyone that is not ARMv7 and does not haveCONFIG_CMD_CACHEwill not build now.
Quoted 7 lines
And I'm not seeing a globally defined CONFIG to say "Yes, we are ARMv7"
or "Yes, we have icache to invalidate".This actually seems related to the cache flush issue that Freescale folks brought up a few weeks ago. Or maybe that's my pre-coffee brain talking.
Yes, it's the same issue that we were talking about. mpc85xx does have flush_dcache() and invalidate_icache() which could be used for this, though they're currently missing the "_all" suffix.
-Scott