Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: fsl-espi: Fix an error that can cause fsl espi task blocked

Incorrect condition is used in spin_event_timeout(). When the TX is
done, the SPIE_NF bit in ESPI_SPIE register is set to 1 to indicate the
Tx FIFO is not full. If the bit is 0, it indicates the Tx FIFO is full.

Due to this error, if the Tx FIFO is full at the beginning, but becomes
not full after handling the Rx FIFO (the SPIE_NF bit is set), the
spin_event_timeout() returns with timeout occurred. It causes the
interrupt handler not to send completion notification to the thread that
called wait_for_complete() waiting for the notification.

Signed-off-by: Jane Wan <Jane.Wan@gainspeed.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jane Wan and committed by
Mark Brown
7a0a1759 b787f68c

+5 -1
+5 -1
drivers/spi/spi-fsl-espi.c
··· 544 544 545 545 /* spin until TX is done */ 546 546 ret = spin_event_timeout(((events = mpc8xxx_spi_read_reg( 547 - &reg_base->event)) & SPIE_NF) == 0, 1000, 0); 547 + &reg_base->event)) & SPIE_NF), 1000, 0); 548 548 if (!ret) { 549 549 dev_err(mspi->dev, "tired waiting for SPIE_NF\n"); 550 + 551 + /* Clear the SPIE bits */ 552 + mpc8xxx_spi_write_reg(&reg_base->event, events); 553 + complete(&mspi->done); 550 554 return; 551 555 } 552 556 }