mcp251x Error during multiple ip link ups/downs
Describe the bug
Hello,
I work with the CAN bus (simple write and reads works fine) I wanted to prepare automatic detection of the baud rate. The problem occurs when we changing interface settings in a loop. After a few tries, "RTNETLINK Replies: Connection Timeout" appears and the Raspberry Pi hangs.
I founded similar problem at fork but for mcp25xxfd driver https://github.com/msperl/linux-rpi/issues/12
Steps to reproduce the behaviour
Connect to a CAN bus device that sends data and run script at Raspberry Pi. I added sleeps to check if this could help
#!/bin/bash
array=(10000 20000 50000 100000 125000 250000 500000 800000 1000000)
can=$1
while true
do
for i in "${array[@]}"
do
echo $i
sleep 1
sudo ip link set $can down
sleep 1
sudo ip link set $can up type can bitrate $i
sleep 1
candump $can -T 100
done
done
Device (s)
Raspberry Pi CM4 Lite
System
Raspberry Pi reference 2023-10-10 Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 962bf483c8f326405794827cce8c0313fd5880a8, stage2
Aug 10 2023 15:33:38 Copyright (c) 2012 Broadcom version 03dc77429335caee083e22ddc8eec09c07f12a7a (clean) (release) (start)
Linux raspberrypi 6.1.0-rpi4-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux
Logs
Feb 21 14:40:10 raspberrypi kernel: mcp251x spi0.0: MCP251x didn't enter in config mode Feb 21 14:40:10 raspberrypi kernel: A link change request failed with some changes committed already. Interface can1 may have been left with an inconsistent configuration, please check.
Additional context
No response