Message ID | 20200812015625.40790-2-chee.hong.ang@intel.com |
---|---|
State | Accepted |
Commit | e3fca5072bf78f7fd7eeab027d6e83bb555def9e |
Delegated to: | Simon Goldschmidt |
Headers | show |
Series | SoCFPGA mailbox driver fixes and enhancements | expand |
> -----Original Message----- > From: Ang, Chee Hong <chee.hong.ang@intel.com> > Sent: Wednesday, August 12, 2020 9:56 AM > To: u-boot@lists.denx.de > Cc: Marek Vasut <marex@denx.de>; Simon Goldschmidt > <simon.k.r.goldschmidt@gmail.com>; Tom Rini <trini@konsulko.com>; See, > Chin Liang <chin.liang.see@intel.com>; Tan, Ley Foon > <ley.foon.tan@intel.com>; Ang, Chee Hong <chee.hong.ang@intel.com>; > Chee, Tien Fong <tien.fong.chee@intel.com>; Lim, Elly Siew Chin > <elly.siew.chin.lim@intel.com> > Subject: [PATCH v1 1/5] 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> > --- > arch/arm/mach-socfpga/mailbox_s10.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach- > socfpga/mailbox_s10.c > index f30e7f80a2..729d9b04fa 100644 > --- a/arch/arm/mach-socfpga/mailbox_s10.c > +++ b/arch/arm/mach-socfpga/mailbox_s10.c > @@ -29,13 +29,14 @@ DECLARE_GLOBAL_DATA_PTR; static > __always_inline int mbox_polling_resp(u32 rout) { > u32 rin; > - unsigned long i = ~0; > + unsigned long i = 2000; > > while (i) { > rin = MBOX_READL(MBOX_RIN); > if (rout != rin) > return 0; > > + udelay(1000); > 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); > > while (1) { > - ret = ~0; > + ret = 1000; > > /* 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) > return -ETIMEDOUT; > Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c index f30e7f80a2..729d9b04fa 100644 --- a/arch/arm/mach-socfpga/mailbox_s10.c +++ b/arch/arm/mach-socfpga/mailbox_s10.c @@ -29,13 +29,14 @@ DECLARE_GLOBAL_DATA_PTR; static __always_inline int mbox_polling_resp(u32 rout) { u32 rin; - unsigned long i = ~0; + unsigned long i = 2000; while (i) { rin = MBOX_READL(MBOX_RIN); if (rout != rin) return 0; + udelay(1000); 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); while (1) { - ret = ~0; + ret = 1000; /* 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) return -ETIMEDOUT;
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> --- arch/arm/mach-socfpga/mailbox_s10.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)