From: Tommy Huang <tommy_huang@aspeedtech.com>
To: <brendanhiggins@google.com>, <benh@kernel.crashing.org>,
<joel@jms.id.au>, <andi.shyti@kernel.org>
Cc: <linux-i2c@vger.kernel.org>, <openbmc@lists.ozlabs.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>, <BMC-SW@aspeedtech.com>
Subject: [PATCH] i2c: aspeed: Consider i2c reset for muti-master case
Date: Fri, 18 Oct 2024 11:49:19 +0800 [thread overview]
Message-ID: <20241018034919.974025-1-tommy_huang@aspeedtech.com> (raw)
In the original code, the device reset would not be triggered
when the driver is set to multi-master and bus is free.
It needs to be considered with multi-master condition.
Fixes: <f327c686d3ba> ("i2c: aspeed: Reset the i2c controller when timeout occurs")
Signed-off-by: Tommy Huang <tommy_huang@aspeedtech.com>
---
drivers/i2c/busses/i2c-aspeed.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index cc5a26637fd5..7639ae3ace67 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -716,14 +716,15 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
if (time_left == 0) {
/*
* In a multi-master setup, if a timeout occurs, attempt
- * recovery. But if the bus is idle, we still need to reset the
- * i2c controller to clear the remaining interrupts.
+ * recovery device. But if the bus is idle,
+ * we still need to reset the i2c controller to clear
+ * the remaining interrupts or reset device abnormal condition.
*/
- if (bus->multi_master &&
- (readl(bus->base + ASPEED_I2C_CMD_REG) &
- ASPEED_I2CD_BUS_BUSY_STS))
- aspeed_i2c_recover_bus(bus);
- else
+ if ((readl(bus->base + ASPEED_I2C_CMD_REG) &
+ ASPEED_I2CD_BUS_BUSY_STS)){
+ if (bus->multi_master)
+ aspeed_i2c_recover_bus(bus);
+ } else
aspeed_i2c_reset(bus);
/*
--
2.25.1
next reply other threads:[~2024-10-18 3:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 3:49 Tommy Huang [this message]
2024-10-21 11:49 ` [PATCH] i2c: aspeed: Consider i2c reset for muti-master case Andrew Jeffery
2024-10-22 2:42 ` Tommy Huang
2024-10-24 13:22 ` Andi Shyti
2024-10-25 0:39 ` Tommy Huang
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=20241018034919.974025-1-tommy_huang@aspeedtech.com \
--to=tommy_huang@aspeedtech.com \
--cc=BMC-SW@aspeedtech.com \
--cc=andi.shyti@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=brendanhiggins@google.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=stable@vger.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