未验证 提交 61bf40ef 编写于 作者: E Eddie James 提交者: Mark Brown

spi: fsi: Fix spurious timeout

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: 89b35e3f ("spi: fsi: Implement a timeout for polling status")
Signed-off-by: NEddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220525165852.33167-2-eajames@linux.ibm.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 9c63b846
...@@ -319,12 +319,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, ...@@ -319,12 +319,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx,
end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS); end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS);
do { do {
if (time_after(jiffies, end))
return -ETIMEDOUT;
rc = fsi_spi_status(ctx, &status, "TX"); rc = fsi_spi_status(ctx, &status, "TX");
if (rc) if (rc)
return rc; return rc;
if (time_after(jiffies, end))
return -ETIMEDOUT;
} while (status & SPI_FSI_STATUS_TDR_FULL); } while (status & SPI_FSI_STATUS_TDR_FULL);
sent += nb; sent += nb;
...@@ -337,12 +337,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, ...@@ -337,12 +337,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx,
while (transfer->len > recv) { while (transfer->len > recv) {
end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS); end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS);
do { do {
if (time_after(jiffies, end))
return -ETIMEDOUT;
rc = fsi_spi_status(ctx, &status, "RX"); rc = fsi_spi_status(ctx, &status, "RX");
if (rc) if (rc)
return rc; return rc;
if (time_after(jiffies, end))
return -ETIMEDOUT;
} while (!(status & SPI_FSI_STATUS_RDR_FULL)); } while (!(status & SPI_FSI_STATUS_RDR_FULL));
rc = fsi_spi_read_reg(ctx, SPI_FSI_DATA_RX, &in); rc = fsi_spi_read_reg(ctx, SPI_FSI_DATA_RX, &in);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册