Skip to contentSkip to conversation

i2c: microchip-core: fix erroneous late ack send

PATCH In review Conor Dooley 2 participants 4 messages Aug 5, 2022 – Aug 11, 2022

Subsystems (2)
lore
Share & tools
lore

Conor Dooley

author maintainer
#0 lore raw

PATCH 1/1 i2c: microchip-core: fix erroneous late ack send

A late ack is currently being sent at the end of a transfer due to incorrect logic in mchp_corei2c_empty_rx(). Currently the Assert Ack bit is being written to the controller's control reg after the last byte has been received, causing it to sent another byte with the ack. Instead, the AA flag should be written to to the contol register when the penultimate byte is read so it is sent out for the last byte.

Fixes 64a6f1c4987e ("i2c: add support for microchip fpga i2c controllers")

---

FYI Wolfram, I am still sitting on the MAINTAINERS update as the SoC updates have not been pulled yet for 6.0 (AFAICT)

 drivers/i2c/busses/i2c-microchip-corei2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-microchip-corei2c.c +1 -1
index 6df0f1c33278..4d7e9b25f018 100644
@@ -206,7 +206,7 @@ static void mchp_corei2c_empty_rx(struct mchp_corei2c_dev *idev)
 		idev->msg_len--;
 	}
 
-	if (idev->msg_len == 0) {
+	if (idev->msg_len <= 1) {
 		ctrl = readb(idev->base + CORE_I2C_CTRL);
 		ctrl &= ~CTRL_AA;
 		writeb(ctrl, idev->base + CORE_I2C_CTRL);
Signature · 1 line
2.36.1
#1 lore raw
Quoted 11 lines · Conor Dooley

A late ack is currently being sent at the end of a transfer due to incorrect logic in mchp_corei2c_empty_rx(). Currently the Assert Ack bit is being written to the controller's control reg after the last byte has been received, causing it to sent another byte with the ack. Instead, the AA flag should be written to to the contol register when the penultimate byte is read so it is sent out for the last byte.

Fixes 64a6f1c4987e ("i2c: add support for microchip fpga i2c controllers")

Fixed these checkpatch warnings:

WARNING: 'contol' may be misspelled - perhaps 'control'?
WARNING: Possible repeated word: 'to'

and applied to for-current, thanks!

author maintainer
#2 lore raw
Quoted 14 lines · Wolfram Sang

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 11 lines · Conor Dooley

A late ack is currently being sent at the end of a transfer due to incorrect logic in mchp_corei2c_empty_rx(). Currently the Assert Ack bit is being written to the controller's control reg after the last byte has been received, causing it to sent another byte with the ack. Instead, the AA flag should be written to to the contol register when the penultimate byte is read so it is sent out for the last byte.

Fixes 64a6f1c4987e ("i2c: add support for microchip fpga i2c controllers")
Quoted 4 lines

Fixed these checkpatch warnings:

WARNING: 'contol' may be misspelled - perhaps 'control'?
WARNING: Possible repeated word: 'to'

Heh, that's what I get for editing the commit in send-email..

Quoted 2 lines

and applied to for-current, thanks!

Thanks :)

Quoted 2 lines
#3 lore raw
Quoted 2 lines

Heh, that's what I get for editing the commit in send-email..

I know that feeling... :)