From: Loic Poulain <loic.poulain@linaro.org>
To: mani@kernel.org, hemantk@codeaurora.org
Cc: linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org,
bbhatt@codeaurora.org, Loic Poulain <loic.poulain@linaro.org>
Subject: [PATCH v2] bus: mhi: Command completion workaround
Date: Wed, 7 Apr 2021 09:28:39 +0200 [thread overview]
Message-ID: <1617780519-1909-1-git-send-email-loic.poulain@linaro.org> (raw)
Some buggy hardwares (e.g sdx24) may report the current command
ring wp pointer instead of the command completion pointer. It's
obviously wrong, causing completion timeout. We can however deal
with that situation by completing the cmd n-1 element, which is
what the device actually completes.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
v2: Fix comment block style.
drivers/bus/mhi/core/main.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index 55aa7db..0f1febf 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -740,6 +740,7 @@ static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl,
{
dma_addr_t ptr = MHI_TRE_GET_EV_PTR(tre);
struct mhi_cmd *cmd_ring = &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING];
+ struct device *dev = &mhi_cntrl->mhi_dev->dev;
struct mhi_ring *mhi_ring = &cmd_ring->ring;
struct mhi_tre *cmd_pkt;
struct mhi_chan *mhi_chan;
@@ -747,6 +748,24 @@ static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl,
cmd_pkt = mhi_to_virtual(mhi_ring, ptr);
+ if (unlikely(cmd_pkt == mhi_ring->wp)) {
+ /*
+ * Some buggy hardwares (e.g sdx24) sometimes report the current
+ * command ring wp pointer instead of the command completion
+ * pointer. It's obviously wrong, causing completion timeout. We
+ * can however deal with that situation by completing the cmd
+ * n-1 element.
+ */
+ void *ring_ptr = (void *)cmd_pkt - mhi_ring->el_size;
+
+ if (ring_ptr < mhi_ring->base)
+ ring_ptr += mhi_ring->len;
+
+ cmd_pkt = ring_ptr;
+
+ dev_warn(dev, "Bad completion pointer (ptr == ring_wp)\n");
+ }
+
chan = MHI_TRE_GET_CMD_CHID(cmd_pkt);
mhi_chan = &mhi_cntrl->mhi_chan[chan];
write_lock_bh(&mhi_chan->lock);
--
2.7.4
reply other threads:[~2021-04-07 7:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1617780519-1909-1-git-send-email-loic.poulain@linaro.org \
--to=loic.poulain@linaro.org \
--cc=bbhatt@codeaurora.org \
--cc=hemantk@codeaurora.org \
--cc=jhugo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=mani@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).