Skip to content

Commit ae7304c

Browse files
Shubhrajyoti DattaWolfram Sang
authored andcommitted
i2c: xiic: Make the start and the byte count write atomic
Disable interrupts while configuring the transfer and enable them back. We have below as the programming sequence 1. start and slave address 2. byte count and stop In some customer platform there was a lot of interrupts between 1 and 2 and after slave address (around 7 clock cyles) if 2 is not executed then the transaction is nacked. To fix this case make the 2 writes atomic. Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> [wsa: added a newline for better readability] Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Cc: stable@kernel.org
1 parent 851a151 commit ae7304c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/i2c/busses/i2c-xiic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
532532
{
533533
u8 rx_watermark;
534534
struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg;
535+
unsigned long flags;
535536

536537
/* Clear and enable Rx full interrupt. */
537538
xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK);
@@ -547,6 +548,7 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
547548
rx_watermark = IIC_RX_FIFO_DEPTH;
548549
xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1);
549550

551+
local_irq_save(flags);
550552
if (!(msg->flags & I2C_M_NOSTART))
551553
/* write the address */
552554
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET,
@@ -556,6 +558,8 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
556558

557559
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET,
558560
msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0));
561+
local_irq_restore(flags);
562+
559563
if (i2c->nmsgs == 1)
560564
/* very last, enable bus not busy as well */
561565
xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);

0 commit comments

Comments
 (0)