mcp251x can't drop the can0 Interface
I guess you might say that I'm playing with an MCP2515 connected to a RaspberryPi. I've got a problem which I've asked about on the RaspberryPi forum but have never received an answer, so as a last resort I thought I'd try here.
Basically I bring up the MCP2515 in listen mode at a certain baud rate. I wanted to work on auto detetection of baud rate. So after listening for a period of time at a certain baud rate I try to change the baud rate but I can't do that with the linux mcp251x driver (I don't think it's the driver's fault but have no idea whose it is). I've put in some debug statements to see what happens when I execute "ifconfig can0 down" and basically the interface goes down momentarily and then gets brough straight back up again. So when I try to use the "ip" command to set the new baud rate I get an error that the device is busy.
Now I'm not sure if the issue is in the linux kernel or in the system utilities "ifconfig" and "ip", but just wondered if anybody has seen this behaviour. (I saw that there was a book published in January on linux networking and must see if it deals with internals or just socket programming.) If somebody could point me in the correct direction to look I'd be very grateful. Or if somebody can confirm or deny this behaviour.
Marc Kleine-Budde
maintainerQuoted 5 lines · John Whitmore
I guess you might say that I'm playing with an MCP2515 connected to a RaspberryPi. I've got a problem which I've asked about on the RaspberryPi forum but have never received an answer, so as a last resort I thought I'd try here.
Quoted 9 lines
Basically I bring up the MCP2515 in listen mode at a certain baud rate. I wanted to work on auto detetection of baud rate. So after listening for a period of time at a certain baud rate I try to change the baud rate but I can't do that with the linux mcp251x driver (I don't think it's the driver's fault but have no idea whose it is). I've put in some debug statements to see what happens when I execute "ifconfig can0 down" and basically the interface goes down momentarily and then gets brough straight back up again. So when I try to use the "ip" command to set the new baud rate I get an error that the device is busy.
Please add this patch to the driver:
-------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
drivers/net/can/mcp251x.c +4 -0
@@ -697,6 +697,8 @@ static int mcp251x_stop(struct net_device *net)struct mcp251x_priv *priv =netdev_priv (net);struct spi_device *spi = priv->spi; +dump_stack (); +close_candev (net); priv->force_quit =1 ;
@@ -941,6 +943,8 @@ static int mcp251x_open(struct net_device *net)unsigned long flags =IRQF_ONESHOT |IRQF_TRIGGER_FALLING ;int ret; +dump_stack (); + ret =open_candev (net);if (ret) {dev_err (&spi->dev,"unable to set initial baudrate!\n" );
-------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
Then reproduce your problem, then send dmesg output.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Quoted 44 lines · Marc Kleine-Budde
Quoted 5 lines · John Whitmore
I guess you might say that I'm playing with an MCP2515 connected to a RaspberryPi. I've got a problem which I've asked about on the RaspberryPi forum but have never received an answer, so as a last resort I thought I'd try here.
Quoted 9 lines
Basically I bring up the MCP2515 in listen mode at a certain baud rate. I wanted to work on auto detetection of baud rate. So after listening for a period of time at a certain baud rate I try to change the baud rate but I can't do that with the linux mcp251x driver (I don't think it's the driver's fault but have no idea whose it is). I've put in some debug statements to see what happens when I execute "ifconfig can0 down" and basically the interface goes down momentarily and then gets brough straight back up again. So when I try to use the "ip" command to set the new baud rate I get an error that the device is busy.
Please add this patch to the driver:
-------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
drivers/net/can/mcp251x.c +4
-1@@ -697,6 +697,8 @@ static int mcp251x_stop(struct net_device *net)struct mcp251x_priv *priv =netdev_priv (net);struct spi_device *spi = priv->spi; +dump_stack (); +close_candev (net); priv->force_quit =1 ;@@ -941,6 +943,8 @@ static int mcp251x_open(struct net_device *net)unsigned long flags =IRQF_ONESHOT |IRQF_TRIGGER_FALLING ;int ret; +dump_stack (); + ret =open_candev (net);if (ret) {dev_err (&spi->dev,"unable to set initial baudrate!\n" ); -------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
Quoted 2 lines
Then reproduce your problem, then send dmesg output.
Sorry for the slight delay went from the RaspberryPi 3.6 Kernel to the 3.10 to see if maybe the later version worked. I'm afraid neither worked.
John
Quoted 8 lines
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Marc Kleine-Budde
maintainerQuoted 2 lines · John Whitmore
Sorry for the slight delay went from the RaspberryPi 3.6 Kernel to the 3.10 to see if maybe the later version worked. I'm afraid neither worked.
Your "ifplugd" is meesing around with the CAN interface.
Quoted 11 lines
[ 86.044493] CPU: 0 PID: 1713 Comm: ifplugd Not tainted 3.10.29-can+ #2 [ 86.044583] [<c0013aa4>] (unwind_backtrace+0x0/0xf0) from [<c0010e00>] (show_stack+0x10/0x14) [ 86.044642] [<c0010e00>] (show_stack+0x10/0x14) from [<bf00ddd4>] (mcp251x_open+0x18/0x1d0 [mcp251x]) [ 86.044694] [<bf00ddd4>] (mcp251x_open+0x18/0x1d0 [mcp251x]) from [<c0327544>] (__dev_open+0xd4/0x144) [ 86.044728] [<c0327544>] (__dev_open+0xd4/0x144) from [<c0327788>] (__dev_change_flags+0x88/0x130) [ 86.044756] [<c0327788>] (__dev_change_flags+0x88/0x130) from [<c032789c>] (dev_change_flags+0x10/0x48) [ 86.044795] [<c032789c>] (dev_change_flags+0x10/0x48) from [<c0381ba0>] (devinet_ioctl+0x630/0x6f8) [ 86.044839] [<c0381ba0>] (devinet_ioctl+0x630/0x6f8) from [<c031195c>] (sock_ioctl+0x70/0x298) [ 86.044882] [<c031195c>] (sock_ioctl+0x70/0x298) from [<c00dc174>] (do_vfs_ioctl+0x7c/0x5c4) [ 86.044913] [<c00dc174>] (do_vfs_ioctl+0x7c/0x5c4) from [<c00dc6f4>] (SyS_ioctl+0x38/0x60) [ 86.044947] [<c00dc6f4>] (SyS_ioctl+0x38/0x60) from [<c000db40>] (ret_fast_syscall+0x0/0x30)
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Quoted 18 lines · Marc Kleine-Budde
Quoted 2 lines · John Whitmore
Sorry for the slight delay went from the RaspberryPi 3.6 Kernel to the 3.10 to see if maybe the later version worked. I'm afraid neither worked.
Your "ifplugd" is meesing around with the CAN interface.
Quoted 11 lines
[ 86.044493] CPU: 0 PID: 1713 Comm: ifplugd Not tainted 3.10.29-can+ #2 [ 86.044583] [<c0013aa4>] (unwind_backtrace+0x0/0xf0) from [<c0010e00>] (show_stack+0x10/0x14) [ 86.044642] [<c0010e00>] (show_stack+0x10/0x14) from [<bf00ddd4>] (mcp251x_open+0x18/0x1d0 [mcp251x]) [ 86.044694] [<bf00ddd4>] (mcp251x_open+0x18/0x1d0 [mcp251x]) from [<c0327544>] (__dev_open+0xd4/0x144) [ 86.044728] [<c0327544>] (__dev_open+0xd4/0x144) from [<c0327788>] (__dev_change_flags+0x88/0x130) [ 86.044756] [<c0327788>] (__dev_change_flags+0x88/0x130) from [<c032789c>] (dev_change_flags+0x10/0x48) [ 86.044795] [<c032789c>] (dev_change_flags+0x10/0x48) from [<c0381ba0>] (devinet_ioctl+0x630/0x6f8) [ 86.044839] [<c0381ba0>] (devinet_ioctl+0x630/0x6f8) from [<c031195c>] (sock_ioctl+0x70/0x298) [ 86.044882] [<c031195c>] (sock_ioctl+0x70/0x298) from [<c00dc174>] (do_vfs_ioctl+0x7c/0x5c4) [ 86.044913] [<c00dc174>] (do_vfs_ioctl+0x7c/0x5c4) from [<c00dc6f4>] (SyS_ioctl+0x38/0x60) [ 86.044947] [<c00dc6f4>] (SyS_ioctl+0x38/0x60) from [<c000db40>] (ret_fast_syscall+0x0/0x30)
oops have to look into that. Learning something new every day. Thanks a million for your help!
Quoted 8 lines
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |