summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2020-05-06 14:02:44 +0800
committerJi Luo <ji.luo@nxp.com>2020-05-07 17:36:44 +0800
commit3432f444e283ccd83c7a28aa58ff1c5c67d5167f (patch)
tree58eac433a5c07c2adc1dde70134fe5cd5e9c4bfb
parentcbf1114bb7f3bd1d54040e26f96b2d74860fea81 (diff)
MA-17076 plat: imx8: Only save data section for cold reboot
In some cases, the bl31 won't be reloaded when spl is not supported, commit 17de039 adds the save/restore data section to fix boot issues which is caused by the dirty data in data section of previous boot. However, sometimes the backup data section in dram won't be erased totally in board cold reboot, it will be restored and modify the 'correct' data section which will cause the board hang. This commit uses a global flag 'data_section_restore_flag' which is initialized as '0x1' and should be stored in data section to indicate the save/restore behavior. Test: cold/warm reboot on imx8qm/imx8qxp. Signed-off-by: Ji Luo <ji.luo@nxp.com>
-rw-r--r--plat/imx/imx8dxl/imx8dxl_bl31_setup.c12
-rw-r--r--plat/imx/imx8qm/imx8qm_bl31_setup.c12
-rw-r--r--plat/imx/imx8qx/imx8qx_bl31_setup.c12
3 files changed, 18 insertions, 18 deletions
diff --git a/plat/imx/imx8dxl/imx8dxl_bl31_setup.c b/plat/imx/imx8dxl/imx8dxl_bl31_setup.c
index 62cbdc1a..33af33d7 100644
--- a/plat/imx/imx8dxl/imx8dxl_bl31_setup.c
+++ b/plat/imx/imx8dxl/imx8dxl_bl31_setup.c
@@ -29,8 +29,8 @@
#include <imx_sip_svc.h>
#include <string.h>
-#define DATA_SECTION_RESTORE_FLAG 0x11223344
#define TRUSTY_PARAMS_LEN_BYTES (4096*2)
+int data_section_restore_flag = 0x1;
IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START);
IMPORT_SYM(unsigned long, __COHERENT_RAM_END__, BL31_COHERENT_RAM_END);
@@ -380,17 +380,17 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3)
{
unsigned int count = (BL31_DATA_END - BL31_DATA_START) / 4;
- unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START) - 0x4);
+ unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START));
unsigned *ptr = (unsigned int *)BL31_DATA_START;
int i;
- if (*data != DATA_SECTION_RESTORE_FLAG) {
- *data = DATA_SECTION_RESTORE_FLAG;
+ if (data_section_restore_flag == 0x1) {
+ data_section_restore_flag = 0x2;
for (i = 0; i < count; i++)
- *(++data) = *(ptr++);
+ *(data++) = *(ptr++);
} else {
for (i = 0; i < count; i++)
- *(ptr++) = *(++data);
+ *(ptr++) = *(data++);
}
#if DEBUG_CONSOLE
diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c
index 864a8802..59b27d32 100644
--- a/plat/imx/imx8qm/imx8qm_bl31_setup.c
+++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c
@@ -29,8 +29,8 @@
#include <imx_sip_svc.h>
#include <string.h>
-#define DATA_SECTION_RESTORE_FLAG 0x11223344
#define TRUSTY_PARAMS_LEN_BYTES (4096*2)
+int data_section_restore_flag = 0x1;
IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START);
IMPORT_SYM(unsigned long, __COHERENT_RAM_END__, BL31_COHERENT_RAM_END);
@@ -402,17 +402,17 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3)
{
unsigned int count = (BL31_DATA_END - BL31_DATA_START) / 4;
- unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START) - 0x4);
+ unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START));
unsigned *ptr = (unsigned int *)BL31_DATA_START;
int i;
- if (*data != DATA_SECTION_RESTORE_FLAG) {
- *data = DATA_SECTION_RESTORE_FLAG;
+ if (data_section_restore_flag == 0x1) {
+ data_section_restore_flag = 0x2;
for (i = 0; i < count; i++)
- *(++data) = *(ptr++);
+ *(data++) = *(ptr++);
} else {
for (i = 0; i < count; i++)
- *(ptr++) = *(++data);
+ *(ptr++) = *(data++);
}
#if DEBUG_CONSOLE
diff --git a/plat/imx/imx8qx/imx8qx_bl31_setup.c b/plat/imx/imx8qx/imx8qx_bl31_setup.c
index 9829e527..7411f436 100644
--- a/plat/imx/imx8qx/imx8qx_bl31_setup.c
+++ b/plat/imx/imx8qx/imx8qx_bl31_setup.c
@@ -29,8 +29,8 @@
#include <imx_sip_svc.h>
#include <string.h>
-#define DATA_SECTION_RESTORE_FLAG 0x11223344
#define TRUSTY_PARAMS_LEN_BYTES (4096*2)
+int data_section_restore_flag = 0x1;
IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START);
IMPORT_SYM(unsigned long, __COHERENT_RAM_END__, BL31_COHERENT_RAM_END);
@@ -380,17 +380,17 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3)
{
unsigned int count = (BL31_DATA_END - BL31_DATA_START) / 4;
- unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START) - 0x4);
+ unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START));
unsigned *ptr = (unsigned int *)BL31_DATA_START;
int i;
- if (*data != DATA_SECTION_RESTORE_FLAG) {
- *data = DATA_SECTION_RESTORE_FLAG;
+ if (data_section_restore_flag == 0x1) {
+ data_section_restore_flag = 0x2;
for (i = 0; i < count; i++)
- *(++data) = *(ptr++);
+ *(data++) = *(ptr++);
} else {
for (i = 0; i < count; i++)
- *(ptr++) = *(++data);
+ *(ptr++) = *(data++);
}
#if DEBUG_CONSOLE