Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Marc Kleine-Budde
Tue, 13 Oct 2026 10:58
Re: [PATCH net] can: rockchip_canfd: stop bus-off restart before closing the device
Author: Marc Kleine-Budde
Date: Tue, 13 Oct 2026 10:58
Date: Tue, 13 Oct 2026 10:58
65 lines
10672 bytes
10672 bytes
--25w3tbmyskksrjyb
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [PATCH net] can: rockchip_canfd: stop bus-off restart before
closing the device
MIME-Version: 1.0
On 13.10.2026 11:22:37, Cunhao Lu wrote:
> The close path cancels restart_work after freeing the IRQ and stopping
> hardware. A queued bus-off restart can therefore enable the controller
> and interrupts after teardown. It can also restart timestamp work before
> runtime suspend.
>
> Serialize restart with the close transition using a mutex. Mark the
> device closing and mask its interrupts before synchronizing the IRQ.
> Release the mutex before cancelling restart_work, so a queued restart
> can observe the closing state without deadlocking.
>
> Exclude the IRQ handler while reinitializing the hardware on restart.
> Do not disable the shared IRQ line while waiting for work to finish.
>
> Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD=
controller")
> Cc: stable@vger.kernel.org
> Signed-off-by: Cunhao Lu <1579567540@qq.com>
AFAICS this is a systematic problem and should IMHO not worked around in
one driver only.
netif_running() tests __LINK_STATE_START, which is removed in
__dev_close_many() prior to calling the driver's ndo_stop().
Can we make use of netif_running() prior to calling do_set_mode(dev,
CAN_MODE_START)? from can_restart()?
can_bus_off() should not schedule_delayed_work() if !netif_running().
We still have to call cancel_delayed_work_sync(&priv->can.restart_work)
=66rom each driver, though.
What do you think?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
--25w3tbmyskksrjyb
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQSl+MghEFFAdY3pYJLMOmT6rpmt0gUCas4O2wAKCRDMOmT6rpmt
0q+pAPwIF8wpYL7J1/gk9g6RXhUr5SARSzzpYTyGVX3yt2JlIQEAxgkwnBhMJin5
BgazUeZQAgL09GXx7TEVzKpH1RZCUw0=
=mEzK
-----END PGP SIGNATURE-----
--25w3tbmyskksrjyb--
Re: [PATCH net] can: rockchip_canfd: stop bus-off restart before closing the device
Author: Marc Kleine-Budde
Date: Tue, 13 Oct 2026 14:27
Date: Tue, 13 Oct 2026 14:27
93 lines
11637 bytes
11637 bytes
--p2fdgwty2yztquzs Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH net] can: rockchip_canfd: stop bus-off restart before closing the device MIME-Version: 1.0 On 13.10.2026 21:06:21, Cunhao Lu wrote: > Hi Marc, > > > AFAICS this is a systematic problem and should IMHO not worked around in > > one driver only. > > Agreed. I initially only noticed the problem in the Rockchip CAN-FD > driver and did not consider the common CAN code. Thanks to your analysis, it was easy to reach that conclusion. :) > > netif_running() tests __LINK_STATE_START, which is removed in > > __dev_close_many() prior to calling the driver's ndo_stop(). > > > > Can we make use of netif_running() prior to calling do_set_mode(dev, > > CAN_MODE_START)? from can_restart()? > > If you have no objections, I think it would be better to put the > netif_running() check after the existing !priv->do_set_mode check and > before netif_carrier_ok(): > > if (!priv->do_set_mode) > return -EOPNOTSUPP; > > if (!netif_running(dev)) > return -ENETDOWN; > > This would preserve the existing error precedence for devices that do > not support restart. ACK > > can_bus_off() should not schedule_delayed_work() if !netif_running(). > > Agreed. Although this would change the behavior of some drivers, I think > it should help improve stability. ok > > We still have to call cancel_delayed_work_sync(&priv->can.restart_work) > > from each driver, though. Let's wrap that into a function and put this into linux/can/dev.h. It's name could be something like close_candev_cancel_restart_sync(). > I can make changes to the other drivers. However, I do not have the > corresponding hardware and would not be able to test the changes on > real devices, so I am concerned about the risk. I would like to confirm: > do I need to audit and fix the restart behavior of every CAN device > driver? I think it's OK to fix the rockchip driver only. > > What do you think? > > I will address these comments in v2. Thanks for your review. Please split the changes into several patches: - fix the existing infrastructure - add new close_candev_cancel_restart_sync() function - use this function in the rockchip driver regards, Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 | --p2fdgwty2yztquzs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSl+MghEFFAdY3pYJLMOmT6rpmt0gUCas4/wQAKCRDMOmT6rpmt 0sMkAP9SLysRPyc/bN1kfprQlX5GQAMSIsfWuKXrKvknT5XDYQD/fce1XVIeVE/g Wu3BWgWdmmI0Sq7/V4pT4SEDHKDXXQM= =J0Bg -----END PGP SIGNATURE----- --p2fdgwty2yztquzs--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads