udev rule not triggering

Getting your soundcard to work, using Debian on non-i386 hardware, etc

udev rule not triggering

Postby jyoung » 2017-12-01 03:00

Hi,

I'm running debian 4.9 with xfce on a surface pro 4. I've got a presentation pointer mouse that goes into autosuspend after 2 seconds, which is pretty annoying during a presentation. One solution seems to be to change the '2' to a '0' or '-1' in /sys/bus/usb/devices/1-1/power/autosuspend. That works, but it needs to be changed every time I plug the mouse in. I've attempted to write a udev rule to do this every time the mouse gets plugged in, but the rule doesn't seem to have any effect:

ACTION=="add", ATTRS{idVendor}=="046d", RUN:="/bin/echo -1 > /sys/bus/usb/devices/1-1/power/autosuspend"

To see if this rule was actually being followed, I changed it to

ACTION=="add", ATTRS{idVendor}=="046d", RUN:="/bin/echo -1 > /home/jyoung/test"

The file 'test' is never created. When I use udevadm to see what rules get checked when this device is plugged in, my rule is in the list. But, I can figure out why it's not triggering. I've checked the idVendor value, it's certainly right. Does anyone have any suggestions? Or, is there a cleaner way to do this? I would have guessed that there would be an easy way to turn off autosuspend for a given device.

Any help would be valued!
jyoung
 
Posts: 3
Joined: 2017-11-30 19:56

Re: udev rule not triggering

Postby Head_on_a_Stick » 2017-12-01 06:30

Apply the usbcore.autosuspend=-1 kernel command line parameter (via /etc/default/grub & `update-grub`).
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6787
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: udev rule not triggering

Postby jyoung » 2017-12-01 14:29

Will that turn off autosuspend for all usb devices? Is there a way to do it on a device-specific basis?
I think there's a lot to be said for powering down devices when they're not needed.

Although, maybe it would be worth prevent autosuspend for all usb devices. autosuspend is of a weird behavior to have, where a device is powered down in a way that makes it unresponsive for a 5-10 seconds even when there is activity. I can imagine that it would be equally frustrating with, say, a memory stick. Which actually brings up a good point, I have used usb memory sticks and I haven't noticed this problem. Maybe the lag aspect is specific to this device.
jyoung
 
Posts: 3
Joined: 2017-11-30 19:56

Re: udev rule not triggering

Postby debiman » 2017-12-02 08:30

this article has been pretty helpful for me.
the 'udevadm' command has some extra commands, i remember that 'udevadm monitor' helped.
i'm sure you can crack this.
User avatar
debiman
 
Posts: 1619
Joined: 2013-03-12 07:18

Re: udev rule not triggering

Postby Head_on_a_Stick » 2017-12-02 10:53

jyoung wrote:
Code: Select all
ACTION=="add", ATTRS{idVendor}=="046d", RUN:="/bin/echo -1 > /sys/bus/usb/devices/1-1/power/autosuspend"

Try this instead:
Code: Select all
ACTION=="add", ATTRS{idVendor}=="046d", RUN:="/usr/local/bin/stopsuspend"

And create the separate stopsuspend script (with the requisite permissions, ofc):
Code: Select all
# tee /usr/local/bin/stopsuspend <<< "/bin/echo -1 > /sys/bus/usb/devices/1-1/power/autosuspend"
# chmod +x /usr/local/bin/stopsuspend
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6787
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: udev rule not triggering

Postby jyoung » 2017-12-14 00:59

Hi Folks,

I attempted to add the usbcore.autosuspend=-1 to grub, but, to make a long story short, I overwrote my bootloader and ended up having to reinstall the system. I'm honestly more familiar with grub 1 and lilo.

Once it was setup again, I directory edited the /boot/grub/grub.cfg file. I know it's inadvisable, but it did work. The usb pointer mouse no longer goes into autosuspend.

debiman, the article you posted is really good; that's what prompted me to try to write a udev rule.
jyoung
 
Posts: 3
Joined: 2017-11-30 19:56


Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable