aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbdul Halim, Muhammad Hadi Asyrafi <muhammad.hadi.asyrafi.abdul.halim@intel.com>2020-06-02 01:05:24 +0800
committerAbdul Halim, Muhammad Hadi Asyrafi <muhammad.hadi.asyrafi.abdul.halim@intel.com>2020-10-27 11:17:41 +0800
commit4978bc28325f5337bac5b2a2df1b772409628cb2 (patch)
treeca8e1aa44542a09e42cf562ce8629681715ca8fe
parentd96e7cda8a9f84ca8d0054bc1c86aabcb27db1d1 (diff)
downloadplatform_external_arm-trusted-firmware-4978bc28325f5337bac5b2a2df1b772409628cb2.tar.gz
platform_external_arm-trusted-firmware-4978bc28325f5337bac5b2a2df1b772409628cb2.tar.bz2
platform_external_arm-trusted-firmware-4978bc28325f5337bac5b2a2df1b772409628cb2.zip
intel: mailbox: Use retry count in mailbox poll
Change the main loop inside mailbox poll function from while(1) to a retry counter named sdm_loop. This is to limit the maximum possible looping of the function and prevent unexpected behaviour. Signed-off-by: Abdul Halim, Muhammad Hadi Asyrafi <muhammad.hadi.asyrafi.abdul.halim@intel.com> Change-Id: I63afad958fe5f656f6333b60d5a8b4c0ada3b23d
-rw-r--r--plat/intel/soc/common/soc/socfpga_mailbox.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/plat/intel/soc/common/soc/socfpga_mailbox.c b/plat/intel/soc/common/soc/socfpga_mailbox.c
index 984aa9c6e..ddfe34cd0 100644
--- a/plat/intel/soc/common/soc/socfpga_mailbox.c
+++ b/plat/intel/soc/common/soc/socfpga_mailbox.c
@@ -90,12 +90,13 @@ int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response,
int resp_len)
{
uint32_t timeout = 40U;
+ uint32_t sdm_loop = 255U;
int rin = 0;
int rout = 0;
int resp_data = 0;
int ret_resp_len;
- while (1) {
+ while (sdm_loop != 0U) {
do {
if (mmio_read_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM)
@@ -106,8 +107,7 @@ int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response,
} while (--timeout != 0U);
if (timeout == 0U) {
- INFO("Timed out waiting for SDM\n");
- return MBOX_TIMEOUT;
+ break;
}
mmio_write_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM, 0);
@@ -155,7 +155,12 @@ int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response,
return ret_resp_len;
}
+
+ sdm_loop--;
}
+
+ INFO("Timed out waiting for SDM\n");
+ return MBOX_TIMEOUT;
}
int iterate_resp(int mbox_resp_len, uint32_t *resp_buf, int resp_len)