summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorSebastian Würl <sebastian.wuerl@ororatech.com>2022-08-04 10:14:11 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2022-08-09 21:40:22 +0200
commitd80d60b0db6ff3dd2e29247cc2a5166d7e9ae37e (patch)
tree4a4225205437f498f41488281e9fc6d4ae0be695 /ipc
parenta4cb6e62ea4d36e53fb3c0f18ea4503d7b76674f (diff)
downloadlinux-d80d60b0db6ff3dd2e29247cc2a5166d7e9ae37e.tar.gz
linux-d80d60b0db6ff3dd2e29247cc2a5166d7e9ae37e.tar.bz2
linux-d80d60b0db6ff3dd2e29247cc2a5166d7e9ae37e.zip
can: mcp251x: Fix race condition on receive interrupt
The mcp251x driver uses both receiving mailboxes of the CAN controller chips. For retrieving the CAN frames from the controller via SPI, it checks once per interrupt which mailboxes have been filled and will retrieve the messages accordingly. This introduces a race condition, as another CAN frame can enter mailbox 1 while mailbox 0 is emptied. If now another CAN frame enters mailbox 0 until the interrupt handler is called next, mailbox 0 is emptied before mailbox 1, leading to out-of-order CAN frames in the network device. This is fixed by checking the interrupt flags once again after freeing mailbox 0, to correctly also empty mailbox 1 before leaving the handler. For reproducing the bug I created the following setup: - Two CAN devices, one Raspberry Pi with MCP2515, the other can be any. - Setup CAN to 1 MHz - Spam bursts of 5 CAN-messages with increasing CAN-ids - Continue sending the bursts while sleeping a second between the bursts - Check on the RPi whether the received messages have increasing CAN-ids - Without this patch, every burst of messages will contain a flipped pair v3: https://lore.kernel.org/all/20220804075914.67569-1-sebastian.wuerl@ororatech.com v2: https://lore.kernel.org/all/20220804064803.63157-1-sebastian.wuerl@ororatech.com v1: https://lore.kernel.org/all/20220803153300.58732-1-sebastian.wuerl@ororatech.com Fixes: bf66f3736a94 ("can: mcp251x: Move to threaded interrupts instead of workqueues.") Signed-off-by: Sebastian Würl <sebastian.wuerl@ororatech.com> Link: https://lore.kernel.org/all/20220804081411.68567-1-sebastian.wuerl@ororatech.com [mkl: reduce scope of intf1, eflag1] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'ipc')
0 files changed, 0 insertions, 0 deletions