]> www.infradead.org Git - users/jedix/linux-maple.git/commit
spi: microchip-core: fix the issues in the isr
authorNaga Sureshkumar Relli <nagasuresh.relli@microchip.com>
Mon, 15 Jul 2024 11:13:52 +0000 (12:13 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 15 Jul 2024 18:08:15 +0000 (19:08 +0100)
commit502a582b8dd897d9282db47c0911d5320ef2e6b9
tree60140f23fa3c13cd06616d9d8094061b5918911e
parent3048dc8ba46b7ba11581f2a7e06849af0df13136
spi: microchip-core: fix the issues in the isr

It is possible for the TXDONE interrupt be raised if the tx FIFO becomes
temporarily empty while transmitting, resulting in recursive calls to
mchp_corespi_write_fifo() and therefore a garbage message might be
transmitted depending on when the interrupt is triggered. Moving all of
the tx FIFO writes out of the TXDONE portion of the interrupt handler
avoids this problem.

Most of rest of the TXDONE portion of the handler is problematic too.
Only reading the rx FIFO (and finalising the transfer) when the TXDONE
interrupt is raised can cause the transfer to stall, if the final bytes
of rx data are not available in the rx FIFO when the final TXDONE
interrupt is raised. The transfer should be finalised regardless of
which interrupt is raised, provided that all tx data has been set and
all rx data received.

The first issue was encountered "in the wild", the second is
theoretical.

Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers")
Signed-off-by: Naga Sureshkumar Relli <nagasuresh.relli@microchip.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20240715-candied-deforest-585685ef3c8a@wendy
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-microchip-core.c