From: Andrei Lalaev <andrey.lalaev@gmail.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: mailhol.vincent@wanadoo.fr, linux-kernel@vger.kernel.org,
linux-can@vger.kernel.org
Subject: Re: [RFC PATCH] can: gs_usb: fix kernel oops during restart
Date: Wed, 16 Jul 2025 07:45:08 +0200 [thread overview]
Message-ID: <988d9355-2243-4187-b4ab-78652a1fb008@gmail.com> (raw)
In-Reply-To: <20250715-smart-ultra-avocet-d7937a-mkl@pengutronix.de>
On 15.07.2025 16:29, Marc Kleine-Budde wrote:
> On 15.07.2025 16:24:22, Andrei Lalaev wrote:
>> I was also surprised because this callback isn't marked as mandatory
>> and that there are no additional checks.
>>
>>>
>>> What about this fix?
>>>
>>> diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
>>> index 13826e8a707b..94603c9eb4aa 100644
>>> --- a/drivers/net/can/dev/netlink.c
>>> +++ b/drivers/net/can/dev/netlink.c
>>> @@ -285,6 +285,12 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
>>> }
>>>
>>> if (data[IFLA_CAN_RESTART_MS]) {
>>> + if (!priv->do_set_mode) {
>>> + NL_SET_ERR_MSG(extack,
>>> + "device doesn't support restart from Bus Off");
>>> + return -EOPNOTSUPP;
>>> + }
>>> +
>>> /* Do not allow changing restart delay while running */
>>> if (dev->flags & IFF_UP)
>>> return -EBUSY;
>>> @@ -292,6 +298,12 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
>>> }
>>>
>>> if (data[IFLA_CAN_RESTART]) {
>>> + if (!priv->do_set_mode) {
>>> + NL_SET_ERR_MSG(extack,
>>> + "device doesn't support restart from Bus Off");
>>> + return -EOPNOTSUPP;
>>> + }
>>> +
>>> /* Do not allow a restart while not running */
>>> if (!(dev->flags & IFF_UP))
>>> return -EINVAL;
>>
>> Thanks for the patch. As expected, it fixes the kernel OOPS,
>> but the interface never leaves the BUS_OFF state.
>
> Which device and which firmware are you using?
>
> The gs_usb/candlelight interface is un(der)defined when it comes to
> bus-off handling.
>
> I think the original candlelight with the stm32f072 does auto bus-off
> recovery. Not sure about the candlelight on stm32g0b1.
>
> regards,
> Marc
>
Sorry, my bad for not mentioning it earlier. I have several USB-CAN adapters:
- two are based on STM32F072 (not original CandleLight, but using the same FW)
- one is a original CandleLightFD on STM32G0B1, that I used for testing
And all of them behave exactly as you described:
- both STM32F072-based automatically recover from BUS_OFF and I see
it in `ip -details link show can0`
- STM32G0B1-based doesn't recover and I have to down/up interface to restore it
Since this is expected behavior and no kernel OOPS occurs,
I will switch to your patch.
Thanks a lot for the patch and your help!
--
Best regards,
Andrei Lalaev
next prev parent reply other threads:[~2025-07-16 5:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 17:55 [RFC PATCH] can: gs_usb: fix kernel oops during restart Andrei Lalaev
2025-07-15 9:37 ` Marc Kleine-Budde
2025-07-15 14:24 ` Andrei Lalaev
2025-07-15 14:29 ` Marc Kleine-Budde
2025-07-16 5:45 ` Andrei Lalaev [this message]
2025-07-16 5:55 ` Marc Kleine-Budde
2025-10-20 10:12 ` Marc Kleine-Budde
2025-10-20 10:12 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=988d9355-2243-4187-b4ab-78652a1fb008@gmail.com \
--to=andrey.lalaev@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox