From fc5e8ff8f89eeaaa2d61a00e56d22f4ec25fb29c Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Mon, 22 May 2023 17:30:10 +0300 Subject: [PATCH] mpfs/CoreSPI: Fix bug when waiting for last character to arrive The logic for rx_fifo_empty is wrong, needs a loop for the retry to work --- arch/risc-v/src/mpfs/mpfs_corespi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/risc-v/src/mpfs/mpfs_corespi.c b/arch/risc-v/src/mpfs/mpfs_corespi.c index 85f77951b7..b5f850dd13 100644 --- a/arch/risc-v/src/mpfs/mpfs_corespi.c +++ b/arch/risc-v/src/mpfs/mpfs_corespi.c @@ -781,8 +781,7 @@ static void mpfs_spi_unload_rx_fifo(struct mpfs_spi_priv_s *priv, for (i = 0; i < nwords; i++) { - rx_fifo_empty = getreg32(MPFS_SPI_STATUS) & MPFS_SPI_RXEMPTY; - if (rx_fifo_empty) + while ((rx_fifo_empty = getreg32(MPFS_SPI_STATUS) & MPFS_SPI_RXEMPTY)) { /* Last RX character not ready yet, try again (once) */