• Robert Hancock's avatar
    i2c: xiic: Wait for TX empty to avoid missed TX NAKs · 521da1e9
    Robert Hancock authored
    Frequently an I2C write will be followed by a read, such as a register
    address write followed by a read of the register value. In this driver,
    when the TX FIFO half empty interrupt was raised and it was determined
    that there was enough space in the TX FIFO to send the following read
    command, it would do so without waiting for the TX FIFO to actually
    empty.
    
    Unfortunately it appears that in some cases this can result in a NAK
    that was raised by the target device on the write, such as due to an
    unsupported register address, being ignored and the subsequent read
    being done anyway. This can potentially put the I2C bus into an
    invalid state and/or result in invalid read data being processed.
    
    To avoid this, once a message has been fully written to the TX FIFO,
    wait for the TX FIFO empty interrupt before moving on to the next
    message, to ensure NAKs are handled properly.
    
    Fixes: e1d5b659 ("i2c: Add support for Xilinx XPS IIC Bus Interface")
    Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
    Cc: <stable@vger.kernel.org> # v2.6.34+
    Reviewed-by: default avatarManikanta Guntupalli <manikanta.guntupalli@amd.com>
    Acked-by: default avatarMichal Simek <michal.simek@amd.com>
    Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
    521da1e9
i2c-xiic.c 38.5 KB