can: dev: can_set_termination(): Allow gpio sleep
Subsystems (4)
PATCH 1/1 can: dev: can_set_termination(): Allow gpio sleep
The current implementation of can_set_termination() sets the GPIO in a context which cannot sleep. This is an issue if the GPIO controller can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Thus, if the termination resistor is set (eg. with ip link), a warning splat will be issued in the kernel log.
Fix this by setting the termination resistor with gpiod_set_value_cansleep() which instead of gpiod_set_value() allows it to sleep.
--- drivers/net/can/dev/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev/dev.c +1 -1
@@ -468,7 +468,7 @@ static int can_set_termination(struct net_device *ndev, u16 term)else set =0 ; -gpiod_set_value (priv->termination_gpio, set); +gpiod_set_value_cansleep (priv->termination_gpio, set);return 0 ; }
Signature · 1 line
2.39.5
Marc Kleine-Budde
maintainerHello Nicolai,
thanks for your contribution!
Quoted 6 lines · Nicolai Buchwitz
The current implementation of
can_set_termination()sets the GPIO in a context which cannot sleep. This is an issue if the GPIO controller can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Thus, if the termination resistor is set (eg. with ip link), a warning splat will be issued in the kernel log.
Quoted 6 lines
Fix this by setting the termination resistor with
gpiod_set_value_cansleep()which instead ofgpiod_set_value()allows it to sleep.Signed-off-by Nicolai Buchwitz <[email protected]>
I've send the same patch a few hours ago:
https://lore.kernel.org/all/20241121-dev-fix-can_set_termination-v1-1-41fa6e29216d@pengutronix.de/
Marc
Signature · 4 lines
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 |
Hi,
Quoted 15 lines · Marc Kleine-Budde
Hello Nicolai,
thanks for your contribution!
Quoted 10 lines · Nicolai Buchwitz
The current implementation of
can_set_termination()sets the GPIO in a context which cannot sleep. This is an issue if the GPIO controller can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Thus, if the termination resistor is set (eg. with ip link), a warning splat will be issued in the kernel log.Fix this by setting the termination resistor with
gpiod_set_value_cansleep()which instead ofgpiod_set_value()allows it to sleep.
Quoted 9 lines
Quoted 2 lines
Signed-off-by Nicolai Buchwitz <[email protected]>I've send the same patch a few hours ago:
https://lore.kernel.org/all/20241121-dev-fix-can_set_termination-v1-1-41fa6e29216d@pengutronix.de/
Marc
Shouldnt this also go to stable?
Regards,
Lino
Marc Kleine-Budde
maintainerQuoted 11 lines · Lino Sanfilippo
Quoted 11 lines · Nicolai Buchwitz
Quoted 10 lines
The current implementation of
can_set_termination()sets the GPIO in a context which cannot sleep. This is an issue if the GPIO controller can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Thus, if the termination resistor is set (eg. with ip link), a warning splat will be issued in the kernel log.Fix this by setting the termination resistor with
gpiod_set_value_cansleep()which instead ofgpiod_set_value()allows it to sleep.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Signed-off-by Nicolai Buchwitz <[email protected]>I've send the same patch a few hours ago:
https://lore.kernel.org/all/20241121-dev-fix-can_set_termination-v1-1-41fa6e29216d@pengutronix.de/
Shouldnt this also go to stable?
Until today no-one complained about the problem, but I'll add stable on Cc while applying the patch.
regards,
Marc
Signature · 4 lines
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 |
Quoted 19 lines · Marc Kleine-Budde
Quoted 18 lines · Lino Sanfilippo
Quoted 18 lines · Nicolai Buchwitz
Quoted 6 lines
The current implementation of
can_set_termination()sets the GPIO in a context which cannot sleep. This is an issue if the GPIO controller can sleep (e.g. since the concerning GPIO expander is connected via SPI or I2C). Thus, if the termination resistor is set (eg. with ip link), a warning splat will be issued in the kernel log.Quoted 6 lines
Fix this by setting the termination resistor with
gpiod_set_value_cansleep()which instead ofgpiod_set_value()allows it to sleep.Signed-off-by Nicolai Buchwitz <[email protected]>I've send the same patch a few hours ago:
https://lore.kernel.org/all/20241121-dev-fix-can_set_termination-v1-1-41fa6e29216d@pengutronix.de/
Quoted 8 lines
Quoted 1 line
Shouldnt this also go to stable?
Until today no-one complained about the problem, but I'll add stable on Cc while applying the patch.
regards,
Marc
Great, thanks!
BR,
Lino