All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yicong Yang <yangyicong@huawei.com>
To: <wsa@kernel.org>, <linux-i2c@vger.kernel.org>
Cc: <chenweilong@huawei.com>, <f.fangjian@huawei.com>,
	<linuxarm@huawei.com>, <prime.zeng@huawei.com>,
	<yangyicong@hisilicon.com>, Sheng Feng <fengsheng5@huawei.com>
Subject: [PATCH 2/2] i2c: hisi: Only use the completion interrupt to finish the transfer
Date: Mon, 13 Mar 2023 15:45:52 +0800	[thread overview]
Message-ID: <20230313074552.54457-3-yangyicong@huawei.com> (raw)
In-Reply-To: <20230313074552.54457-1-yangyicong@huawei.com>

From: Yicong Yang <yangyicong@hisilicon.com>

The controller will always generate a completion interrupt when the
transfer is finished normally or not. Currently we use either error or
completion interrupt to finish, this may result the completion
interrupt unhandled and corrupt the next transfer, especially at low
speed mode. Since on error case, the error interrupt will come first
then is the completion interrupt. So only use the completion interrupt
to finish the whole transfer process.

Fixes: d62fbdb99a85 ("i2c: add support for HiSilicon I2C controller")
Reported-by: Sheng Feng <fengsheng5@huawei.com>
Signed-off-by: Sheng Feng <fengsheng5@huawei.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/i2c/busses/i2c-hisi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-hisi.c b/drivers/i2c/busses/i2c-hisi.c
index 1b7609a34f4a..e067671b3ce2 100644
--- a/drivers/i2c/busses/i2c-hisi.c
+++ b/drivers/i2c/busses/i2c-hisi.c
@@ -348,7 +348,11 @@ static irqreturn_t hisi_i2c_irq(int irq, void *context)
 		hisi_i2c_read_rx_fifo(ctlr);
 
 out:
-	if (int_stat & HISI_I2C_INT_TRANS_CPLT || ctlr->xfer_err) {
+	/*
+	 * Only use TRANS_CPLT to indicate the completion. On error cases we'll
+	 * get two interrupts, INT_ERR first then TRANS_CPLT.
+	 */
+	if (int_stat & HISI_I2C_INT_TRANS_CPLT) {
 		hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL);
 		hisi_i2c_clear_int(ctlr, HISI_I2C_INT_ALL);
 		complete(ctlr->completion);
-- 
2.24.0


  parent reply	other threads:[~2023-03-13  7:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13  7:45 [PATCH 0/2] Improvement and fix for HiSilicon I2C driver Yicong Yang
2023-03-13  7:45 ` [PATCH 1/2] i2c: hisi: Avoid redundant interrupts Yicong Yang
2023-03-16 20:06   ` Wolfram Sang
2023-03-13  7:45 ` Yicong Yang [this message]
2023-03-16 20:06   ` [PATCH 2/2] i2c: hisi: Only use the completion interrupt to finish the transfer Wolfram Sang

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=20230313074552.54457-3-yangyicong@huawei.com \
    --to=yangyicong@huawei.com \
    --cc=chenweilong@huawei.com \
    --cc=f.fangjian@huawei.com \
    --cc=fengsheng5@huawei.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=prime.zeng@huawei.com \
    --cc=wsa@kernel.org \
    --cc=yangyicong@hisilicon.com \
    /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.