can: sja1000: Prevent overrun stalls with a soft reset on Renesas SoCs
authorMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 16 Jun 2023 13:45:53 +0000 (15:45 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 22 Jun 2023 07:41:32 +0000 (09:41 +0200)
commit717c6ec241b5524400acc0f6009b89e2c59527f9
tree5a2a14af3b715b765ea981758172d0340bf28c01
parentaf7647a0b4b50c3f988a76b05dea5e6bf20c858a
can: sja1000: Prevent overrun stalls with a soft reset on Renesas SoCs

In their RZN1 SoC, Renesas put a CAN controller supposed to act very
similarly to the original Philips sja1000. In practice, while flooding
the bus with another device, we discovered that the controller very
often after an overrun situation would just refuse any new frame, drop
them all and trigger over and over again the overrun interrupt, even
though the buffer would have been totally emptied. The controller acts
like if its internal buffer offsets (where it writes and where the host
reads) where totally screwed-up.

Renesas manual mentions a single action to perform in order to
resynchronize the read and write offsets within the buffer: performing
a soft reset.

Performing a soft reset takes a bit of time and involves small delays,
so better do that in a threaded handler rather than inside the hard IRQ
handler.

Add platform data to recognize the platforms which need this workaround,
and when the faulty situation is diagnosed, stop what is being
performed and request the threaded handler to be executed in order to
perform the reset.

Tested-by: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com> # 5.10
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/all/20230616134553.2786391-2-miquel.raynal@bootlin.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/sja1000/sja1000.c
drivers/net/can/sja1000/sja1000.h
drivers/net/can/sja1000/sja1000_platform.c