Unexpected behaviour of UDEV + USB device detection

116 Views Asked by At

I am working with an embedded platform running Linux (Yocto). I have created a set of UDEV rules that detect the plug/unplug of an external USB sound card. The rules are firing some scripts used for audio capturing, etc.

ACTION=="add", SUBSYSTEMS=="usb", DRIVERS=="snd-usb-audio", RUN+="/usr/bin/audio.sh start"

ACTION=="remove", ENV{ID_MODEL}=="xxxxxx", RUN+="/usr/bin/audio.sh stop"

The first time I connect and disconnect the device, everything works as expected: device is enumerated and recognised correctly and rules are fired starting and stopping the script. The erroneous behaviour begins when I reconnect the device; exactly one minute later I'm getting the message:

udevd[128]: worker [559] /devices/platform/soc/2100000.bus/2184000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0 is taking a long time

In the meantime, the "add" rule has fired and the script has run. Two minutes after that the following messages appear:

[981.155879] udevd[559]: timeout '/usr/bin/audio.sh start'

[984.571667] usb 1-1: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x200, type = 4

[984.622923] usb 1-1: cannot get ctl value: req = 0x81, wValue = 0x202, wIndex = 0x200, type = 4

[984.676660] usb 1-1: cannot get ctl value: req = 0x81, wValue = 0x102, wIndex = 0x200, type = 1

If I disconnect the device at this point, the "remove" UDEV rule is fired correctly and stops the process. If I do it earlier, then the "remove" rule does not fire at all, until this worker times out.

Now, I have checked my script and reduced it, to basically run only one command. In that case, the messages are different:

[1924.275992] udevd[128]: worker [843] /devices/platform/soc/2100000.bus/2184000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0 timeout; kill it

[1924.301369] udevd[128]: seq 2041 '/devices/platform/soc/2100000.bus/2184000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0' killed

[1924.313188] udevd[128]: worker [843] terminated by signal 9 (Killed)

[1924.326581] udevd[128]: worker [843] failed while handling '/devices/platform/soc/2100000.bus/2184000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0'

I have tried reducing the timeout by changing the event_timeout property in udev.conf to 5 seconds; however, no change in the behaviour. I have also tried with different devices, however the results are exactly the same. At this point I don't have the slightest idea of where to even begin looking, so any help would be greatly appreciated.

0

There are 0 best solutions below