Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

udev rule not triggering

Need help with peripherals or devices?
Post Reply
Message
Author
jyoung
Posts: 8
Joined: 2017-11-30 19:56

udev rule not triggering

#1 Post by jyoung »

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!

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: udev rule not triggering

#2 Post by Head_on_a_Stick »

Apply the usbcore.autosuspend=-1 kernel command line parameter (via /etc/default/grub & `update-grub`).
deadbang

jyoung
Posts: 8
Joined: 2017-11-30 19:56

Re: udev rule not triggering

#3 Post by jyoung »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: udev rule not triggering

#4 Post by debiman »

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
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: udev rule not triggering

#5 Post by Head_on_a_Stick »

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
deadbang

jyoung
Posts: 8
Joined: 2017-11-30 19:56

Re: udev rule not triggering

#6 Post by jyoung »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: udev rule not triggering

#7 Post by Head_on_a_Stick »

jyoung wrote:I attempted to add the usbcore.autosuspend=-1 to grub
If you showed us exactly what you did rather than just describing it vaguely then we could tell you where you went wrong ;)

Hint: GRUB_CMDLINE_LINUX
I directory edited the /boot/grub/grub.cfg file. I know it's inadvisable, but it did work
It will break again after the next kernel update, /etc/default/grub is the correct file for user modifications.
deadbang

Post Reply