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

authored by Shubhrajyoti Datta and committed by Wolfram Sang ae7304c3 851a1511

+4
+4
drivers/i2c/busses/i2c-xiic.c
··· 532 { 533 u8 rx_watermark; 534 struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; 535 536 /* Clear and enable Rx full interrupt. */ 537 xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); ··· 548 rx_watermark = IIC_RX_FIFO_DEPTH; 549 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1); 550 551 if (!(msg->flags & I2C_M_NOSTART)) 552 /* write the address */ 553 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, ··· 558 559 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, 560 msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); 561 if (i2c->nmsgs == 1) 562 /* very last, enable bus not busy as well */ 563 xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);
··· 532 { 533 u8 rx_watermark; 534 struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; 535 + unsigned long flags; 536 537 /* Clear and enable Rx full interrupt. */ 538 xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); ··· 547 rx_watermark = IIC_RX_FIFO_DEPTH; 548 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1); 549 550 + local_irq_save(flags); 551 if (!(msg->flags & I2C_M_NOSTART)) 552 /* write the address */ 553 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, ··· 556 557 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, 558 msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); 559 + local_irq_restore(flags); 560 + 561 if (i2c->nmsgs == 1) 562 /* very last, enable bus not busy as well */ 563 xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);