You are not logged in.

#1 2013-10-26 09:57:56

athal
Member
Registered: 2012-05-29
Posts: 16

USB Mouse autosuspends after 2 seconds

Hello dear Community


I have a problem with my USB mouse on my laptop. It autosuspends after 2 seconds when my laptop is on battery power. When AC is plugged in, the mouse works without problems normally. But sometimes (I couldn't find any underling rule for this behaviour) the mouse autosuspends also after 2 seconds when power IS plugged in.

First things first:

lsusb yields:

Bus 002 Device 003: ID 8087:07da Intel Corp. 
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 2232:1045  
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 003 Device 002: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So the Mouse I am talking about has the ID 045e:00cb

After unplugging the mouse dmesg gives me:

[  420.549995] usb 3-2: USB disconnect, device number 2
[  422.770284] usb 3-2: new low-speed USB device number 4 using xhci_hcd
[  422.789282] usb 3-2: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes
[  422.792590] input: Microsoft  Microsoft Basic Optical Mouse v2.0  as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/input/input12
[  422.792991] hid-generic 0003:045E:00CB.0002: input,hidraw0: USB HID v1.11 Mouse [Microsoft  Microsoft Basic Optical Mouse v2.0 ] on usb-0000:00:14.0-2/input0

I thought that laptopmode tools is the reason for the problems, so tried the advice posted on this blog. I made a udev rule

[nikolai@niko-arch ~]$ cat /etc/udev/rules.d/91-local-rules 
# Add rule to turn of autosuspend for specific mouse
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="045e", ATTR{idProduct}=="00cb", TEST=="power/control", ATTR{power/control}="on"

and changed my laptopmode tools settings:

[nikolai@niko-arch ~]$ cat /etc/laptop-mode/conf.d/usb-autosuspend.conf 
#
# Configuration file for Laptop Mode Tools module usb-autosuspend.
#
# For more information, consult the laptop-mode.conf(8) manual page.
#


###############################################################################
# USB autosuspend settings
# ------------------------
#
#__COMMENT If you enable this setting, laptop mode tools will automatically enable the
#__COMMENT USB autosuspend feature for all devices.
#__COMMENT
#__COMMENT NOTE: Some USB devices claim they support autosuspend, but implement it in a
#__COMMENT broken way. This can mean keyboards losing keypresses, or optical mice turning
#__COMMENT their LED completely off. If you have a device that misbehaves, add its USB ID
#__COMMENT to the blacklist below and complain to your hardware vendor.
#
################################################################################

# Enable debug mode for this module
# Set to 1 if you want to debug this module
DEBUG=0

# Enable USB autosuspend feature?
# Set to 0 to disable
CONTROL_USB_AUTOSUSPEND="auto"

# Set this to use opt-in/whitelist instead of opt-out/blacklist for deciding
# which USB devices should be autosuspended.
# AUTOSUSPEND_USE_WHITELIST=0 means AUTOSUSPEND_*_BLACKLIST will be used.
# AUTOSUSPEND_USE_WHITELIST=1 means AUTOSUSPEND_*_WHITELIST will be used.
AUTOSUSPEND_USE_WHITELIST=0

# The list of USB IDs that should not use autosuspend. Use lsusb to find out the
# IDs of your USB devices.
# Example: AUTOSUSPEND_USBID_BLACKLIST="046d:c025 0123:abcd"
AUTOSUSPEND_USBID_BLACKLIST="045e:00cb"

# The list of USB driver types that should not use autosuspend.  The driver
# type is given by "DRIVER=..." in a USB device's uevent file.
# Example: AUTOSUSPEND_USBID_BLACKLIST="usbhid usb-storage"
AUTOSUSPEND_USBTYPE_BLACKLIST=""

# The list of USB IDs that should use autosuspend. Use lsusb to find out the
# IDs of your USB devices.
# Example: AUTOSUSPEND_USBID_WHITELIST="046d:c025 0123:abcd"
AUTOSUSPEND_USBID_WHITELIST=""

# The list of USB driver types that should use autosuspend.  The driver
# type is given by "DRIVER=..." in a USB device's uevent file.
# Example: AUTOSUSPEND_USBTYPE_WHITELIST="usbhid usb-storage"
AUTOSUSPEND_USBTYPE_WHITELIST=""

# Trigger auto-suspension of the USB deivce under conditional circumstances
BATT_SUSPEND_USB=1
LM_AC_SUSPEND_USB=0
NOLM_AC_SUSPEND_USB=0

# USB Auto-Suspend timeout in seconds
# Number of seconds after which the USB devices should suspend
AUTOSUSPEND_TIMEOUT=2

But I experience still the same issue (after rebooting and unplugging the mouse).

Then I tried to completely disable laptopmode tools with

CONTROL_USB_AUTOSUSPEND="0"

and rebooted, but nothing chances.

Maybe I am missing somthing obvious. Thanks for any hints!

Best Regards
Nikolai

Last edited by athal (2013-10-26 10:02:29)

Offline

#2 2013-10-26 10:06:37

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: USB Mouse autosuspends after 2 seconds

You have a bad filename! man udev says:

Rule files must have the extension .rules; other extensions are ignored.

So rename to 91-local.rules

And check it's taken effect.

Last edited by brebs (2013-10-26 10:07:41)

Offline

#3 2013-10-26 10:42:10

athal
Member
Registered: 2012-05-29
Posts: 16

Re: USB Mouse autosuspends after 2 seconds

Thanks for the reply.

[root@niko-arch rules.d]# cat 91-local.rules 
# Add rule to turn of autosuspend for specific mouse
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="045e", ATTR{idProduct}=="00cb", TEST=="power/control", ATTR{power/control}="on"
[root@niko-arch rules.d]# udevadm control --reload-rules
[root@niko-arch rules.d]# for d in /sys/bus/usb/devices/[0-9]* ; do if [[ -e $d/product ]] ; then echo -e "`basename $d`\t`cat $d/power/control`\t`cat $d/speed`\t`cat $d/product`" ; fi ; done
1-1.4	auto	480	WebCam SC-10HDP12631N
3-2	auto	1.5	Microsoft Basic Optical Mouse v2.0 
3-3	auto	480	USB2.0-CRW
[root@niko-arch rules.d]# lsusb
Bus 002 Device 003: ID 8087:07da Intel Corp. 
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 2232:1045  
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 003 Device 008: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Still doesn't work. Also when I plug power in and unplug the mouse. Should I reboot to fully confirm? I don't think it's necessary because the udev rules are reloaded when issuing the above cmd.

Offline

#4 2013-10-26 14:08:06

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: USB Mouse autosuspends after 2 seconds

You're seeing "auto" rather than "on" for the mouse, so the rule is NOT working.

I'd expect to see "on 12".

Offline

#5 2013-10-26 21:13:33

athal
Member
Registered: 2012-05-29
Posts: 16

Re: USB Mouse autosuspends after 2 seconds

Yeah I know that there should be "on". But why "on 12"? And what could I do to track down the issue? Uninstall laptop_mode? Use powertop like suggested elsewhere...

Offline

#6 2013-10-27 08:57:15

replax
Member
Registered: 2011-02-12
Posts: 90

Re: USB Mouse autosuspends after 2 seconds

Hi!
I got the same problem with my external mouse/keyboard here: https://bbs.archlinux.org/viewtopic.php?id=166517
I tried what you posted, brebs but it also did not work. If I change the power status using powertop my output of your script correctly says:

1-1.6   auto    480     Integrated Camera
3-1     auto    5000    Elements 1042
4-1.2   auto    480     USB2.0 Hub
4-1.2.2 on      12      Microsoft® SiderWinderTM X6 Keyboard
4-1.2.3 on      1.5     USB-PS/2 Optical Mouse
4-1.2.4 auto    480     USB2.0 Hub

but only with my 91-local.rules, which are basically the same as athal postest, the output is:

1-1.6   auto    480     Integrated Camera
3-1     auto    5000    Elements 1042
4-1.2   auto    480     USB2.0 Hub
4-1.2.2 auto    12      Microsoft® SiderWinderTM X6 Keyboard
4-1.2.3 auto    1.5     USB-PS/2 Optical Mouse
4-1.2.4 auto    480     USB2.0 Hub

of course i did udevadm control --reload.
it's somewhat annoying to have to start powertop everytime when you boot your pc with attached external mouse/keyboard.
Note though, I do not use laptop-tools, I do the rest of my powermanagement with udev rules, too.

[me@mybox rules.d]$ ls
42-usb_power_save.rules  91-local.rules     pci_pm.rules
80-net-name-slot.rules   disable_wol.rules  wifi_power_save.rules
[me@mybox rules.d]$ cat 42-usb_power_save.rules 
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"
[me@mybox rules.d]$ cat 91-local.rules 
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="045e", ATTR{idProduct}=="074b", TEST=="power/control", ATTR{power/control}=="on"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTR{idProduct}=="c051", TEST=="power/control", ATTR{power/control}=="on"

Thanks for any advice smile!

Last edited by replax (2013-10-27 08:59:30)

Offline

#7 2013-10-27 09:22:10

athal
Member
Registered: 2012-05-29
Posts: 16

Re: USB Mouse autosuspends after 2 seconds

Hi replax && welcome to the club wink

I just installed powertop and disabled autosuspend for my mouse and everything works just fine. But it's  bit sad that this proprietary intel binary is able to control things better on my system that I am. I am not happy with that and I want to know the permanent solution to the problem. Any ideas where I could dig to unreveal the solution?

Are the udev rules incorrect? Or where should I start?

Offline

#8 2013-10-27 10:02:23

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: USB Mouse autosuspends after 2 seconds

Why did you change ATTR to ATTRS, for idVendor? That's *not* what I do, and my udev rule works - in eudev 1.1, anyway.

Alternatively, maybe udev/systemd has changed/broken something again. You'll have to do a bit of udev debugging yourselves, e.g.:

udevadm info -a --name /dev/input/event2

For whatever number your mouse is (can vary).

A USB speed of 12 Mbit/s is usual for mice, I believe. Maybe 1.5 is sufficient for cheap, crappy mice with a low polling rate wink I use usbhid.mousepoll=2, for a polling rate of 500 per second.

Offline

#9 2013-10-27 11:22:46

replax
Member
Registered: 2011-02-12
Posts: 90

Re: USB Mouse autosuspends after 2 seconds

Hi brebs, thanks for the reply!
if i do:

sudo udevadm info -a --name /dev/input/mouse0

the mouse part is:

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2.3':
    KERNELS=="4-1.2.3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1.2.3"
    ATTRS{idVendor}=="046d"
    ATTRS{speed}=="1.5"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="5"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="98mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="3000"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="51267"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Logitech"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="c051"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}=="USB-PS/2 Optical Mouse"

because there, it's called ATTRS too, I changed both to ATTRS and then tried both with ATTR, to no avail..
I also tried ATTR(S){power/control}="on" instead of two = signs, as in "==", but that did not make any difference either as far as i can tell.

As for the speed, I agree that 1.5 is damn low indeed! I got no Hightech mouse but a Logitech MX518, which is, in my opinion, alright and no cheapo crapware... Might be because I connect the mouse through a usb hub to my pc.
Where do you specify the polling-rate?

btw, I am on the most recent arch version with the stock kernel. my machine is a thinkpad x220 and I connect my external mouse/keyboard to a usb hub which I then connect to my pc.

Last edited by replax (2013-10-27 11:57:25)

Offline

#10 2013-10-27 14:14:06

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: USB Mouse autosuspends after 2 seconds

To avoid unnecessary confusion, each rule filename should start with a 2-digit number. This determines the order, and the order is important. This is why I use 91, to be last, so nothing else overrules the setting of ATTR{power/control}="on"

"=" means set, "==" is a comparison.

Offline

#11 2013-10-28 22:07:31

replax
Member
Registered: 2011-02-12
Posts: 90

Re: USB Mouse autosuspends after 2 seconds

Hey! my issue is resolved!
I made sure all files in rules.d are prefixed with a 2 digit number. my 91-local.rules file now contains:

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="074b", TEST=="power/control", ATTR{power/control}="on"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c051", TEST=="power/control", ATTR{power/control}="on"

and my keyboard/mouse are not put to sleep anymore after 2 sec smile!!

@brebs, where do I specify the polling rate for my mouse? as I also play on my machine, i really want to know big_smile
thanks for all the help smile!

Offline

Board footer

Powered by FluxBB