How can I solve the CAN bus packet loss?

I use the CAN interface(can0) as below setting (1Mbps).

  • sudo ip link set can0 type can bitrate 1000000 dbitrate 2000000 berr-reporting on fd on
  • sudo ip link set up can0

Many packet loss was occurred during CAN communication,
when the system run on heavy load ( ex USB3.0 camera is running).

So, I changed the CPU affinity(CPU0 --> CPU4) for handling CAN irq,
then, packet loss was reduced.

  • CAN packet loss after changing the CPU affinity
  • CPU0 (default) - Rx 0.96% / Tx 0%
  • CPU4 - Rx 0.0036% / Tx 0%

But the packet loss is still occurred.
I have some questions about this issue and want to improve the packet loss.

1. Is the loss rate of 0.004% is acceptable/normal in general CAN communication?

2. Dose the DMA is supported for CAN in TX2?
If CAN can use the DMA, can the packet loss be improved ?

3. I can see many xhci_hcd warning log in kernel log.
Can the “xhci_hcd warning” affect the CAN packet loss?


[ 2064.826289] xhci_hcd 0000:01:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[ 2064.883229] xhci_hcd 0000:01:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[ 2064.895387] xhci_hcd 0000:01:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[ 2066.554347] extcon-gpio-states external-connection:extcon@1: Cable state 2
[ 2066.561287] mttcan c310000.mttcan can0: mttcan_poll_ir: some msgs lost on in Q0
[ 2066.902340] extcon-gpio-states external-connection:extcon@1: Cable state 2
[ 2069.685794] handle_tx_event: 171 callbacks suppressed
[ 2069.690847] xhci_hcd 0000:01:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[ 2069.720301] xhci_hcd 0000:01:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
[ 2069.752758] xhci_hcd 0000:01:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?

[ 2074.754012] handle_tx_event: 171 callbacks suppressed

4. Are there any ideas for improving the CAN packet loss?

I met the same problem.

when I plug in or out the usb device, the can0 RX errors increase from the ifconfig.

when I changed the CPU affinity(CPU0 --> CPU2) for handling CAN irq with command,

sudo sh -c “echo 2 > /proc/irq/427/smp_affinity”

the packet loss reduced.

However when the load increase, the error still appear.

Any suggestion to solve this problem?

In my point of view, should I increase the priority of the CAN interupt? and how?

do you solve the problem?