• Sowjanya Komatineni's avatar
    spi: tegra114: fix for unpacked mode transfers · 1a89ac5b
    Sowjanya Komatineni authored
    Fixes: computation of actual bytes to fill/receive in/from FIFO in unpacked
    mode when transfer length is not a multiple of requested bits per word.
    
    unpacked mode transfers fails when the transfer includes partial bytes in
    the last word.
    
    Total words to be written/read to/from FIFO is computed based on transfer
    length and bits per word. Unpacked mode includes 0 padding bytes for partial
    words to align with bits per word and these extra bytes are also accounted
    for calculating bytes left to transfer in the current driver.
    
    This causes extra bytes access of tx/rx buffers along with buffer index
    position crossing actual length where remain_len becomes negative and due to
    unsigned type, negative value is a 32 bit representation of signed value
    and transferred bytes never meets the actual transfer length resulting in
    transfer timeout and a hang.
    
    This patch fixes this with proper computation of the actual bytes to fill in
    FIFO during transmit and the actual bytes to read from FIFO during receive
    ignoring 0 padded bytes.
    Signed-off-by: default avatarSowjanya Komatineni <skomatineni@nvidia.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    1a89ac5b
spi-tegra114.c 33.9 KB