You are not logged in.

#1 2014-09-03 17:19:18

themusicalduck
Member
Registered: 2011-07-04
Posts: 115

Keyboard and mouse intermittently powering off.

I have a problem where my keyboard and mouse are being very unreliable. The mouse will power itself off unless I am constantly moving it around. The only way to get it to respond again is to click one of the buttons. I can see that the mouse is turning itself off, because there is a light display on it that goes out and comes back on when I click.

It's harder to see what is happening with my keyboard, but it seems to have similar problems. If I don't use the keyboard for a moment, I'll have to press a key once before it'll start responding again. Sometimes I'll be typing something and it will just miss out characters at random.

The mouse is a Logitech G9x and the keyboard a Ducky Zero. I'm using Gnome. Other operating systems don't seem to have this problem (OSX, Windows) although I did have some problems with the keyboard not responding until I replugged it in OSX. But that has resolved itself. Windows doesn't seem to have any issue. If I remember right, I booted a live Ubuntu session a while back which also didn't have any issues.

My USB soundcard works fine, but that is powered from an external supply, so it may not get the same issues.

Sometimes if I reboot enough times, the keyboard and mouse will fix themselves. But nowadays it seems to be getting worse and the majority of the time, they aren't working. I tried disabling EHCI, XHCI and Legacy USB in BIOS, but that didn't help.

This only started happening a couple of months ago. I don't know if there were any updates that might have caused it, I do generally keep the system up to date. I wonder if it's a hardware problem, but given it seems to work fine in Windows, I'm not sure.

Edit: Replugging the mouse and keyboard after boot actually seems to fix it. I'd prefer not to have to do that though.

Last edited by themusicalduck (2014-09-07 21:11:39)

Offline

#2 2014-09-05 09:21:22

Morn
Member
Registered: 2012-09-02
Posts: 854

Re: Keyboard and mouse intermittently powering off.

Try turning off USB autosuspend. There are several ways to do this, but one method is (as root):

echo -1 >/sys/module/usbcore/parameters/autosuspend
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo -1 > $i; done

You have to do this each time you reboot. I still have rc-local.service, so I can just put these lines in  /etc/rc.local.

Offline

#3 2014-09-05 10:33:44

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Keyboard and mouse intermittently powering off.

Morn wrote:

Try turning off USB autosuspend. There are several ways to do this, but one method is (as root):

echo -1 >/sys/module/usbcore/parameters/autosuspend
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo -1 > $i; done

You have to do this each time you reboot. I still have rc-local.service, so I can just put these lines in  /etc/rc.local.

 That is highlly inefficient, since you use this on every device. Why not use the modules parameters? Load it properly through modprobe configuration.

filename:       /lib/modules/$(uname -r)/kernel/drivers/usb/core/usbcore.ko.gz
[..]
parm:           autosuspend:default autosuspend delay (int)

Edit: Improved style.

Last edited by emeres (2014-09-05 10:35:22)

Offline

#4 2014-09-05 11:24:39

Morn
Member
Registered: 2012-09-02
Posts: 854

Re: Keyboard and mouse intermittently powering off.

emeres wrote:

 That is highlly inefficient, since you use this on every device.

True, but then again people have reported very mixed success with selectively blacklisting mice and keyboards only in previous threads about this problem. So why not use the shotgun approach?

In reality most energy saving measures seem to cause trouble under Linux, even when they work perfectly under Windows: C-state modes above C1 cause audible coil whine on my PC; USB autosuspend makes some mice and USB hubs disconnect randomly, CPU frequency scaling was always terrible until Intel implemented their own kernel solution.

For a desktop PC, powersaving stuff like EIST simply isn't worth it IMO, at least under Linux. Maybe Linux distros should offer a "desktop PC power profile" during installation with all these flaky powersaving features disabled. They really only make sense for notebooks to prolong battery life a bit.

Offline

#5 2014-09-05 11:49:51

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Keyboard and mouse intermittently powering off.

 It is nice that you interpreted it that way*, but that is not what I meant. I meant using a service for disabling autosuspend on every usb device manually with a for loop, where you can simply use modprobe options for it, is highly inefficient. First you let modprobe load the module with autosuspend enabled, then you disable it by hand from a service. I hope this is clear enough now, I apologize for confusing you, should that have happened.

 *Side note: We live in a unsane (not sane) world, which borders on an insane world. Products/services are not designed to be efficient, they are designed to be sold, ergo if there is a possibility to make it break just after guarantee period is over, then is will be rewarded for designing and producing it that way. With a bigger user base in gnu/linux certain environment agencies would demand better implementation of power saving features and designs, especially if there was profit for them in it. But, that whole topic is not suitable for Arch Linux Forums. I will stop right here, anything else than a rbe is inefficient in that manner.

Edit: Added Linux in between Arch Forums and 'is'.

Edit2: Improved style. Maybe I miss here something, since I never paid any attention to autosuspend.

Last edited by emeres (2014-09-05 12:42:34)

Offline

#6 2014-09-05 12:43:55

Morn
Member
Registered: 2012-09-02
Posts: 854

Re: Keyboard and mouse intermittently powering off.

emeres wrote:

 It is nice that you interpreted it that way*, but that is not what I meant.

Ah, OK, sorry. Oh well, I guess there are always a 1,000 ways to achieve a given thing under Linux. Me, I happen to like rc.local for things like this, rather than messing with several config files. This way I have most of my custom changes in one place. :-)

emeres wrote:

With a bigger user base in gnu/linux certain environment agencies would demand better implementation of power saving features and designs, especially if there was profit for them in it.

Well, I doubt e.g. USB autosuspend really makes such a huge difference in power consumtion. Mice and keyboards already comsume very little power, what's the point in turning them off?

Perhaps powersaving makes sense for a large company with thousands of desktop PCs that run 24/7, but for the home user, it's not worth it. E.g. the crappy power supply on my PC consumes 15 W even when the PC is completely off, so by purchasing a power strip and turning it off overnight I'm already saving more energy than I ever could be disabling my mouse LED.

Offline

#7 2014-09-05 13:04:07

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,090
Website

Re: Keyboard and mouse intermittently powering off.

@themusicalduck, has this issue ben resolved?

Offline

#8 2014-09-05 13:26:35

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Keyboard and mouse intermittently powering off.

Morn wrote:

Well, I doubt e.g. USB autosuspend really makes such a huge difference in power consumtion. Mice and keyboards already comsume very little power, what's the point in turning them off?

Perhaps powersaving makes sense for a large company with thousands of desktop PCs that run 24/7, but for the home user, it's not worth it. E.g. the crappy power supply on my PC consumes 15 W even when the PC is completely off, so by purchasing a power strip and turning it off overnight I'm already saving more energy than I ever could be disabling my mouse LED.

 Which is the reason we should all save energy and be efficient, since our so called economy is extensively based upon finite resources, especially the food sector. Always look at it from a global perspective, national/regional perspective becomes more and more of a luxury. The more energy is wasted, the more expensive it gets in the end, for all of us. And the money aspect is irrelevant, energy needed to extract those resources, not.
 Also please note, that it is not always the most efficient way to simply turn a device off. One good example are fluorescent lamps, especially in schools, universities and other institutions, where they are periodically turned on and off multiple times during a day, 'wearing them out'. It would be in most cases far more efficient to turn them on once day, and even that could be reconsidered, but it would have to be measured to make the appropriate decision (energy needed for production & transport of a new unit vs. continuous power supply). Light emitting diodes are very efficient (usually > 0,9), but the power supplies for usb ports for usb devices not always. And consider new usb3.0 and usb3.1 standards, which are advertised and documented* to provide up to 100 Watts and 20 Volts and 10 Watts at 5 Volts depending on the connector used. Again this goes a little off-topic. To actually know if you are saving power or energy, measure it correctly.

*I only skimmed through the new specification, that thing is huge, but I trust others can read correctly.

PS. And yes, that is a very crappy PSU that needs 15 W on idle.

Offline

#9 2014-09-05 13:49:07

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

Re: Keyboard and mouse intermittently powering off.

Morn wrote:

it's not worth it.

Well, the *proper* solution, is to add overrides, in the form of udev rules to disable USB auto-suspend, for the badly-behaved hardware.

I suppose these should be offered to upstream udev. Use systemd bugzilla.

Offline

#10 2014-09-05 17:31:20

Morn
Member
Registered: 2012-09-02
Posts: 854

Re: Keyboard and mouse intermittently powering off.

emeres wrote:

 Which is the reason we should all save energy and be efficient, since our so called economy is extensively based upon finite resources, especially the food sector. Always look at it from a global perspective, national/regional perspective becomes more and more of a luxury.

Well, just because e.g. Germany requires everyone to use low-flow water toilets doesn't mean California will get much-needed water. Same for energy. Most of that is not distributed globally. It would be much more helpful if e.g. Apple or Samsung would not produce a new marginally improved smartphone model every year because rare earths *are* a globally redistributable, non-renewable resource. All those African rare earth elements in your cell phone are permanently removed from the economy, unlike water and energy which can filtered and obtained indefinitely as long as the Sun shines on Earth. Our consumerist economy is built on wastefulnesss and overconsumption, not conservation.

emeres wrote:

The more energy is wasted, the more expensive it gets in the end, for all of us. And the money aspect is irrelevant, energy needed to extract those resources, not.

That's why my PC is Pentium G630-based and uses an R7 240-based graphics card. TDP is about 75-80 W under full CPU and GPU load I think. *Some* people have 500 W graphics cards. If you want to save power, look at the graphics card which is by far the most power-hungry component in a modern desktop PC. But forget the mouse and keyboard.

emeres wrote:

 Also please note, that it is not always the most efficient way to simply turn a device off. One good example are fluorescent lamps, especially in schools, universities and other institutions, where they are periodically turned on and off multiple times during a day, 'wearing them out'. It would be in most cases far more efficient to turn them on once day, and even that could be reconsidered, but it would have to be measured to make the appropriate decision (energy needed for production & transport of a new unit vs. continuous power supply).

Yes, total cost of ownership, which counts all energy that goes into the manufacture of a product. Which is why the Tesla is a bad idea: too much power needed to manufacture its batteries. Fuel cells for the win. :-)

emeres wrote:

Light emitting diodes are very efficient (usually > 0,9), but the power supplies for usb ports for usb devices not always. And consider new usb3.0 and usb3.1 standards, which are advertised and documented* to provide up to 100 Watts and 20 Volts and 10 Watts at 5 Volts depending on the connector used. Again this goes a little off-topic. To actually know if you are saving power or energy, measure it correctly..

My USB 3.0 PCI card isn't connected to the internal power supply harness thingy. I'm violating the spec. But then again I don't use those ports for charging, just for file transfer. :-)

emeres wrote:

PS. And yes, that is a very crappy PSU that needs 15 W on idle.

Just think about the energy that could be saved by building power supplies that shut down properly…

brebs wrote:

Well, the *proper* solution, is to add overrides, in the form of udev rules to disable USB auto-suspend, for the badly-behaved hardware.

In another thread, someone did this but somehow the rule was ignored and autosuspend was still on. Conserving the system administrator's energy is also energy conservation, so a simple fix that always works is better than complex rules that get ignored by the system.

Offline

#11 2014-09-05 18:06:45

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Keyboard and mouse intermittently powering off.

@Morn, I agree, but again this goes off topic. The moderators will beat us, so to put the matter to rest:

emeres wrote:

I will stop right here, anything else than a rbe is inefficient in that manner.

@OP @all This would be the relevant documentation and this wiki page refers to the rules brebs linked. I get the rule to execute a test, so it is written correctly in case of my logitech mx518, but the attributes do not get respected. Maybe something overwrites it, my mouse is suddenly not compatible or the attributes reference changed, but I bet brebs would have updated his post before referencing, so this seems unlikely.

Edit: Typo.

Edit2: When I have some more time to look at it, I will report back. Hardware changes are somewhat problematic on my system, so it may take a while.

Edit3: Read this post. (loose usb connection/cpufreq governor)

Last edited by emeres (2014-09-07 21:55:13)

Offline

#12 2014-09-05 18:28:57

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

Re: Keyboard and mouse intermittently powering off.

Well, I haven't need the udev rule for quite a while - I ended up turning power-saving off as part of my never-ending experimentation, and just kept it turned off, because I don't need long battery life.

But some people do. And in general, power-conservation is a good thing. So Morn's rant about toilets etc. is just annoyingly stupid.

Since I don't use the rule, I can't say for certain that it is still correct for current udev - but when the only people who have a problem with it, also seem incompetent at debugging it, then I of course suspect that the problem is just with them wink  They should google about udev rules and udev debugging, as I had to, and figure out some certainty themselves.

Offline

#13 2014-09-06 05:47:17

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

Re: Keyboard and mouse intermittently powering off.

emeres wrote:

the attributes do not get respected

Maybe it's this kernel bug that's fixed in 3.16.2:

commit 37f0326a649ac1e4aed3061052aafdc0159dc42e
Author: Roger Quadros <rogerq@ti.com>
Date:   Mon Aug 4 12:44:46 2014 +0300

    usb: hub: Prevent hub autosuspend if usbcore.autosuspend is -1
   
    commit bdd405d2a5287bdb9b04670ea255e1f122138e66 upstream.
   
    If user specifies that USB autosuspend must be disabled by module
    parameter "usbcore.autosuspend=-1" then we must prevent
    autosuspend of USB hub devices as well.
   
    commit 596d789a211d introduced in v3.8 changed the original behaivour
    and stopped respecting the usbcore.autosuspend parameter for hubs.

Offline

#14 2014-09-06 21:14:52

themusicalduck
Member
Registered: 2011-07-04
Posts: 115

Re: Keyboard and mouse intermittently powering off.

Thanks everyone for the responses.

I managed to fix it thanks to brebs' link. However, using ATTR{product} didn't seem to work, but using idVendor and idProduct with information from lsusb did.

Cheers!

Offline

#15 2014-09-06 22:25:05

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Keyboard and mouse intermittently powering off.

@OP glad you got it working in the proper manner like brebs stated.

@brebs I can confirm that the attributes the udev rule sets, get overwritten shortly after plugging the device in, so I speculate this is not udev, since ':=' assignments were used. Because I do not use the testing repository, my kernel stays at 3.16.1 for at least a week, before next upgrade, but thank you for the tip, although considering the above, it probably is irrelevant in this case. I probably miss here something obvious, like modprobe defaulting the parameters:

Documenation wrote:

Finally, the parameter value can be changed while the system is
running.  If you do:

    echo 5 >/sys/module/usbcore/parameters/autosuspend

then each new USB device will have its autosuspend idle-delay
initialized to 5.  (The idle-delay values for already existing devices
will not be affected.)

# changed format for easier reading, everything is in one line
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{idVendor}=="046d", 
ATTR{idProduct}=="c051", ATTR{avoid_reset_quirk}:="1", ATTR{power/control}="auto", 
ATTR{power/autosuspend_delay_ms}:="10000", ATTR{power/autosuspend}:="10", 
ATTR{power/persist}="1", RUN+="/usr/bin/sh -c 'date >> /tmp/mx'"

 The values above are for testing purpose only, with both autosuspend{_delay_ms} in place, one is redundant. I will probably skip the test in future, several other combinations have been tested so far. However, this rule sets the mouse to suspend, contrary to what OP wanted to achieve. Obviously the parameters can be overwritten with echo afterwards resulting in desired state.
 The interesting part is that I once registered two changes in autosuspend_delay_ms after plugging the mouse in and the udev rule overwrote modprobes autosuspend parameters new value previously set with echo like in the above documentation quote, which leads to me the conclusion, it is something else, like a part of systemd. The last value appears to be what usbcore was loaded with during boot, so the default 2000 in this case. After I figure it out, this and the previous post, will get updated.

Edit: And the reason was... loose connection in the usb socket. At least it seems so, even though I recently refitted the sockets, so it seemed very unlikely. I did not reboot yet, again it is problematic in my case, I did however change the cpu frequency governor back and forth.

Last edited by emeres (2014-09-07 21:54:41)

Offline

#16 2014-09-07 21:18:36

themusicalduck
Member
Registered: 2011-07-04
Posts: 115

Re: Keyboard and mouse intermittently powering off.

Seems like I spoke too soon, because although it worked the once, it doesn't seem to be working on subsequent boots.

At the moment after boot, the suspend is still set to auto and running sudo udevadm control --reload does not load the new settings.

Does anyone have a suggestion why it doesn't work with either the product name or ids?

This is the contents of my /etc/udev/rules.d/91-local.rules file:

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c066", ATTR{power/control}="on"

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0f39", ATTR{idProduct}=="1083", ATTR{power/control}="on"

Also, offtopic but I have to ask -

Morn wrote:

C-state modes above C1 cause audible coil whine on my PC

I get terrible whining on my USB Presonus card and disabling C-states doesn't seem to help it. Is there anything else that you had to do? Or are you talking about noise actually coming from the hardware rather than through speakers/headphones?

Last edited by themusicalduck (2014-09-07 21:19:53)

Offline

#17 2014-09-07 21:51:26

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Keyboard and mouse intermittently powering off.

 You could alternatively try environment variables/parameters 'udevadm monitor --env', so ENV{ID_VENDOR_ID} as described on the wiki. This is usually done to do something when a device is removed, but works also when connected. Other thing is to use a final assignment to a key ':='. Does the control value change?

 Start a new thread about your sound card.

Offline

#18 2014-09-07 23:09:00

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

Re: Keyboard and mouse intermittently powering off.

themusicalduck wrote:

does not load the new setting

You're probably confused between "reload" and "trigger".

Read "man udevadm".

The proper test is to physically unplug, then re-insert the mouse.

Offline

#19 2014-09-08 09:36:29

Morn
Member
Registered: 2012-09-02
Posts: 854

Re: Keyboard and mouse intermittently powering off.

themusicalduck wrote:

Morn wrote:

C-state modes above C1 cause audible coil whine on my PC

I get terrible whining on my USB Presonus card and disabling C-states doesn't seem to help it. Is there anything else that you had to do? Or are you talking about noise actually coming from the hardware rather than through speakers/headphones?

Yeah, I was talking about a whining sound directly from the mobo. I think it's caused by C3 or C4, can't remember which. Windows 7 simply skips the offending C-state, therefore no whine under Windows.

Offline

#20 2014-09-13 16:27:11

themusicalduck
Member
Registered: 2011-07-04
Posts: 115

Re: Keyboard and mouse intermittently powering off.

emeres wrote:

 You could alternatively try environment variables/parameters 'udevadm monitor --env', so ENV{ID_VENDOR_ID} as described on the wiki. This is usually done to do something when a device is removed, but works also when connected. Other thing is to use a final assignment to a key ':='. Does the control value change?

This is a bit beyond me, sorry. I might need a bit more guidance before I can take on this advice.

brebs wrote:

You're probably confused between "reload" and "trigger".

Read "man udevadm".

The proper test is to physically unplug, then re-insert the mouse.

Physically unplugging and re-inserting the mouse and keyboard fixes the problem regardless of any changes. The thing is that I would like it to be working from boot, and not having to replug them.

Last edited by themusicalduck (2014-09-13 16:34:26)

Offline

#21 2022-06-21 06:59:08

xz-dev
Member
Registered: 2021-07-14
Posts: 2

Re: Keyboard and mouse intermittently powering off.

My Logitech mouse have same problem, if I replug it, problem will fixed until next boot.
So I add a udev rule, power/control not work when linux boot.

cat /etc/udev/rules.d/99-logitech.rules

ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="G502 HERO Gaming Mouse", ATTR{power/autosuspend}="-1" 

Last edited by xz-dev (2022-06-21 07:00:02)

Offline

Board footer

Powered by FluxBB