Re: [PATCH can] can: rockchip: rk3576: fix rtnl_lock deadlock during interface down under bus traffic
From: Marc Kleine-Budde
Date: Mon Aug 17 2026 - 12:27:17 EST
On 17.08.2026 09:37:50, Cheng Liu wrote:
> When bringing the CAN interface down (via `ip link set can0 down`) while
> there is heavy incoming CAN traffic or continuous hardware error frames,
> the system hangs and deadlocks. Existing and new networking operations
> (such as `ifconfig`, SSH logins, Socket operations) hang indefinitely
> waiting for `rtnl_lock`.
>
> The deadlock occurs because `rk3576_canfd_close()` calls `napi_disable()`
> before `rk3576_canfd_stop()`. Since hardware interrupts are still
> active, incoming CAN frames and error interrupts continuously trigger
> `napi_schedule()`, preventing `napi_disable()` from seeing the
> `NAPI_STATE_SCHED` bit cleared and causing it to loop infinitely in
> `msleep(1)`. Because `dev_close()` holds the global `rtnl_lock`, the
> entire networking subsystem deadlocks:
>
> Call trace:
> __switch_to+0xdc/0x120
> __schedule+0x2ac/0x840
> schedule+0x54/0xe0
> schedule_hrtimeout_range_clock+0x98/0x134
> usleep_range_state+0x7c/0xb0
> napi_disable+0xc0/0x110
> rk3576_canfd_close+0x44/0xd0
> __dev_close_many+0xb0/0x14c
> dev_change_flags+0x28/0x64
> do_setlink+0x618/0xe2c
> rtnetlink_rcv_msg+0x2a8/0x380
>
> Fix this by:
> 1. Reordering `rk3576_canfd_close()` to call `rk3576_canfd_stop()` before
> `napi_disable()`, ensuring interrupts are disabled and controller is
> in reset mode before waiting for NAPI to complete.
> 2. Standardizing `rk3576_canfd_rx_poll()` to respect the NAPI
> quota/budget and properly complete NAPI polling via
> `napi_complete_done()`.
> 3. Guarding against NULL pointer dereference in `rk3576_canfd_err()` when
> `alloc_can_err_skb()` fails, and calling `can_bus_off()` upon bus-off.
>
> Signed-off-by: Cheng Liu <chengliu480@xxxxxxxxx>
> ---
> drivers/net/can/rockchip/rk3576_canfd.c | 61 +++++++++++++------------
The driver for the rk3576 is not mainline, yet. Maybe Elaine can pick it
up.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature