Skip to content

Commit d12e3aa

Browse files
osctobeWolfram Sang
authored andcommitted
i2c: at91: disable TXRDY interrupt after sending data
Driver was not disabling TXRDY interrupt after last TX byte. This caused interrupt storm until transfer timeouts for slow or broken device on the bus. The patch fixes the interrupt storm on my SAMA5D2-based board. Cc: stable@vger.kernel.org # 5.2.x [v5.2 introduced file split; the patch should apply to i2c-at91.c before the split] Fixes: fac368a ("i2c: at91: add new driver") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com> Tested-by: Raag Jadav <raagjadav@gmail.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent fd01eec commit d12e3aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/i2c/busses/i2c-at91-master.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ static void at91_twi_write_next_byte(struct at91_twi_dev *dev)
122122
writeb_relaxed(*dev->buf, dev->base + AT91_TWI_THR);
123123

124124
/* send stop when last byte has been written */
125-
if (--dev->buf_len == 0)
125+
if (--dev->buf_len == 0) {
126126
if (!dev->use_alt_cmd)
127127
at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP);
128+
at91_twi_write(dev, AT91_TWI_IDR, AT91_TWI_TXRDY);
129+
}
128130

129131
dev_dbg(dev->dev, "wrote 0x%x, to go %zu\n", *dev->buf, dev->buf_len);
130132

@@ -542,9 +544,8 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
542544
} else {
543545
at91_twi_write_next_byte(dev);
544546
at91_twi_write(dev, AT91_TWI_IER,
545-
AT91_TWI_TXCOMP |
546-
AT91_TWI_NACK |
547-
AT91_TWI_TXRDY);
547+
AT91_TWI_TXCOMP | AT91_TWI_NACK |
548+
(dev->buf_len ? AT91_TWI_TXRDY : 0));
548549
}
549550
}
550551

0 commit comments

Comments
 (0)