Re: [PATCH net v6 3/6] can: rockchip_canfd: cancel bus-off restart before closing the device

From: Cunhao Lu

Date: Wed Nov 04 2026 - 03:10:47 EST


Hi,

> Is rkcanfd_start_xmit() serialized against this reinitialization at all?
> Would this leave INT_MASK unmasked and the TX queue awake on a
> controller that is in reset with the CAN state at CAN_STATE_BUS_OFF?

Both windows predate this patch. Its added waits can extend the TX race
after the core restores carrier. Patch 5 of v6 closes both windows.
I will fix this issue in v7 by introducing restart synchronization and
TX protection together.

In the complete v6 series, both restart and open use
rkcanfd_chip_start_finish(). It holds tx_lock while clearing the IRQ gate,
unmasking interrupts and waking the queue. A new bus-off must acquire the
same lock in rkcanfd_tx_disable() before publishing BUS_OFF and stopping
the controller, so it takes precedence over startup. The flag is not the
only synchronization here; an additional lock around the whole handler
is not needed for the reported interleaving.

> Can the handler see a new cycle_last together with an old nsec?

Yes, before patch 6 of v6. That pre-existing race is fixed by taking
timestamp_lock for conversion as well as timecounter updates. I will
retain that fix in v7. The worker rearming issue is already fixed by the
locked active check in patch 4 of v6 and will also remain fixed.

Best regards,
Cunhao Lu

pw-bot: cr