arm: move flush_dcache_all() to just before disable cache
PATCH v2 1/10 arm: move flush_dcache_all() to just before disable cache
From: Arun Mankuzhi <[email protected]>
In Cortex-A15 architecture, when we run cache invalidate the cache clean operation executes automatically.
So if there are any dirty cache lines before disabling the L2 cache these will be synchronized with the main memory when invalidate_dcache_all() runs in the last part of U-boot
The two functions after flush_dcache_all is using the stack. So this data will be on the cache. After disable when invalidate is called the data will be flushed from cache to memory. This corrupts the stack in invalida_dcache_all. So this change is required to avoid the u-boot hang.
So flush has to be done just before clearing CR_C bit
---
Changes in v2: None
arch/arm/lib/cache-cp15.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/lib/cache-cp15.c +4 -1
@@ -124,8 +124,11 @@ static void cache_disable(uint32_t cache_bit)return ;/* if disabling data cache, disable mmu too */ cache_bit |= CR_M; - flush_dcache_all(); } + reg =get_cr (); +cp_delay (); +if (cache_bit == (CR_C |CR_M )) +flush_dcache_all ();set_cr (reg & ~cache_bit); }#endif
Signature · 1 line
1.7.7.3
PATCH v2 2/10 arm: Keep track of the tlb size as well as its location
From: Gabe Black <[email protected]>
It may be necessary to know where the TLB area ends as well as where it starts. This allows board code to complete a secure memory erase without destroying the page tables.
---
Changes in v2: None
arch/arm/include/asm/global_data.h | 1 + arch/arm/lib/board.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/include/asm/global_data.h +1 -0
@@ -73,6 +73,7 @@ typedef struct global_data {unsigned long reloc_off;#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))unsigned long tlb_addr; +unsigned long tlb_size;#endif const void *fdt_blob;/* Our device tree, NULL if none */ void **jt;/* jump table */
arch/arm/lib/board.c +3 -2
@@ -353,13 +353,14 @@ void board_init_f(ulong bootflag)#if !(defined(CONFIG_SYS_ICACHE_OFF ) && defined(CONFIG_SYS_DCACHE_OFF ))/* reserve TLB table */ - addr -= (4096 *4 ); + gd->tlb_size =4096 *4 ; + addr -= gd->tlb_size;/* round down to next 64 kB limit */ addr &= ~(0x10000 -1 ); gd->tlb_addr = addr; -debug ("TLB table at: %08lx\n" , addr); +debug ("TLB table from %08lx to %08lx\n" , addr, addr + gd->tlb_size);#endif /* round down to next 4 kB limit */
Signature · 1 line
1.7.7.3
PATCH v2 3/10 arm: Move fdt check earlier so that board_early_init_f() can use it
In reply to Simon GlassWe want to use the fdt inside board_early_init_f(), so check for its presence earlier in the pre-reloc init sequence.
So far ARM and microblaze are the only only ones that use CONFIG_OF_CONTROL. Microblaze does not have the same init loop, and in particular does not have the board_early_init_f() call. So a patch for microblaze would have no meaning.
---
Changes in v2:
- Update commit message with more detail
arch/arm/lib/board.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/arm/lib/board.c +3 -4
@@ -233,13 +233,12 @@ int power_init_board(void)init_fnc_t *init_sequence[] = { arch_cpu_init,/* basic arch cpu dependent setup */ - -#if defined(CONFIG_BOARD_EARLY_INIT_F) - board_early_init_f, -#endif #ifdef CONFIG_OF_CONTROL fdtdec_check_fdt, #endif +#if defined(CONFIG_BOARD_EARLY_INIT_F) + board_early_init_f, +#endif timer_init,/* initialize timer */ #ifdef CONFIG_BOARD_POSTCLK_INIT board_postclk_init,
Signature · 1 line
1.7.7.3
PATCH v2 4/10 arm: Add CONFIG_DELAY_ENVIRONMENT to delay environment loading
In reply to Simon GlassThis option delays loading of the environment until later, so that only the default environment will be available to U-Boot.
This can address the security risk of untrusted data being used during boot.
Any time you load untrusted data you expose yourself to a bug in the code. The attacker gets to choose the data so can sometimes carefully craft it to exploit a bug. We try to avoid touching user-controlled data during a verified boot unless strictly necessary. Since the default environment is good enough in this case (or you would just change it), this gets around the problem by just not loading the environment.
When CONFIG_DELAY_ENVIRONMENT is defined, it is convenient to have a run-time way of enabling loading of the environment. Add this to the fdt as /config/delay-environment.
Note: This patch depends on http://patchwork.ozlabs.org/patch/194342/
---
Changes in v2:
- Update commit message to provide more detail
README | 9 +++++++++ arch/arm/lib/board.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-)
README +9 -0
@@ -2329,6 +2329,15 @@ CBFS (Coreboot Filesystem) support run-time determined information about the hardware to the environment. These will be named board_name, board_rev. + CONFIG_DELAY_ENVIRONMENT + + Normally the environment is loaded when the board is + intialised so that it is available to U-Boot. This inhibits + that so that the environment is not available until + explicitly loaded later by U-Boot code. With CONFIG_OF_CONTROL + this is instead controlled by the value of + /config/load-environment. + - DataFlash Support: CONFIG_HAS_DATAFLASH
arch/arm/lib/board.c +27 -2
@@ -40,6 +40,7 @@#include <common.h> #include <command.h> +#include <environment.h> #include <malloc.h> #include <stdio_dev.h> #include <version.h>
@@ -476,7 +477,28 @@ static char *failed = "*** failed ***\n";#endif /* -************************************************************************ +* Tell if it's OK to load the environment early in boot. +* +* If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see +* if this is OK (defaulting to saying it's not OK). +* +* NOTE: Loading the environment early can be a bad idea if security is +* important, since no verification is done on the environment. +* +* @return 0 if environment should not be loaded, !=0 if it is ok to load +*/ +static int should_load_env (void ) +{ +#ifdef CONFIG_OF_CONTROL +return fdtdec_get_config_int (gd->fdt_blob,"load-environment" ,0 ); +#elif definedCONFIG_DELAY_ENVIRONMENT +return 0 ; +#else +return 1 ; +#endif +} + +/************************************************************************ * * This is the next part if the initialization sequence: we are now * running from RAM and have a "normal" C environment, i. e. global
@@ -583,7 +605,10 @@ void board_init_r(gd_t *id, ulong dest_addr)#endif /* initialize environment */ -env_relocate (); +if (should_load_env ()) +env_relocate (); +else +set_default_env (NULL );#if defined(CONFIG_CMD_PCI ) || defined(CONFIG_PCI )arm_pci_init ();
Signature · 1 line
1.7.7.3
PATCH v2 4/10 arm: Add CONFIG_DELAY_ENVIRONMENT to delay environment loading
Quoted 104 lines · Simon Glass
This option delays loading of the environment until later, so that only the default environment will be available to U-Boot.
This can address the security risk of untrusted data being used during boot.
Any time you load untrusted data you expose yourself to a bug in the code. The attacker gets to choose the data so can sometimes carefully craft it to exploit a bug. We try to avoid touching user-controlled data during a verified boot unless strictly necessary. Since the default environment is good enough in this case (or you would just change it), this gets around the problem by just not loading the environment.
When
CONFIG_DELAY_ENVIRONMENTis defined, it is convenient to have a run-time way of enabling loading of the environment. Add this to the fdt as /config/delay-environment.Note: This patch depends on http://patchwork.ozlabs.org/patch/194342/
Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Update commit message to provide more detailREADME | 9 +++++++++ arch/arm/lib/board.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-)README +9
-0@@ -2329,6 +2329,15 @@ CBFS (Coreboot Filesystem) support run-time determined information about the hardware to the environment. These will be named board_name, board_rev. + CONFIG_DELAY_ENVIRONMENT + + Normally the environment is loaded when the board is + intialised so that it is available to U-Boot. This inhibits + that so that the environment is not available until + explicitly loaded later by U-Boot code. With CONFIG_OF_CONTROL + this is instead controlled by the value of + /config/load-environment. + - DataFlash Support: CONFIG_HAS_DATAFLASHarch/arm/lib/board.c +27
-3@@ -40,6 +40,7 @@#include <common.h> #include <command.h> +#include <environment.h> #include <malloc.h> #include <stdio_dev.h> #include <version.h> @@ -476,7 +477,28 @@ static char *failed = "*** failed ***\n";#endif /* -************************************************************************ +* Tell if it's OK to load the environment early in boot. +* +* If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see +* if this is OK (defaulting to saying it's not OK). +* +* NOTE: Loading the environment early can be a bad idea if security is +* important, since no verification is done on the environment. +* +* @return 0 if environment should not be loaded, !=0 if it is ok to load +*/ +static int should_load_env (void ) +{ +#ifdef CONFIG_OF_CONTROL +return fdtdec_get_config_int (gd->fdt_blob,"load-environment" ,0 ); +#elif definedCONFIG_DELAY_ENVIRONMENT +return 0 ; +#else +return 1 ; +#endif +} + +/************************************************************************ * * This is the next part if the initialization sequence: we are now * running from RAM and have a "normal" C environment, i. e. global @@ -583,7 +605,10 @@ void board_init_r(gd_t *id, ulong dest_addr)#endif /* initialize environment */ -env_relocate (); +if (should_load_env ()) +env_relocate (); +else +set_default_env (NULL );#if defined(CONFIG_CMD_PCI ) || defined(CONFIG_PCI )arm_pci_init (); --
Quoted 2 lines
1.7.7.3
PATCH v2 5/10 Document the CONFIG_DISPLAY_BOARDINFO option
In reply to Simon GlassAdd a short note about this in the README.
---
Changes in v2:
- Split out CONFIG_DISPLAY_BOARDINFO README change into separate commit
README | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
README +5 -0
@@ -3351,6 +3351,11 @@ use the "saveenv" command to store a valid environment. space for already greatly restricted images, including but not limited to NAND_SPL configurations. +- CONFIG_DISPLAY_BOARDINFO + Display information about the board that U-Boot is running on + when U-Boot starts up. The board function checkboard() is called + to do this. + Low Level (hardware related) configuration options: ---------------------------------------------------
Signature · 1 line
1.7.7.3
PATCH v2 6/10 arm: Add CONFIG_DISPLAY_BOARDINFO_LATE to display board info on LCD
In reply to Simon GlassThis option displays board info after stdio is running, so that it will appear on the LCD. If it is displayed earlier, the board info will appear on the serial console but not on the LCD.
Here follows a blow-by-blow description.
1a. Without CONFIG_DISPLAY_BOARDINFO_LATE, on serial:
U-Boot 2011.12-02550-g037e1c5-dirty (Nov 15 2012 - 14:29:42) for SMDK5250
CPU: S5PC520 @ 1700MHz
Board: Google Snow, rev 0 I2C: ready DRAM: 2 GiB Elpida DDR3 @ 800MHz MMC: S5P MSHC0: 0, S5P MSHC1: 1 SF: Detected W25Q32 with page size 4 KiB, total 4 MiB
*** Warning - bad CRC, using default environment
In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0
SMDK5250 #
1b. Without CONFIG_DISPLAY_BOARDINFO_LATE, on LCD (note machine info is missing):
In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0
SMDK5250 #
2a. With CONFIG_DISPLAY_BOARDINFO_LATE, on serial:
U-Boot 2011.12-02550-g037e1c5 (Nov 15 2012 - 14:27:40) for SMDK5250
CPU: S5PC520 @ 1700MHz I2C: ready DRAM: 2 GiB Elpida DDR3 @ 800MHz MMC: S5P MSHC0: 0, S5P MSHC1: 1 SF: Detected W25Q32 with page size 4 KiB, total 4 MiB
*** Warning - bad CRC, using default environment
Model: Google Snow In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0
SMDK5250 #
2b. With CONFIG_DISPLAY_BOARDINFO_LATE, on LCD (note machine info is present):
Model: Google Snow In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0
SMDK5250 #
Since the LCD is all that a typical user sees, it is useful to display the model there.
We may be able to rearrange things some other way one day, but at present this seems like a convenient way of getting the required behaviour.
---
Changes in v2:
- Update commit message to provide a detailed description
README | 5 +++++ arch/arm/lib/board.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-)
README +5 -0
@@ -3356,6 +3356,11 @@ use the "saveenv" command to store a valid environment. when U-Boot starts up. The board function checkboard() is called to do this. +- CONFIG_DISPLAY_BOARDINFO_LATE + Similar to the previous option, but display this information + later, once stdio is running and output goes to the LCD, if + present. + Low Level (hardware related) configuration options: ---------------------------------------------------
arch/arm/lib/board.c +19 -0
@@ -498,6 +498,16 @@ static int should_load_env(void)#endif } +#if defined(CONFIG_DISPLAY_BOARDINFO_LATE ) && defined(CONFIG_OF_CONTROL ) +static void display_fdt_model (const void *blob) +{ +const char *model; + + model = (char *)fdt_getprop (blob,0 ,"model" ,NULL ); +printf ("Model: %s\n" , model ? model :"<unknown>" ); +} +#endif +/************************************************************************ * * This is the next part if the initialization sequence: we are now
@@ -625,6 +635,15 @@ void board_init_r(gd_t *id, ulong dest_addr)console_init_r ();/* fully init console as a device */ +#ifdef CONFIG_DISPLAY_BOARDINFO_LATE +# ifdef CONFIG_OF_CONTROL +/* Put this here so it appears on the LCD, now it is ready */ +display_fdt_model (gd->fdt_blob); +# else +checkboard (); +# endif +#endif +#if defined(CONFIG_ARCH_MISC_INIT )/* miscellaneous arch dependent initialisations */ arch_misc_init ();
Signature · 1 line
1.7.7.3
PATCH v2 7/10 Add option to display customised memory information
In reply to Simon GlassSome boards want to report more than just memory size. For example, it might be useful to display the memory type (DDR2, DDR3) or manufacturer.
Add a weak function to support this requirement, accessed through a new 'meminfo' command.
Any example of the DRAM: output is below, just for illustration:
SMDK5250 # meminfo
DRAM: 2 GiB Elpida DDR3 @ 800MHz
---
Changes in v2:
- Rewrite customised memory info patch to use a command
README | 1 + common/cmd_mem.c | 27 +++++++++++++++++++++++++++ include/common.h | 9 +++++++++ include/config_cmd_all.h | 1 + 4 files changed, 38 insertions(+), 0 deletions(-)
README +1 -0
@@ -840,6 +840,7 @@ The following options need to be configured: CONFIG_CMD_LOADS loads CONFIG_CMD_MD5SUM print md5 message digest (requires CONFIG_CMD_MEMORY and CONFIG_MD5) + CONFIG_CMD_MEMINFO * Display detailed memory information CONFIG_CMD_MEMORY md, mm, nm, mw, cp, cmp, crc, base, loop, loopw, mtest CONFIG_CMD_MISC Misc functions like sleep etc
common/cmd_mem.c +27 -0
@@ -33,6 +33,9 @@#include <dataflash.h> #endif #include <watchdog.h> +#include <linux/compiler.h> + +DECLARE_GLOBAL_DATA_PTR ;static int mod_mem (cmd_tbl_t *,int ,int ,int ,char *const []);
@@ -1203,6 +1206,22 @@ U_BOOT_CMD(#endif +#ifdef CONFIG_CMD_MEMINFO +__weak void board_show_dram (ulong size) +{ +puts ("DRAM: " ); +print_size (size,"\n" ); +} + +static int do_mem_info (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +board_show_dram (gd->ram_size); + +return 0 ; +} +#endif + U_BOOT_CMD( base, 2, 1, do_mem_base, "print or set address offset",
@@ -1243,3 +1262,11 @@ U_BOOT_CMD("[.b, .w, .l] address value delay(ms)" );#endif /* CONFIG_MX_CYCLIC */ + +#ifdef CONFIG_CMD_MEMINFO +U_BOOT_CMD ( + meminfo,3 ,1 , do_mem_info, +"display memory information" , +"" +); +#endif
include/common.h +9 -0
@@ -311,6 +311,15 @@ int mac_read_from_eeprom(void);extern u8 _binary_dt_dtb_start[];/* embedded device tree blob */ int set_cpu_clk_info (void ); +/** +* Show the DRAM size in a board-specific way +* +* This is used by boards to display DRAM information in their own way. +* +* @param size Size of DRAM (which should be displayed along with other info) +*/ +void board_show_dram (ulong size); +/* common/flash.c */ void flash_perror (int );
include/config_cmd_all.h +1 -0
@@ -53,6 +53,7 @@#define CONFIG_CMD_LICENSE /* console license display */ #define CONFIG_CMD_LOADB /* loadb */ #define CONFIG_CMD_LOADS /* loads */ +#define CONFIG_CMD_MEMINFO /* meminfo */ #define CONFIG_CMD_MEMORY /* md mm nm mw cp cmp crc base loop mtest */ #define CONFIG_CMD_MFSL /* FSL support for Microblaze */ #define CONFIG_CMD_MII /* MII support */
Signature · 1 line
1.7.7.3
PATCH v2 8/10 arm: Make interrupts.o and reset.o in libarm also appear in SPL
In reply to Simon GlassFrom: Tom Wai-Hong Tam <[email protected]>
SPL u-boot may call do_reset() which depends on interrupts.o and reset.o. So make them also appear in SPL.
---
Changes in v2: None
arch/arm/lib/Makefile | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +3 -2
@@ -40,14 +40,15 @@ ifndef CONFIG_SPL_BUILD COBJS-y += board.o COBJS-y += bootm.o COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o -COBJS-y += interrupts.o -COBJS-y += reset.o SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o else COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o endif +COBJS-y += interrupts.o +COBJS-y += reset.o + COBJS-y += cache.o COBJS-y += cache-cp15.o
Signature · 1 line
1.7.7.3
PATCH v2 9/10 arm: Move bootstage record for board_init_f() to after arch_cpu_init()
In reply to Simon GlassThe timer may be inited in arch_cpu_init() so it is not safe to make a bootstage mark before this is called. Arrange the code to fix this.
Note: The question was raised as to why we don't keep all archs in sync. PowerPC doesn't have specific bootstage markers at present (although it does use boot progress). I hope that the generic board series will solve this problem in general, but in the meantime this is a real problem, and only in ARM.
We now get a correct time for board_init_f:
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
100,000 100,000 spl_start
848,530 748,530 board_init_f
907,301 58,771 board_init_r
910,478 3,177 board_init---
Changes in v2:
- Rebase to master
- Update commit message
arch/arm/lib/board.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
arch/arm/lib/board.c +9 -2
@@ -232,8 +232,17 @@ int __power_init_board(void)int power_init_board (void ) __attribute__((weak,alias ("__power_init_board" ))); +/* Record the board_init_f() bootstage (after arch_cpu_init()) */ +static int mark_bootstage (void ) +{ +bootstage_mark_name (BOOTSTAGE_ID_START_UBOOT_F ,"board_init_f" ); + +return 0 ; +} +init_fnc_t *init_sequence[] = { arch_cpu_init,/* basic arch cpu dependent setup */ + mark_bootstage, #ifdef CONFIG_OF_CONTROL fdtdec_check_fdt, #endif
@@ -277,8 +286,6 @@ void board_init_f(ulong bootflag)void *new_fdt =NULL ;size_t fdt_size =0 ; -bootstage_mark_name (BOOTSTAGE_ID_START_UBOOT_F ,"board_init_f" ); -/* Pointer is writable since we allocated a register for it */ gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR ) & ~0x07 );/* compiler optimization barrier needed for GCC >= 3.4 */
Signature · 1 line
1.7.7.3
PATCH v2 10/10 arm: Tabify code for MMC initialization
In reply to Simon GlassFrom: Taylor Hutt <[email protected]>
The two modified lines were indented with spaces.
They are now indented with tabs.
---
Changes in v2: None
arch/arm/lib/board.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/board.c +2 -2
@@ -612,8 +612,8 @@ void board_init_r(gd_t *id, ulong dest_addr)#endif #ifdef CONFIG_GENERIC_MMC -puts ("MMC: " ); -mmc_initialize (gd->bd); +puts ("MMC: " ); +mmc_initialize (gd->bd);#endif #ifdef CONFIG_HAS_DATAFLASH
Signature · 1 line
1.7.7.3
PATCH v2 1/10 arm: move flush_dcache_all() to just before disable cache
In reply to Simon GlassHi Simon,
Quoted 31 lines · Simon Glass
From: Arun Mankuzhi <[email protected]>
In Cortex-A15 architecture, when we run cache invalidate the cache clean operation executes automatically.
So if there are any dirty cache lines before disabling the L2 cache these will be synchronized with the main memory wheninvalidate_dcache_all()runs in the last part of U-bootThe two functions after
flush_dcache_allis using the stack. So this data will be on the cache. After disable when invalidate is called the data will be flushed from cache to memory. This corrupts the stack ininvalida_dcache_all. So this change is required to avoid the u-boot hang.So flush has to be done just before clearing
CR_CbitSigned-off-by Arun Mankuzhi <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonearch/arm/lib/cache-cp15.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)arch/arm/lib/cache-cp15.c +0
-0@@ -124,8 +124,11 @@ static void cache_disable(uint32_t cache_bit)return ;/* if disabling data cache, disable mmu too */
arch/arm/lib/cache-cp15.c static void cache_disable(uint32_t cache_bit) · line 134
Quoted 10 lines
arch/arm/lib/cache-cp15.c +4
-1cache_bit |= CR_M; - flush_dcache_all(); } + reg =get_cr (); +cp_delay (); +if (cache_bit == (CR_C |CR_M )) +flush_dcache_all ();set_cr (reg & ~cache_bit); }#endif
Applied the whole series to u-boot-arm/master, thanks!
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/10 arm: move flush_dcache_all() to just before disable cache
In reply to Simon GlassHi,
Quoted 29 lines · Simon Glass
From: Arun Mankuzhi <[email protected]>
In Cortex-A15 architecture, when we run cache invalidate the cache clean operation executes automatically.
So if there are any dirty cache lines before disabling the L2 cache these will be synchronized with the main memory wheninvalidate_dcache_all()runs in the last part of U-bootThe two functions after
flush_dcache_allis using the stack. So this data will be on the cache. After disable when invalidate is called the data will be flushed from cache to memory. This corrupts the stack ininvalida_dcache_all. So this change is required to avoid the u-boot hang.So flush has to be done just before clearing
CR_CbitSigned-off-by Arun Mankuzhi <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonearch/arm/lib/cache-cp15.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)arch/arm/lib/cache-cp15.c +0
-0
arch/arm/lib/cache-cp15.c static void cache_disable(uint32_t cache_bit) · line 132
Quoted 10 lines
arch/arm/lib/cache-cp15.c +4
-1@@ -124,8 +124,11 @@ static void cache_disable(uint32_t cache_bit)return ;/* if disabling data cache, disable mmu too */ cache_bit |=CR_M ; -flush_dcache_all (); } + reg =get_cr (); +cp_delay (); +if (cache_bit == (CR_C |CR_M )) +flush_dcache_all ();set_cr (reg & ~cache_bit);
Sorry for the late question.
But are the two functions that is after flush_dcache_all currently ?
There is only set_cr, which does not use the stack.
Regards,
Sricharan
PATCH v2 1/10 arm: move flush_dcache_all() to just before disable cache
Hi,
Quoted 48 lines · R Sricharan
Hi,
Quoted 30 lines · Simon Glass
From: Arun Mankuzhi <[email protected]>
In Cortex-A15 architecture, when we run cache invalidate the cache clean operation executes automatically.
So if there are any dirty cache lines before disabling the L2 cache these will be synchronized with the main memory wheninvalidate_dcache_all()runs in the last part of U-bootThe two functions after
flush_dcache_allis using the stack. So this data will be on the cache. After disable when invalidate is called the data will be flushed from cache to memory. This corrupts the stack ininvalida_dcache_all. So this change is required to avoid the u-boot hang.So flush has to be done just before clearing
CR_CbitSigned-off-by Arun Mankuzhi <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v2: Nonearch/arm/lib/cache-cp15.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)arch/arm/lib/cache-cp15.c +0
-0arch/arm/lib/cache-cp15.c static void cache_disable(uint32_t cache_bit) · line 132
Quoted 10 lines
arch/arm/lib/cache-cp15.c +4
-1@@ -124,8 +124,11 @@ static void cache_disable(uint32_t cache_bit)return ;/* if disabling data cache, disable mmu too */ cache_bit |=CR_M ; -flush_dcache_all (); } + reg =get_cr (); +cp_delay (); +if (cache_bit == (CR_C |CR_M )) +flush_dcache_all ();set_cr (reg & ~cache_bit);Sorry for the late question.
But are the two functions that is afterflush_dcache_allcurrently ?
Quoted 1 line
There is only
set_cr, which does not use the stack.
I'm not sure I understand that comment, but Arun is copied on this email and may have some further comment.
Quoted 5 lines
Regards,
Sricharan
Regards,
Simon