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

can: c_can: Fix RX message handling, handle lost message before EOB

If we handle end of block messages with higher priority than a lost message,
we can run into an endless interrupt loop.

This is reproducable with a am335x processor and "cansequence -r" at 1Mbit.
As soon as we loose a packet we can't escape from an interrupt loop.

This patch fixes the problem by handling lost packets before EOB packets.

Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Markus Pargmann and committed by
Marc Kleine-Budde
5d0f801a c17cb8b5

+3 -3
+3 -3
drivers/net/can/c_can/c_can.c
··· 814 814 msg_ctrl_save = priv->read_reg(priv, 815 815 C_CAN_IFACE(MSGCTRL_REG, 0)); 816 816 817 - if (msg_ctrl_save & IF_MCONT_EOB) 818 - return num_rx_pkts; 819 - 820 817 if (msg_ctrl_save & IF_MCONT_MSGLST) { 821 818 c_can_handle_lost_msg_obj(dev, 0, msg_obj); 822 819 num_rx_pkts++; 823 820 quota--; 824 821 continue; 825 822 } 823 + 824 + if (msg_ctrl_save & IF_MCONT_EOB) 825 + return num_rx_pkts; 826 826 827 827 if (!(msg_ctrl_save & IF_MCONT_NEWDAT)) 828 828 continue;