diff options
author | Peng Fan <peng.fan@nxp.com> | 2018-06-26 20:33:01 +0800 |
---|---|---|
committer | Anson Huang <Anson.Huang@nxp.com> | 2019-12-13 10:41:30 +0800 |
commit | 9b8cf58deee79eccde5c129b0aec9b4deaacb1ab (patch) | |
tree | b0b67d56cc3aab84cc4be5a8a027fbe74d0e8abe | |
parent | 6c03b183c37e476075367e63de5a6d3f245541af (diff) |
imx8: postpone moving resources to non-secure partition
With flash_uboot_cm4ddr in imx-mkimage, the m4 code will access ddr.
However after m4 core moved to non-secure partition, the ddr memory
is still in secure partition. Then m4 core will fault.
So postpone moving resources including m4 core, until other resources,
such as memory/pin moved to non-secure partition.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit 1c8ce0ad5f583ec41026d4ab5bef622f1b45aecd)
(cherry picked from commit 5b026e05b8f71b3d86da0953c5ca196d5ba5cc66)
-rw-r--r-- | plat/imx/imx8qm/imx8qm_bl31_setup.c | 102 | ||||
-rw-r--r-- | plat/imx/imx8qx/imx8qx_bl31_setup.c | 68 |
2 files changed, 85 insertions, 85 deletions
diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c index c76de646..95e06a8a 100644 --- a/plat/imx/imx8qm/imx8qm_bl31_setup.c +++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c @@ -178,6 +178,57 @@ void mx8_partition_resources(void) secure_rsrcs[i], err); } + /* + * sc_rm_set_peripheral_permissions + * sc_rm_set_memreg_permissions + * sc_rm_set_pin_movable + */ + + for (mr = 0; mr < 64; mr++) { + owned = sc_rm_is_memreg_owned(ipc_handle, mr); + if (owned) { + err = sc_rm_get_memreg_info(ipc_handle, mr, &start, &end); + if (err) + ERROR("Memreg get info failed, %u\n", mr); + NOTICE("Memreg %u 0x%llx -- 0x%llx\n", mr, start, end); + if (BL31_BASE >= start && (BL31_LIMIT - 1) <= end) { + mr_record = mr; /* Record the mr for ATF running */ + } else { + err = sc_rm_assign_memreg(ipc_handle, os_part, mr); + if (err) + ERROR("Memreg assign failed, 0x%llx -- 0x%llx, \ + err %d\n", start, end, err); + } + } + } + + if (mr_record != 64) { + err = sc_rm_get_memreg_info(ipc_handle, mr_record, &start, &end); + if (err) + ERROR("Memreg get info failed, %u\n", mr_record); + if ((BL31_LIMIT - 1) < end) { + err = sc_rm_memreg_alloc(ipc_handle, &mr, BL31_LIMIT, end); + if (err) + ERROR("sc_rm_memreg_alloc failed, 0x%llx -- 0x%llx\n", + (sc_faddr_t)BL31_LIMIT, end); + err = sc_rm_assign_memreg(ipc_handle, os_part, mr); + if (err) + ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", + (sc_faddr_t)BL31_LIMIT, end); + } + + if (start < (BL31_BASE - 1)) { + err = sc_rm_memreg_alloc(ipc_handle, &mr, start, BL31_BASE - 1); + if (err) + ERROR("sc_rm_memreg_alloc failed, 0x%llx -- 0x%llx\n", + start, (sc_faddr_t)BL31_BASE - 1); + err = sc_rm_assign_memreg(ipc_handle, os_part, mr); + if (err) + ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", + start, (sc_faddr_t)BL31_BASE - 1); + } + } + owned = sc_rm_is_resource_owned(ipc_handle, SC_R_M4_0_PID0); if (owned) { err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, @@ -232,57 +283,6 @@ void mx8_partition_resources(void) SC_R_M4_1_PID0, err); } - /* - * sc_rm_set_peripheral_permissions - * sc_rm_set_memreg_permissions - * sc_rm_set_pin_movable - */ - - for (mr = 0; mr < 64; mr++) { - owned = sc_rm_is_memreg_owned(ipc_handle, mr); - if (owned) { - err = sc_rm_get_memreg_info(ipc_handle, mr, &start, &end); - if (err) - ERROR("Memreg get info failed, %u\n", mr); - NOTICE("Memreg %u 0x%llx -- 0x%llx\n", mr, start, end); - if (BL31_BASE >= start && (BL31_LIMIT - 1) <= end) { - mr_record = mr; /* Record the mr for ATF running */ - } else { - err = sc_rm_assign_memreg(ipc_handle, os_part, mr); - if (err) - ERROR("Memreg assign failed, 0x%llx -- 0x%llx, \ - err %d\n", start, end, err); - } - } - } - - if (mr_record != 64) { - err = sc_rm_get_memreg_info(ipc_handle, mr_record, &start, &end); - if (err) - ERROR("Memreg get info failed, %u\n", mr_record); - if ((BL31_LIMIT - 1) < end) { - err = sc_rm_memreg_alloc(ipc_handle, &mr, BL31_LIMIT, end); - if (err) - ERROR("sc_rm_memreg_alloc failed, 0x%llx -- 0x%llx\n", - (sc_faddr_t)BL31_LIMIT, end); - err = sc_rm_assign_memreg(ipc_handle, os_part, mr); - if (err) - ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", - (sc_faddr_t)BL31_LIMIT, end); - } - - if (start < (BL31_BASE - 1)) { - err = sc_rm_memreg_alloc(ipc_handle, &mr, start, BL31_BASE - 1); - if (err) - ERROR("sc_rm_memreg_alloc failed, 0x%llx -- 0x%llx\n", - start, (sc_faddr_t)BL31_BASE - 1); - err = sc_rm_assign_memreg(ipc_handle, os_part, mr); - if (err) - ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", - start, (sc_faddr_t)BL31_BASE - 1); - } - } - if (err) NOTICE("Partitioning Failed\n"); else diff --git a/plat/imx/imx8qx/imx8qx_bl31_setup.c b/plat/imx/imx8qx/imx8qx_bl31_setup.c index f9f3b1a2..f71a7bb5 100644 --- a/plat/imx/imx8qx/imx8qx_bl31_setup.c +++ b/plat/imx/imx8qx/imx8qx_bl31_setup.c @@ -179,40 +179,6 @@ void imx8_partition_resources(void) secure_rsrcs[i], err); } - owned = sc_rm_is_resource_owned(ipc_handle, SC_R_M4_0_PID0); - if (owned) { - err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, - SC_R_M4_0_PID0, false); - if (err) - ERROR("sc_rm_set_resource_movable: rsrc %u, ret %u\n", - SC_R_M4_0_PID0, err); - } - - /* move all movable resources and pins to non-secure partition */ - err = sc_rm_move_all(ipc_handle, secure_part, os_part, true, true); - if (err) - ERROR("sc_rm_move_all: %u\n", err); - if (owned) { - err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, - SC_R_M4_0_PID0, true); - if (err) - ERROR("sc_rm_set_resource_movable: rsrc %u, ret %u\n", - SC_R_M4_0_PID0, err); - err = sc_rm_assign_resource(ipc_handle, os_part, SC_R_M4_0_PID0); - if (err) - ERROR("sc_rm_assign_resource: rsrc %u, ret %u\n", - SC_R_M4_0_PID0, err); - } - - /* iterate through peripherals to give NS OS part access */ - for (i = 0; i < ARRAY_SIZE(ns_access_allowed); i++) { - err = sc_rm_set_peripheral_permissions(ipc_handle, - ns_access_allowed[i], os_part, SC_RM_PERM_FULL); - if (err) - ERROR("sc_rm_set_peripheral_permissions: rsrc %u, \ - ret %u\n", ns_access_allowed[i], err); - } - /* * sc_rm_set_peripheral_permissions * sc_rm_set_memreg_permissions @@ -264,6 +230,40 @@ void imx8_partition_resources(void) } } + owned = sc_rm_is_resource_owned(ipc_handle, SC_R_M4_0_PID0); + if (owned) { + err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, + SC_R_M4_0_PID0, false); + if (err) + ERROR("sc_rm_set_resource_movable: rsrc %u, ret %u\n", + SC_R_M4_0_PID0, err); + } + + /* move all movable resources and pins to non-secure partition */ + err = sc_rm_move_all(ipc_handle, secure_part, os_part, true, true); + if (err) + ERROR("sc_rm_move_all: %u\n", err); + if (owned) { + err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, + SC_R_M4_0_PID0, true); + if (err) + ERROR("sc_rm_set_resource_movable: rsrc %u, ret %u\n", + SC_R_M4_0_PID0, err); + err = sc_rm_assign_resource(ipc_handle, os_part, SC_R_M4_0_PID0); + if (err) + ERROR("sc_rm_assign_resource: rsrc %u, ret %u\n", + SC_R_M4_0_PID0, err); + } + + /* iterate through peripherals to give NS OS part access */ + for (i = 0; i < ARRAY_SIZE(ns_access_allowed); i++) { + err = sc_rm_set_peripheral_permissions(ipc_handle, + ns_access_allowed[i], os_part, SC_RM_PERM_FULL); + if (err) + ERROR("sc_rm_set_peripheral_permissions: rsrc %u, \ + ret %u\n", ns_access_allowed[i], err); + } + if (err) NOTICE("Partitioning Failed\n"); else |