Possible race condition during mode switch
Posted: 03 Jun 2014, 03:03
In developing some new software I ran into an issue with usb_modeswitch. The best I have been able to determine is that there is a race condition.
Setup:
Arch Linux running on a Raspberry Pi
Linux Kernel - I have tried both 3.6.11-11 and 3.12.20-3 (which is the latest)
I am using a Verzion USB760 modems
Problem:
During system boot the modem identifies two mass storage devices: a drive and a cdrom.
As the corresponding drivers are initializing the udev rules detect the device availability
and trigger the modeswitch. This is were the fun begins... sometimes the modeswitch completes
but the 4 ttyUSBX devices do not show up and short of power cycling the Pi nothing you do fixes
the problem. The Pi and the modem must power cycle in order to straight out the problem.
What I have noticed is that if you slow down the modeswitch give the kernel time to complete
the driver initialization before the modeswitch is activated then it works flawlessly but if it
happens to quickly then it can leave the modem/kernel is a weird state that will not easily
recover from (and usually requires a power cycle to fix).
I have a solution now which does not use modeswitch at all, I was able to determine a way to resolve the race condition reliably, I also tried setting "SetStorageDelay=20" for some reason this did not help it only slowed down the process of doing a modeswitch.
My current solution I wait for the /dev/sr0 device to appear at which point I use 'eject /dev/sr0' to active the modeswitch and then everything works great (never fails).
Any suggestion or insight into what is going on would be helpfull.
Setup:
Arch Linux running on a Raspberry Pi
Linux Kernel - I have tried both 3.6.11-11 and 3.12.20-3 (which is the latest)
I am using a Verzion USB760 modems
Problem:
During system boot the modem identifies two mass storage devices: a drive and a cdrom.
As the corresponding drivers are initializing the udev rules detect the device availability
and trigger the modeswitch. This is were the fun begins... sometimes the modeswitch completes
but the 4 ttyUSBX devices do not show up and short of power cycling the Pi nothing you do fixes
the problem. The Pi and the modem must power cycle in order to straight out the problem.
What I have noticed is that if you slow down the modeswitch give the kernel time to complete
the driver initialization before the modeswitch is activated then it works flawlessly but if it
happens to quickly then it can leave the modem/kernel is a weird state that will not easily
recover from (and usually requires a power cycle to fix).
I have a solution now which does not use modeswitch at all, I was able to determine a way to resolve the race condition reliably, I also tried setting "SetStorageDelay=20" for some reason this did not help it only slowed down the process of doing a modeswitch.
My current solution I wait for the /dev/sr0 device to appear at which point I use 'eject /dev/sr0' to active the modeswitch and then everything works great (never fails).
Any suggestion or insight into what is going on would be helpfull.