From: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: Wolfram Sang <wsa@the-dreams.de>,
Rajendra Nayak <rnayak@codeaurora.org>,
swboyd@chromium.org, Akash Asthana <akashast@codeaurora.org>,
Alok Chauhan <alokc@codeaurora.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Girish Mahadevan <girishm@codeaurora.org>,
Karthikeyan Ramasubramanian <kramasub@codeaurora.org>,
Wolfram Sang <wsa@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: i2c-qcom-geni: Fix DMA transfer race
Date: Tue, 21 Jul 2020 11:07:29 +0530 [thread overview]
Message-ID: <76940ce4659232e9adc073b4065d0e9b@codeaurora.org> (raw)
In-Reply-To: <20200720172448.1.I7efdf6efaa6edadbb690196cd4fbe3392a582c89@changeid>
On 2020-07-21 05:54, Douglas Anderson wrote:
> When I have KASAN enabled on my kernel and I start stressing the
> touchscreen my system tends to hang. The touchscreen is one of the
> only things that does a lot of big i2c transfers and ends up hitting
> the DMA paths in the geni i2c driver. It appears that KASAN adds
> enough delay in my system to tickle a race condition in the DMA setup
> code.
>
> When the system hangs, I found that it was running the geni_i2c_irq()
> over and over again. It had these:
>
> m_stat = 0x04000080
> rx_st = 0x30000011
> dm_tx_st = 0x00000000
> dm_rx_st = 0x00000000
> dma = 0x00000001
>
> Notably we're in DMA mode but are getting M_RX_IRQ_EN and
> M_RX_FIFO_WATERMARK_EN over and over again.
>
> Putting some traces in geni_i2c_rx_one_msg() showed that when we
> failed we were getting to the start of geni_i2c_rx_one_msg() but were
> never executing geni_se_rx_dma_prep().
>
> I believe that the problem here is that we are writing the transfer
> length and setting up the geni command before we run
> geni_se_rx_dma_prep(). If a transfer makes it far enough before we do
> that then we get into the state I have observed. Let's change the
> order, which seems to work fine.
>
> Fixes: 37692de5d523 ("i2c: i2c-qcom-geni: Add bus driver for the
> Qualcomm GENI I2C controller")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
> drivers/i2c/busses/i2c-qcom-geni.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c
> b/drivers/i2c/busses/i2c-qcom-geni.c
> index 18d1e4fd4cf3..21e27f10510a 100644
> --- a/drivers/i2c/busses/i2c-qcom-geni.c
> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
> @@ -366,15 +366,15 @@ static int geni_i2c_rx_one_msg(struct
> geni_i2c_dev *gi2c, struct i2c_msg *msg,
> else
> geni_se_select_mode(se, GENI_SE_FIFO);
>
> - writel_relaxed(len, se->base + SE_I2C_RX_TRANS_LEN);
> - geni_se_setup_m_cmd(se, I2C_READ, m_param);
> -
> if (dma_buf && geni_se_rx_dma_prep(se, dma_buf, len, &rx_dma)) {
> geni_se_select_mode(se, GENI_SE_FIFO);
> i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
> dma_buf = NULL;
> }
>
> + writel_relaxed(len, se->base + SE_I2C_RX_TRANS_LEN);
> + geni_se_setup_m_cmd(se, I2C_READ, m_param);
> +
> time_left = wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT);
> if (!time_left)
> geni_i2c_abort_xfer(gi2c);
Tested-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member
of Code Aurora Forum, hosted by The Linux Foundation
next prev parent reply other threads:[~2020-07-21 5:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 0:24 [PATCH] i2c: i2c-qcom-geni: Fix DMA transfer race Douglas Anderson
2020-07-21 5:37 ` Sai Prakash Ranjan [this message]
2020-07-21 5:59 ` Stephen Boyd
2020-07-21 7:07 ` Stephen Boyd
2020-07-21 10:58 ` Mukesh, Savaliya
2020-07-21 16:18 ` Doug Anderson
2020-07-21 18:55 ` Stephen Boyd
2020-07-21 20:26 ` Doug Anderson
2020-07-22 22:08 ` Doug Anderson
2020-07-21 10:48 ` Akash Asthana
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=76940ce4659232e9adc073b4065d0e9b@codeaurora.org \
--to=saiprakash.ranjan@codeaurora.org \
--cc=agross@kernel.org \
--cc=akashast@codeaurora.org \
--cc=alokc@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=dianders@chromium.org \
--cc=girishm@codeaurora.org \
--cc=kramasub@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rnayak@codeaurora.org \
--cc=swboyd@chromium.org \
--cc=wsa@kernel.org \
--cc=wsa@the-dreams.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.