Skip to content

Commit fee4651

Browse files
TommyHuang0527wsakernel
authored andcommitted
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: 2e57b7c ("i2c: aspeed: Add multi-master use case support") Cc: <stable@vger.kernel.org> # v5.1+ Signed-off-by: Tommy Huang <tommy_huang@aspeedtech.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent b2cacc2 commit fee4651

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/i2c/busses/i2c-aspeed.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,16 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
698698

699699
if (time_left == 0) {
700700
/*
701-
* If timed out and bus is still busy in a multi master
702-
* environment, attempt recovery at here.
701+
* In a multi-master setup, if a timeout occurs, attempt
702+
* recovery. But if the bus is idle, we still need to reset the
703+
* i2c controller to clear the remaining interrupts.
703704
*/
704705
if (bus->multi_master &&
705706
(readl(bus->base + ASPEED_I2C_CMD_REG) &
706707
ASPEED_I2CD_BUS_BUSY_STS))
707708
aspeed_i2c_recover_bus(bus);
709+
else
710+
aspeed_i2c_reset(bus);
708711

709712
/*
710713
* If timed out and the state is still pending, drop the pending

0 commit comments

Comments
 (0)