OSDN Git Service

spi: tegra114: fix for unpacked mode transfers
authorSowjanya Komatineni <skomatineni@nvidia.com>
Wed, 27 Mar 2019 05:56:24 +0000 (22:56 -0700)
committerMark Brown <broonie@kernel.org>
Mon, 1 Apr 2019 08:25:24 +0000 (15:25 +0700)
commit1a89ac5b91895127f7c586ec5075c3753ca25501
treeab850c9a2e885462d409618fd8c3c8002d9b5531
parent7b3d10cdf54b8bc1dc0da21faed9789ac4da3684
spi: tegra114: fix for unpacked mode transfers

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: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-tegra114.c