I develop a project using the imx8mm chip running Linux 4.19. The chip has no CAN controller so we use a SPI to CAN converter Microchip MCP2518FD. It is connected via SPI and one interrupt GPIO. The interaction between imx8 and mcp2518 is driven by that GPIO interrupt (for example, the GPIO pin is asserted when there's new data in Rx buffer).
I have a strange issue. The kernel log often says that mcp2518 Rx buffer gets overlowed and ifconfig shows a significant number of rx errors on can0 interface. While investigating the issue, I noticed that the number of errors highly depends on the load of imx8 core 0.
- When core 0 load is low, the rx error rate goes up to 6%.
- When core 0 load is 100%, there are no rx errors. For testing purposes, I used a script that creates a dummy load on core0 (continious archiving of a file or continios reading of /dev/random).
It looks very strange, that loading the main core fixes the issue. I suppose that some interrupts are missed or processed with delay due to wait or sleep mode of the CPU. And creating a dummy load prevents the CPU from entering such modes.
Could you suggest any ideas on how to make SPI or interrupt GPIO work reliable at low CPU load?