Skip to contentSkip to conversation

i2c: aspeed: Reset the i2c controller when timeout occurs

PATCH Superseded Tommy Huang 2 participants 2 messages Sep 4, 2023 – Sep 5, 2023

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: aspeed: Reset the i2c controller when timeout occurs

Reset the i2c controller when an i2c transfer timeout occurs. The remaining interrupts and device should be reset to avoid unpredictable controller behavior.

Fixes 2e57b7cebb98 ("i2c: aspeed: Add multi-master use case support")
Cc Jae Hyun Yoo <[email protected]>
Cc <[email protected]> # v5.1+
---
 drivers/i2c/busses/i2c-aspeed.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-aspeed.c +5 -2
index 2e5acfeb76c8..5a416b39b818 100644
@@ -698,13 +698,16 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
 
 	if (time_left == 0) {
 		/*
-		 * If timed out and bus is still busy in a multi master
-		 * environment, attempt recovery at here.
+		 * 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.
 		 */
 		if (bus->multi_master &&
 		    (readl(bus->base + ASPEED_I2C_CMD_REG) &
 		     ASPEED_I2CD_BUS_BUSY_STS))
 			aspeed_i2c_recover_bus(bus);
+		else
+			aspeed_i2c_reset(bus);
 
 		/*
 		 * If timed out and the state is still pending, drop the pending
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Tommy,

Thanks for fixing what I asked, I'm going to review here:

But still there are 3 things I will ask you for your next patches:

1. Please add a version to the patch, this is patch version 2, so that the title should be "[PATCH v2] i2c...."

You can have that with git-format-patch:

git format-patch -v 2 ....

Quoted 9 lines · Tommy Huang

Reset the i2c controller when an i2c transfer timeout occurs. The remaining interrupts and device should be reset to avoid unpredictable controller behavior.

Fixes 2e57b7cebb98 ("i2c: aspeed: Add multi-master use case support")
Cc Jae Hyun Yoo <[email protected]>
Cc <[email protected]> # v5.1+

2. Don't leave blank lines between tags. But I think Wolfram can fix this before pushing.

Quoted 1 line

---

3. After the '---' it comes the freedom of speach section where you can write anything. Please add the changelog, something like:

v1 -> v2
- Fixed comment...
- Fixed commit log...
- etc.

This is important for reviewers in order to understand what has changed from patch v1 to patch v2.

Please, before your next patch, read first the Documentation/process/submitting-patches.rst document.

Thanks,
Andi

Quoted 29 lines
 drivers/i2c/busses/i2c-aspeed.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-aspeed.c +5 -2
index 2e5acfeb76c8..5a416b39b818 100644
@@ -698,13 +698,16 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
 
 	if (time_left == 0) {
 		/*
-		 * If timed out and bus is still busy in a multi master
-		 * environment, attempt recovery at here.
+		 * 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.
 		 */
 		if (bus->multi_master &&
 		    (readl(bus->base + ASPEED_I2C_CMD_REG) &
 		     ASPEED_I2CD_BUS_BUSY_STS))
 			aspeed_i2c_recover_bus(bus);
+		else
+			aspeed_i2c_reset(bus);
 
 		/*
 		 * If timed out and the state is still pending, drop the pending
Signature · 1 line
2.25.1