4

I have a new Lenovo ThinkPad E15 that came with Windows 10 installed. I added Ubuntu 20.04 as an option (dual-boot).

Whenever the laptop sleeps (goes into a "suspend" state) and then later I wake it up, the Logitech wireless mouse scroll wheel doesn't work. ("Logitech MK270 Wireless Keyboard and Mouse Combo", but the only thing that doesn't work is the scroll wheel.)

I then unplug its USB-A dongle and replug it (I often need to do this multiple times), and then the mouse wheel works again.

I don't want to need to touch the USB plug at all. It should just always work. How can I fix this?

P.S. My question is very similar to Ubuntu 20.04: Scroll doesn't work for wireless mouse after system wakes up from suspended state, which has no answer yet.

P.P.S. I've confirmed that the USB switch in my setup is not related to the problem. The problem happens even when the tiny Logitech USB dongle is plugged directly into the laptop.

Ryan
  • 649
  • See also https://unix.stackexchange.com/questions/309247/linux-mouse-freezes-after-suspend. sudo modprobe -r hid_logitech_dj && sudo modprobe -r usbhid && sudo modprobe hid_logitech_dj && sudo modprobe usbhid disconnected and reconnected the USB mouse, but its wheel still doesn't work (unless I physically unplug and replug). – Ryan Aug 23 '21 at 18:22
  • I also tried sudo modprobe -r hid_logitech_dj && sudo modprobe -r logitech-djreceiver && sudo modprobe -r logitech-hidpp-device && sudo modprobe -r usbhid && sudo modprobe hid_logitech_dj && sudo modprobe usbhid && sudo modprobe logitech-djreceiver && sudo modprobe logitech-hidpp-device but got an error FATAL: Module logitech-djreceiver not found. – Ryan Aug 23 '21 at 18:22
  • Hi @Ryan: try connecting your commands with ";" instead of "&&" and check again (this will continue executing the orders even if you get an error from one of them). Regarding the output you posted, It seems like you don´t have the logitech-djreceiver installed, so I would try to go from there. Try a fresh install and then run the modprobe sequence. Hope it helps. Cheers. – Rho Oct 29 '21 at 09:48
  • 3
    I cannot say with certainty if it fixes your problem, but I have a very similar one and just wanted to post a question myself. What I found so far for me may help you: modprobe doesn't help since the modules are not loaded. What helps is a reset of the usb bus. You can look for the USB ID of the device with lsusb. Install usbutils and issue usbreset <USB ID>. After this, the device should be recognized again without unplugging and replugging. A systemctl service similar to this answer should automate it: https://unix.stackexchange.com/a/227293/140914 – emk2203 Jan 04 '22 at 17:41

2 Answers2

2

modprobe doesn't help here, the best chance is to reset the USB bus for this malfunctioning or missing device.

Look for the USB ID in the form of VID:PID of the device with lsusb. Install usbutils and issue usbreset VID:PID. After this, the device should be functioning again without unplugging and replugging. The bus reset is not exactly equal, but should be close enough.

To automate this action, make a systemctl service for it:

sudo vim /etc/systemd/system/reset-usb-upon-wake@.service

Paste in these lines, and save the file:

[Unit]
Description="Reset a USB device after system resume"
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service] Type=oneshot ExecStart=/usr/bin/usbreset %i

[Install] WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

Recall the VID:PID value you got from lsusb.

For example, maybe it was 0bda:5411.

Enable/start the service by running a command like: sudo systemctl start reset-usb-upon-wake@VID:PID.service, such as sudo systemctl start reset-usb-upon-wake@0bda:5411.service.

This way, even if you have multiple devices that need this kind of service, they can all use this single service file.

Ryan
  • 649
emk2203
  • 4,423
  • Thanks for this answer. I'm trying it now and running into some problems. I will edit your answer above with what I think might work. And I'll come back here when I learn more. – Ryan Jan 05 '22 at 15:30
  • I don't think I have this working. When I woke my computer from hibernation this morning, the scroll wheel didn't work. Does that mean I need more service files? Is there a way to make this work upon hibernation waking and first boot, too? Thanks! :-) – Ryan Jan 06 '22 at 14:47
  • 1
    First, look into the journal of systemd to see if everything was setup correctly: Boot the PC, go to sleep, resume and afterwards use journalctl -b to see everything since last boot. Look if your service ran after the resume. If it did, chances are that the usb reset method is unfortunately not sufficient in your case. If usb reset doesn't work, there's little to be done with software alone, I'm afraid. – emk2203 Jan 06 '22 at 16:28
  • 1
    Switching the mouse off and on might be the best solution if software attempts fail. – emk2203 Jan 06 '22 at 16:43
  • I will try modifying based on https://unix.stackexchange.com/a/492497/48973 – Ryan Jan 07 '22 at 14:20
  • So far, I'm pretty sure that running sudo systemctl start reset-usb-upon-wake@046d:c534.service has worked every time, but afterwards it weirdly continually presses Enter (seemingly) in the terminal, causing the terminal to scroll endlessly until I type a new command. So I'd like to fix that, and also I still haven't gotten it to run automatically upon waking. I'll edit the answer above to show what I've tried. – Ryan Jan 10 '22 at 13:57
  • In the log, I do see this, which implies that it worked: Jan 11 09:05:22 ThinkPad-E15-Gen-2 systemd[1]: Starting "Reset a USB device after system resume"... Jan 11 09:05:22 ThinkPad-E15-Gen-2 kernel: usb 3-5.3: reset full-speed USB device number 16 using xhci_hcd Jan 11 09:05:22 ThinkPad-E15-Gen-2 usbreset[12310]: Resetting USB Receiver ... ok Jan 11 09:05:22 ThinkPad-E15-Gen-2 systemd[1]: reset-usb-upon-wake@046d:c534.service: Succeeded. Jan 11 09:05:22 ThinkPad-E15-Gen-2 systemd[1]: Finished "Reset a USB device after system resume". – Ryan Jan 11 '22 at 14:55
  • ...but the mouse scroll wheel didn't actually work until I opened the terminal and manually ran that service. Any ideas? Thanks. – Ryan Jan 11 '22 at 14:56
  • I awarded a bunch of points even though I still don't know how to fix my problem (because I really appreciated your continued effort). :-) – Ryan Jan 11 '22 at 19:05
  • 1
    Sorry for being absent for a while. It looks like there is some quirk with your hardware/software and it's supposed to function, but in reality, things are different.

    You could try a second reset via the service, maybe with a 1 second pause in between, and hope this helps, or maybe try a different kernel to see if the driver got some updates and it works with a newer version.

    You can try maybe with a live USB of the development 22.04. It has kernel 5.15, a LTS version, with a lot of improvements. If this works, maybe use kernel 5.15 in your 20.04. Thanks for the points!

    – emk2203 Jan 22 '22 at 13:50
  • If you have a moment, I've still been fighting this problem for more than a year. I've now asked it as a separate question: https://askubuntu.com/q/1454673/48214 Thanks! – Ryan Feb 12 '23 at 20:40
  • Thanks for your help! I think I finally got it! https://askubuntu.com/a/1493498/48214 – Ryan Nov 21 '23 at 23:54
0

I solved the problem of not working the scroll in a wireless mouse after suspend , by disabling in bios the following( I am not sure which one was the problem)

-USB Legacy port charging -wake on USB -USB redirection support

Nikos
  • 1