All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chee Hong Ang <chee.hong.ang@intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH v1 1/5] arm: socfpga: mailbox: Refactor mailbox timeout event handling
Date: Wed, 12 Aug 2020 09:56:21 +0800	[thread overview]
Message-ID: <20200812015625.40790-2-chee.hong.ang@intel.com> (raw)
In-Reply-To: <20200812015625.40790-1-chee.hong.ang@intel.com>

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;
 
-- 
2.19.0

  reply	other threads:[~2020-08-12  1:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12  1:56 [PATCH v1 0/5] SoCFPGA mailbox driver fixes and enhancements Chee Hong Ang
2020-08-12  1:56 ` Chee Hong Ang [this message]
2020-09-04  9:38   ` [PATCH v1 1/5] arm: socfpga: mailbox: Refactor mailbox timeout event handling Tan, Ley Foon
2020-08-12  1:56 ` [PATCH v1 2/5] arm: socfpga: mailbox: Always read mailbox responses before returning status Chee Hong Ang
2020-09-04  9:39   ` Tan, Ley Foon
2020-08-12  1:56 ` [PATCH v1 3/5] arm: socfpga: mailbox: Support sending large mailbox command Chee Hong Ang
2020-09-04  9:43   ` Tan, Ley Foon
2020-08-12  1:56 ` [PATCH v1 4/5] arm: socfpga: mailbox: Update mailbox response codes Chee Hong Ang
2020-08-12  1:56 ` [PATCH v1 5/5] arm: socfpga: mailbox: Add mailbox retry support Chee Hong Ang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200812015625.40790-2-chee.hong.ang@intel.com \
    --to=chee.hong.ang@intel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.