Commit d96e7cda authored by Chee Hong Ang's avatar Chee Hong Ang Committed by Abdul Halim, Muhammad Hadi Asyrafi
Browse files

intel: mailbox: Ensure time out duration is predictive



For each count down of time out counter, wait for number of
miliseconds to ensure the time out duration is predictive.
Signed-off-by: default avatarChee Hong Ang <chee.hong.ang@intel.com>
Change-Id: I0e92dd1ef1da0ef504ec86472cf0d3c88528930b
parent 6d9f9f5e
...@@ -101,6 +101,8 @@ static const gicv2_driver_data_t plat_gicv2_gic_data = { ...@@ -101,6 +101,8 @@ static const gicv2_driver_data_t plat_gicv2_gic_data = {
******************************************************************************/ ******************************************************************************/
void bl31_platform_setup(void) void bl31_platform_setup(void)
{ {
socfpga_delay_timer_init();
/* Initialize the gic cpu and distributor interfaces */ /* Initialize the gic cpu and distributor interfaces */
gicv2_driver_init(&plat_gicv2_gic_data); gicv2_driver_init(&plat_gicv2_gic_data);
gicv2_distif_init(); gicv2_distif_init();
......
...@@ -25,7 +25,8 @@ PLAT_BL_COMMON_SOURCES := \ ...@@ -25,7 +25,8 @@ PLAT_BL_COMMON_SOURCES := \
lib/xlat_tables/aarch64/xlat_tables.c \ lib/xlat_tables/aarch64/xlat_tables.c \
lib/xlat_tables/xlat_tables_common.c \ lib/xlat_tables/xlat_tables_common.c \
plat/intel/soc/common/aarch64/platform_common.c \ plat/intel/soc/common/aarch64/platform_common.c \
plat/intel/soc/common/aarch64/plat_helpers.S plat/intel/soc/common/aarch64/plat_helpers.S \
plat/intel/soc/common/socfpga_delay_timer.c
BL2_SOURCES += \ BL2_SOURCES += \
common/desc_image_load.c \ common/desc_image_load.c \
...@@ -44,7 +45,6 @@ BL2_SOURCES += \ ...@@ -44,7 +45,6 @@ BL2_SOURCES += \
plat/intel/soc/agilex/soc/agilex_mmc.c \ plat/intel/soc/agilex/soc/agilex_mmc.c \
plat/intel/soc/agilex/soc/agilex_pinmux.c \ plat/intel/soc/agilex/soc/agilex_pinmux.c \
plat/intel/soc/common/bl2_plat_mem_params_desc.c \ plat/intel/soc/common/bl2_plat_mem_params_desc.c \
plat/intel/soc/common/socfpga_delay_timer.c \
plat/intel/soc/common/socfpga_image_load.c \ plat/intel/soc/common/socfpga_image_load.c \
plat/intel/soc/common/socfpga_storage.c \ plat/intel/soc/common/socfpga_storage.c \
plat/intel/soc/common/soc/socfpga_emac.c \ plat/intel/soc/common/soc/socfpga_emac.c \
......
...@@ -89,7 +89,7 @@ int mailbox_read_response(uint32_t *job_id, uint32_t *response, int resp_len) ...@@ -89,7 +89,7 @@ int mailbox_read_response(uint32_t *job_id, uint32_t *response, int resp_len)
int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response, int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response,
int resp_len) int resp_len)
{ {
int timeout = 0xFFFFFF; uint32_t timeout = 40U;
int rin = 0; int rin = 0;
int rout = 0; int rout = 0;
int resp_data = 0; int resp_data = 0;
...@@ -97,13 +97,15 @@ int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response, ...@@ -97,13 +97,15 @@ int mailbox_poll_response(uint32_t job_id, int urgent, uint32_t *response,
while (1) { while (1) {
while (timeout > 0 && do {
!(mmio_read_32(MBOX_OFFSET + if (mmio_read_32(MBOX_OFFSET + MBOX_DOORBELL_FROM_SDM)
MBOX_DOORBELL_FROM_SDM) & 1)) { & 1) {
timeout--; break;
} }
mdelay(25);
} while (--timeout != 0U);
if (!timeout) { if (timeout == 0U) {
INFO("Timed out waiting for SDM\n"); INFO("Timed out waiting for SDM\n");
return MBOX_TIMEOUT; return MBOX_TIMEOUT;
} }
...@@ -164,7 +166,7 @@ int iterate_resp(int mbox_resp_len, uint32_t *resp_buf, int resp_len) ...@@ -164,7 +166,7 @@ int iterate_resp(int mbox_resp_len, uint32_t *resp_buf, int resp_len)
int rout = mmio_read_32(MBOX_OFFSET + MBOX_ROUT); int rout = mmio_read_32(MBOX_OFFSET + MBOX_ROUT);
while (mbox_resp_len > 0) { while (mbox_resp_len > 0) {
timeout = 0xFFFFFF; timeout = 40;
mbox_resp_len--; mbox_resp_len--;
resp_data = mmio_read_32(MBOX_OFFSET + resp_data = mmio_read_32(MBOX_OFFSET +
MBOX_RESP_BUFFER + MBOX_RESP_BUFFER +
...@@ -180,11 +182,16 @@ int iterate_resp(int mbox_resp_len, uint32_t *resp_buf, int resp_len) ...@@ -180,11 +182,16 @@ int iterate_resp(int mbox_resp_len, uint32_t *resp_buf, int resp_len)
mmio_write_32(MBOX_OFFSET + MBOX_ROUT, rout); mmio_write_32(MBOX_OFFSET + MBOX_ROUT, rout);
do { do {
timeout--;
rin = mmio_read_32(MBOX_OFFSET + MBOX_RIN); rin = mmio_read_32(MBOX_OFFSET + MBOX_RIN);
} while ((rout == rin) && (mbox_resp_len > 0) && (timeout > 0)); if (rout == rin) {
mdelay(25);
} else {
break;
}
timeout--;
} while ((mbox_resp_len > 0) && (timeout != 0U));
if (timeout == 0) { if (timeout == 0U) {
INFO("Timed out waiting for SDM\n"); INFO("Timed out waiting for SDM\n");
return MBOX_TIMEOUT; return MBOX_TIMEOUT;
} }
......
...@@ -109,6 +109,8 @@ static const gicv2_driver_data_t plat_gicv2_gic_data = { ...@@ -109,6 +109,8 @@ static const gicv2_driver_data_t plat_gicv2_gic_data = {
******************************************************************************/ ******************************************************************************/
void bl31_platform_setup(void) void bl31_platform_setup(void)
{ {
socfpga_delay_timer_init();
/* Initialize the gic cpu and distributor interfaces */ /* Initialize the gic cpu and distributor interfaces */
gicv2_driver_init(&plat_gicv2_gic_data); gicv2_driver_init(&plat_gicv2_gic_data);
gicv2_distif_init(); gicv2_distif_init();
......
...@@ -25,7 +25,8 @@ PLAT_BL_COMMON_SOURCES := \ ...@@ -25,7 +25,8 @@ PLAT_BL_COMMON_SOURCES := \
lib/xlat_tables/aarch64/xlat_tables.c \ lib/xlat_tables/aarch64/xlat_tables.c \
lib/xlat_tables/xlat_tables_common.c \ lib/xlat_tables/xlat_tables_common.c \
plat/intel/soc/common/aarch64/platform_common.c \ plat/intel/soc/common/aarch64/platform_common.c \
plat/intel/soc/common/aarch64/plat_helpers.S plat/intel/soc/common/aarch64/plat_helpers.S \
plat/intel/soc/common/socfpga_delay_timer.c
BL2_SOURCES += \ BL2_SOURCES += \
common/desc_image_load.c \ common/desc_image_load.c \
...@@ -43,7 +44,6 @@ BL2_SOURCES += \ ...@@ -43,7 +44,6 @@ BL2_SOURCES += \
plat/intel/soc/stratix10/soc/s10_memory_controller.c \ plat/intel/soc/stratix10/soc/s10_memory_controller.c \
plat/intel/soc/stratix10/soc/s10_pinmux.c \ plat/intel/soc/stratix10/soc/s10_pinmux.c \
plat/intel/soc/common/bl2_plat_mem_params_desc.c \ plat/intel/soc/common/bl2_plat_mem_params_desc.c \
plat/intel/soc/common/socfpga_delay_timer.c \
plat/intel/soc/common/socfpga_image_load.c \ plat/intel/soc/common/socfpga_image_load.c \
plat/intel/soc/common/socfpga_storage.c \ plat/intel/soc/common/socfpga_storage.c \
plat/intel/soc/common/soc/socfpga_emac.c \ plat/intel/soc/common/soc/socfpga_emac.c \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment