• Ricardo Ribalda Delgado's avatar
    spi/spi-xilinx: Fix race condition on last word read · eca37c7c
    Ricardo Ribalda Delgado authored
    Some users have reported that in polled mode the driver fails randomly
    to read the last word of the transfer.
    
    The end condition used for the transmissions (in polled and irq mode)
    has been the TX_EMPTY flag. But Lars-Peter Clausen has identified a delay
    from the TX_EMPTY to the actual end of the data rx.
    
    I believe that this race condition has not been detected until now
    because of the latency added by the IRQ handler or the PCIe bridge.
    This bugs affects setups with low latency access to the spi core.
    
    This patch replaces the readout logic:
    
    For all the words, except the last one, the TX_EMPTY flag is used (and
    cached).
    
    If !TX_EMPY or is the last word. The status register is read and the
    RX_EMPTY flag is used.
    
    The performance is not affected: there is an extra read of the
    Status Register, but the readout can start as soon as there is a word
    in the buffer.
    Reported-by: default avatarEdward Kigwana <ekigwana@scires.com>
    Initial-fix-by: default avatarLars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    eca37c7c
spi-xilinx.c 14.1 KB