arm: socfpga: mailbox: Refactor mailbox timeout event handling
Add miliseconds delay when waiting for mailbox event to happen before timeout. This will ensure the timeout duration is predictive. Signed-off-by: Chee Hong Ang <chee.hong.ang@intel.com> Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
This commit is contained in:
committed by
Ley Foon Tan
parent
e2afbee50c
commit
e3fca5072b
@@ -29,13 +29,14 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
static __always_inline int mbox_polling_resp(u32 rout)
|
static __always_inline int mbox_polling_resp(u32 rout)
|
||||||
{
|
{
|
||||||
u32 rin;
|
u32 rin;
|
||||||
unsigned long i = ~0;
|
unsigned long i = 2000;
|
||||||
|
|
||||||
while (i) {
|
while (i) {
|
||||||
rin = MBOX_READL(MBOX_RIN);
|
rin = MBOX_READL(MBOX_RIN);
|
||||||
if (rout != rin)
|
if (rout != rin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
udelay(1000);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,11 +177,15 @@ static __always_inline int mbox_send_cmd_common(u8 id, u32 cmd, u8 is_indirect,
|
|||||||
MBOX_WRITEL(1, MBOX_DOORBELL_TO_SDM);
|
MBOX_WRITEL(1, MBOX_DOORBELL_TO_SDM);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = ~0;
|
ret = 1000;
|
||||||
|
|
||||||
/* Wait for doorbell from SDM */
|
/* Wait for doorbell from SDM */
|
||||||
while (!MBOX_READL(MBOX_DOORBELL_FROM_SDM) && ret--)
|
do {
|
||||||
;
|
if (MBOX_READL(MBOX_DOORBELL_FROM_SDM))
|
||||||
|
break;
|
||||||
|
udelay(1000);
|
||||||
|
} while (--ret);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user