Bluetooth mouse sleeps after 5 seconds of inactivity, but btusb.enable_autosuspend=0 fixes it

Bug #1801642 reported by Wajuz Donny
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

I'm having bluetooth mouse lag issue. After leaving it stationary for 5 seconds, I have to move it for 2 seconds before the pointer starts moving.

I recently upgraded to Cosmic 3 days ago (from Bionic). There was no issue in the first 3 days, including after suspend/restart/shutdown. This issue only appears starting today.

I tried:
1. Running 'bluetoothctl' and then 'scan off'. The command failed to run with 'Failed to stop discovery: org.bluez.Error.Failed'.
2. modprobe -r btusb, then modprobe it again.
3. sudo sh -c 'echo N > /sys/module/drm_kms_helper/parameters/poll'
4. Disabling wifi.

$ apt-cache policy bluez
5.50-0ubuntu1

$uname -a; lspci -nnk | grep -iA2 net; lsusb; dmesg | grep -i bluetooth; dmesg | grep -i firmware; lsmod | grep bluetooth
4.18.0-10-generic #11
02:00.0 Network controller [0280]: Intel Corporation Wireless 7260 [8086:08b1] (rev 73)
 Subsystem: Intel Corporation Dual Band Wireless-N 7260 [8086:4460]
 Kernel driver in use: iwlwifi
03:00.1 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 12)
 Subsystem: Dell RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [1028:05f9]
 Kernel driver in use: r8169
 Kernel modules: r8169
Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 003: ID 17e9:4301 DisplayLink
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 047: ID 04f3:0206 Elan Microelectronics Corp.
Bus 002 Device 006: ID 8087:07dc Intel Corp.
Bus 002 Device 034: ID 0461:4d51 Primax Electronics, Ltd 0Y357C PMX-MMOCZUL (B) [Dell Laser Mouse]
Bus 002 Device 118: ID 0853:0132 Topre Corporation
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[ 287.361153] hid-generic 0005:046D:B012.0005: input,hidraw2: BLUETOOTH HID v0.14 Keyboard [MX Master] on FC:F8:AE:33:C7:31
bluetooth 548864 33 btrtl,btintel,btbcm,bnep,btusb,rfcomm
ecdh_generic 24576 2 bluetooth

ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: bluez 5.50-0ubuntu1
ProcVersionSignature: Ubuntu 4.18.0-10.11-generic 4.18.12
Uname: Linux 4.18.0-10-generic x86_64
ApportVersion: 2.20.10-0ubuntu13
Architecture: amd64
CurrentDesktop: MATE
Date: Mon Nov 5 13:40:01 2018
InstallationDate: Installed on 2018-07-08 (119 days ago)
InstallationMedia: Ubuntu-MATE 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
InterestingModules: rfcomm bnep btusb bluetooth
MachineType: Dell Inc. Inspiron 7537
ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-4.18.0-10-generic root=/dev/mapper/ubuntu--mate--vg-root ro ipv6.disable=1 quiet splash i915.enable_psr=0
SourcePackage: bluez
UpgradeStatus: Upgraded to cosmic on 2018-11-02 (3 days ago)
dmi.bios.date: 10/31/2013
dmi.bios.vendor: Dell Inc.
dmi.bios.version: A05
dmi.board.name: 07PF9F
dmi.board.vendor: Dell Inc.
dmi.board.version: A00
dmi.chassis.type: 8
dmi.chassis.vendor: Dell Inc.
dmi.chassis.version: 0.1
dmi.modalias: dmi:bvnDellInc.:bvrA05:bd10/31/2013:svnDellInc.:pnInspiron7537:pvr:rvnDellInc.:rn07PF9F:rvrA00:cvnDellInc.:ct8:cvr0.1:
dmi.product.family: Shark Bay ULT
dmi.product.name: Inspiron 7537
dmi.product.sku: Inspiron 7537
dmi.sys.vendor: Dell Inc.
hciconfig:
 hci0: Type: Primary Bus: USB
  BD Address: FC:F8:AE:33:C7:31 ACL MTU: 1021:5 SCO MTU: 96:5
  UP RUNNING
  RX bytes:2380 acl:32 sco:0 events:208 errors:0
  TX bytes:28560 acl:29 sco:0 commands:170 errors:0

Revision history for this message
Wajuz Donny (wajuzdonny) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

1. If you have 'tlp' installed then please try removing that.

2. If #1 has not solved the problem then please install 'powertop'. Now run:
   sudo powertop
and keep pressing Tab till you reach the "Tunables" section. Find your mouse in that list ("Autosuspend for USB device..."). Does it show a "Good" or "Bad" value?

Changed in bluez (Ubuntu):
status: New → Incomplete
Revision history for this message
Wajuz Donny (wajuzdonny) wrote :

My apology, I found the issue is due to canonical-livepatch (which is LTS-only). Issue resolved after removing it.

Changed in bluez (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
Wajuz Donny (wajuzdonny) wrote :

Ok, after another waking from suspend, the issue comes back again.

powertop shows "Bluetooth device interface status" is good. I can't identify which entry is the mouse, but the only bad USB devices are the keyboard and touchscreen.

Installing powertop somehow resolve this issue (for now). I'll check again tomorrow. I'll close this report if no issue in a week.

Wajuz Donny (wajuzdonny)
summary: - Bluetooth mouse sleep after 5 seconds of inactivity
+ Bluetooth mouse sleeps after 5 seconds of inactivity
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: Bluetooth mouse sleeps after 5 seconds of inactivity

I think you're looking at the wrong line there. The line you want is:

  Autosuspend for USB device ... <your mouse>

It sounds like the line for your mouse says "Good", which is actually bad news. Because it means the kernel is powering down the USB device for power savings. So a delay is expected.

Make sure the line for your mouse says "Bad"

  Bad Autosuspend for USB device ... <your mouse>

so that it doesn't go to sleep. :)

Revision history for this message
Wajuz Donny (wajuzdonny) wrote :

I see. There are two "Good" unknown autosuspend USB devices, not sure which one is my mouse. I can't find it in "Bad" either.

Anyhow, the issue seems resolved currently.

Revision history for this message
Wajuz Donny (wajuzdonny) wrote :

Day 3: No issue after wake from suspend.
Day 4: Issue comes back again (after suspend). Resolved after toggling "Autosuspend on" for two unknown USB devices to "Bad".

Wajuz Donny (wajuzdonny)
Changed in bluez (Ubuntu):
status: Invalid → New
Revision history for this message
Wajuz Donny (wajuzdonny) wrote :

Day 5: Issue comes back again (after suspend). Those two unknown devices switched back to "Good". This time I toggled one of them to "Bad" and the issue is resolved.

How do I make the powertop changes permanent?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

First ensure you don't have 'tlp' installed.

Second, I can only answer by Googling. Maybe changing your kernel command line to disable autosuspend of USB devices:

https://www.kernel.org/doc/html/v4.16/driver-api/usb/power-management.html

affects: bluez (Ubuntu) → linux (Ubuntu)
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Status changed to Confirmed

This change was made by a bot.

Changed in linux (Ubuntu):
status: New → Confirmed
Changed in linux (Ubuntu):
importance: Undecided → Medium
Brad Figg (brad-figg)
tags: added: cscc
Revision history for this message
Boaz Dodin (bdcomp) wrote : Re: Bluetooth mouse sleeps after 5 seconds of inactivity

After enabling the HWE stack on my Kubuntu 18.04.3 64bit and upgrade to Kernel 5.0, the bluetooth mouse sleeps after some inactivity.
An upgrade to Kubuntu 19.04, Kernel 5.0.0-23-generic, didn't solve the issue.

No tlp installed.

PowerTOP
Good Bluetooth device interface status

Any ideas how to disable this bluetooth power saving?
Or it's a regression between original Kubuntu 18.04 kernel and 5.0?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

"Good" in PowerTop usually means it is set to sleep. It sounds like the setting you want is actually the one labelled "Bad".

Revision history for this message
Boaz Dodin (bdcomp) wrote :

Exactly. But I can't figure our where this setting, for a permanent change...

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Such settings are in the /sys filesystem as text files you can read and write to. Writing to them is not remembered across boots though -- that's what software like powertop or tlp does.

So you can script writing to /sys/SOMETHING to control power management. Otherwise to change the defaults in the kernel would require changing the kernel source or adding kernel parameters.

Revision history for this message
Boaz Dodin (bdcomp) wrote :

/sys is huge, with many directories and files.
Can't find here bluetooth related config.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Does kernel parameter `btusb.enable_autosuspend=0` help?

Revision history for this message
Boaz Dodin (bdcomp) wrote :

Additional info:
sudo service bluetooth status:
.
.
.
Aug 09 11:05:47 boaz-desktop systemd[1]: Started Bluetooth service.
Aug 09 11:05:47 boaz-desktop bluetoothd[944]: Starting SDP server
Aug 09 11:05:47 boaz-desktop bluetoothd[944]: Bluetooth management interface 1.14 initia
Aug 09 11:05:51 boaz-desktop bluetoothd[944]: Endpoint registered: sender=:1.110 path=/M
Aug 09 11:05:51 boaz-desktop bluetoothd[944]: Endpoint registered: sender=:1.110 path=/M
Aug 09 11:06:20 boaz-desktop bluetoothd[944]: No cache for FF:FF:7D:BE:34:6F
Aug 09 11:06:22 boaz-desktop bluetoothd[944]: bt_uhid_send: Invalid argument (22)

Revision history for this message
Boaz Dodin (bdcomp) wrote :

btusb.enable_autosuspend=0 is a magic! Yay!!!

Later I will try to permanent set it.

P.S. Still wondering why Kernel (or linux-firmware?) upgrade bring this issue?

summary: - Bluetooth mouse sleeps after 5 seconds of inactivity
+ Bluetooth mouse sleeps after 5 seconds of inactivity, but
+ btusb.enable_autosuspend=0 fixes it
Revision history for this message
riso (richard-neuwirth) wrote :

Hello,

Sorry for stupid question (I'm new in linux) but how can I change kernel parameter?
My google search have no success...

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

To change parameters you need to:

1. Edit /etc/default/grub as root, and change the GRUB_CMDLINE_LINUX_DEFAULT line.

2. Run: sudo update-grub

3. Reboot.

Revision history for this message
Andrew Novikov (as-asaw) wrote :

I'm seeing this annoying issue with Ubuntu 20.04 running the linux-oem-20.04b kernel (currently 5.10.0-1026-oem). The above workaround fixes it.

Revision history for this message
Andrew Novikov (as-asaw) wrote :

The problem is clearly visible on a Dell Precision 5750. On a ThinkPad P1 Gen 3 the mouse "freezing" effect is barely noticeable.

Norbert (nrbrtx)
tags: removed: cosmic
tags: added: focal
Revision history for this message
Christophe Combelles (ccomb) wrote :

Got it under Debian 11

Short summary without completely disabling btusb autosuspend :

- Run powertop and identify the line in the "Tunables" tab that fix your problem when you switch it to "Bad" by hitting the Enter key.
  For instance >> Good Autosuspend for unknown USB device 1-7 (a1b2:c3d4)
- In /etc/tlp.conf, add a line with USB_BLACKLIST="a1b2:c3d4"
- restart tlp (systemctl restart tlp)

Revision history for this message
Christophe Combelles (ccomb) wrote :

For an unknown reason, the TLP setting is not applied after suspend/resume.

The thing I found to work for me is creating a file /lib/systemd/system-sleep/bt_autosuspend with this content, using the exact same line used by powertop (and set it executable) :

#!/bin/sh

# prevent the btusb from suspending after resume

case $1 in
    pre) ;;
    post) echo 'on' > '/sys/bus/usb/devices/1-7/power/control';;
esac

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Christophe,

Please don't report TLP bugs here. Ubuntu does not support TLP, although you can report them at https://bugs.launchpad.net/ubuntu/+source/tlp/+filebug

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.