diff options
author | Leonard Crestez <leonard.crestez@nxp.com> | 2018-01-18 13:40:29 +0200 |
---|---|---|
committer | Abel Vesa <abel.vesa@nxp.com> | 2018-06-11 10:33:02 +0300 |
commit | 06a8c7dbdff87894dd11458225b3b43f19a2c62b (patch) | |
tree | e8ff8940cf5a7232f839b7bbd403f2815250cfe2 /plat/imx/common | |
parent | d4a858c7e5b37dc40a9110485db4683779b5fcb0 (diff) |
imx: Add bakery_lock to sc_call_rpc
It is possible for multiple cores to do attempt RPC calls and without
locking this can result in corrupt messages on the SCFW side. This is
particularly visible with cpuidle.
This needs to be a bakery_lock because on the wakeup path
psci_cpu_suspend_finish calls the platform's pwr_domain_suspend_finish
before enabling the data cache.
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Anson Huang <anson.huang@nxp.com>
Diffstat (limited to 'plat/imx/common')
-rw-r--r-- | plat/imx/common/sci/ipc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/plat/imx/common/sci/ipc.c b/plat/imx/common/sci/ipc.c index 664350bd..b75766d1 100644 --- a/plat/imx/common/sci/ipc.c +++ b/plat/imx/common/sci/ipc.c @@ -35,11 +35,21 @@ #include "mx8_mu.h" +#include <bakery_lock.h> +DEFINE_BAKERY_LOCK(sc_ipc_bakery_lock); +#define sc_ipc_lock_init() bakery_lock_init(&sc_ipc_bakery_lock) +#define sc_ipc_lock() bakery_lock_get(&sc_ipc_bakery_lock) +#define sc_ipc_unlock() bakery_lock_release(&sc_ipc_bakery_lock) + void sc_call_rpc(sc_ipc_t ipc, sc_rpc_msg_t *msg, bool no_resp) { + sc_ipc_lock(); + sc_ipc_write(ipc, msg); if (!no_resp) sc_ipc_read(ipc, msg); + + sc_ipc_unlock(); } sc_err_t sc_ipc_open(sc_ipc_t *ipc, sc_ipc_id_t id) @@ -51,6 +61,8 @@ sc_err_t sc_ipc_open(sc_ipc_t *ipc, sc_ipc_id_t id) if ((ipc == NULL) || (base == 0)) return SC_ERR_IPC; + sc_ipc_lock_init(); + /* Init MU */ MU_Init(base); |