mpfs_corespi: fix semaphore race condition

SPI TX_DONE interrupt can be received after a semaphore timeout,
but before interrupts are disabled. This will leave the semaphore
to the signaled state.

After a timeout the semaphore is always reset to non-signaled state
to fix this race condition.

Signed-off-by: Tero Salminen <tero.salminen@unikie.com>
This commit is contained in:
Tero Salminen 2024-03-28 09:03:50 +02:00 committed by Xiang Xiao
parent 5a51d3b23f
commit 186b11c941

View file

@ -931,6 +931,18 @@ static void mpfs_spi_irq_exchange(struct mpfs_spi_priv_s *priv,
MPFS_SPI_INTTXDONE,
0);
/* TX_DONE interrupt can be received after a semaphore timeout, but before
* interrupts are disabled. This will leave the semaphore to the signaled
* state.
* After a timeout the semaphore is always reset to non-signaled state
* to fix this race condition.
*/
if (priv->error == -ETIMEDOUT)
{
nxsem_reset(&priv->sem_isr, 0);
}
putreg32(MPFS_SPI_TXCHUNDRUN |
MPFS_SPI_RXCHOVRFLW |
MPFS_SPI_DATA_RX |