Skip to content

Commit

Permalink
spi: fsi: Fix spurious timeout
Browse files Browse the repository at this point in the history
The driver may return a timeout error even if the status register
indicates that the transfer may proceed. Fix this by restructuring
the polling loop.

Fixes: 89b35e3 ("spi: fsi: Implement a timeout for polling status")
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220525165852.33167-2-eajames@linux.ibm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Eddie James authored and broonie committed May 26, 2022
1 parent 9c63b84 commit 61bf40e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/spi/spi-fsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx,

end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS);
do {
if (time_after(jiffies, end))
return -ETIMEDOUT;

rc = fsi_spi_status(ctx, &status, "TX");
if (rc)
return rc;

if (time_after(jiffies, end))
return -ETIMEDOUT;
} while (status & SPI_FSI_STATUS_TDR_FULL);

sent += nb;
Expand All @@ -337,12 +337,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx,
while (transfer->len > recv) {
end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS);
do {
if (time_after(jiffies, end))
return -ETIMEDOUT;

rc = fsi_spi_status(ctx, &status, "RX");
if (rc)
return rc;

if (time_after(jiffies, end))
return -ETIMEDOUT;
} while (!(status & SPI_FSI_STATUS_RDR_FULL));

rc = fsi_spi_read_reg(ctx, SPI_FSI_DATA_RX, &in);
Expand Down

0 comments on commit 61bf40e

Please sign in to comment.