On Thu, Aug 4, 2022 at 10:42 AM Sebastian Würl <sebastian.wuerl@xxxxxxxxxxxxx> wrote: > > 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 For future submissions... > Fixes: bf66f3736a94 ("can: mcp251x: Move to threaded interrupts instead of workqueues.") > Signed-off-by: Sebastian Würl <sebastian.wuerl@xxxxxxxxxxxxx> > --- When you send the new version of a single patch, use --annotate to put a changelog here (after the cutter '---' line) so people will know how v4 differes to v3 to v2 and to v1. Also you mentioned some issues with the mail program. Use `git send-email` for patch submission. Also you may consider my "smart" (no) script [1] for that. [1]: https://github.com/andy-shev/home-bin-tools/blob/master/ge2maintainer.sh -- With Best Regards, Andy Shevchenko