netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Possible race condition of the rockchip_canfd driver
@ 2025-09-18 12:58 Andrea Daoud
  2025-09-19 19:03 ` Marc Kleine-Budde
  0 siblings, 1 reply; 7+ messages in thread
From: Andrea Daoud @ 2025-09-18 12:58 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Heiko Stuebner, Elaine Zhang, kernel, linux-can, netdev,
	linux-arm-kernel, linux-rockchip, linux-kernel

Hi Marc,

I'm using the rockchip_canfd driver on an RK3568. When under high bus
load, I get
the following logs [1] in rkcanfd_tx_tail_is_eff, and the CAN bus is unable to
communicate properly under this condition. The exact cause is currently not
entirely clear, and it's not reliably reproducible.

In the logs we can spot some strange points:

1. Line 24, tx_head == tx_tail. This should have been rejected by the if
(!rkcanfd_get_tx_pending) clause.

2. Line 26, the last bit of priv->tx_tail (0x0185dbb3) is 1. This means that the
tx_tail should be 1, because rkcanfd_get_tx_tail is essentially mod the
priv->tx_tail by two. But the printed tx_tail is 0.

I believe these problems could mean that the code is suffering from some race
condition. It seems that, in the whole IRQ processing chain of the driver,
there's no lock protection. Maybe some IRQ happens within the execution of
rkcanfd_tx_tail_is_eff, and touches the state of the tx_head and tx_tail?

Could you please have a look at the code, and check if some locking is needed?

[1]: https://pastebin.com/R7uuEKEz

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-29  8:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 12:58 Possible race condition of the rockchip_canfd driver Andrea Daoud
2025-09-19 19:03 ` Marc Kleine-Budde
2025-09-20 10:08   ` Andrea Daoud
2025-09-22  8:50     ` Marc Kleine-Budde
2025-09-27 16:26       ` Andrea Daoud
2025-09-28 17:47         ` Alexander Shiyan
2025-09-29  8:22         ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).