Bluetooth stop working after some time

Just after rebooting machine, Bluetooth works well, pairing, a2dp and so on. However, after some time (mostly after suspend-resume) it simply stop working: no packets get delivered, no ping, no pairing requrests, nothing works. Bluetooth tray icon gets disappeared, in the settings kcm module I see that bluetooth module is not active, button “Activate” does nothing without any messages. Wifi keep working without issues.

Suspicious kernel messages are:

[342485.795280] rtw_8821ce 0000:03:00.0: failed to get tx report from firmware
[342799.443102] rtw_8821ce 0000:03:00.0: firmware failed to leave lps state
[347969.161842] Bluetooth: hci0: urb 00000000a6583e12 failed to resubmit (113)

Tried bluetoothctl to enable the adapter, but no luck:

[bluetooth]# show
Controller 64:6C:80:67:8B:BC (public)
        Name: cy-machine-hp
        Alias: cy-machine-hp
        Class: 0x00000000
        **Powered: no**
        Discoverable: no
        DiscoverableTimeout: 0x000000b4
        Pairable: yes
        UUID: Message Notification Se.. (00001133-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
        UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: IrMC Sync                 (00001104-0000-1000-8000-00805f9b34fb)
        UUID: Vendor specific           (00005005-0000-1000-8000-0002ee000001)
        UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
        UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
        UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
        UUID: OBEX File Transfer        (00001106-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d053D
        Discovering: no
        Roles: central
        Roles: peripheral
Advertising Features:
        ActiveInstances: 0x00 (0)
        SupportedInstances: 0x05 (5)
        SupportedIncludes: appearance
        SupportedIncludes: local-name
**Failed to set power on: org.bluez.Error.Failed**

power on:

[bluetooth] power on
**bluetoth Failed to set power on: org.bluez.Error.Busy**

Workaround

Sometimes unloading modules using modprobe and load them back helps, then do bluetoothctl power on, if necessary

modprobe -ra btusb btrtl
modprobe -a btrtl btusb
bluetoothctl
[bluetooth] power on

System info
Manjaro rolling latest, all updates installed
Laptop: HP 15-gw008ur (Product ID 1u3d6ea#acb)
Kernel: 5.15.rc3
Also tried older versions with no success

[cy-machine-hp cy6ergn0m]# uname -a
Linux cy-machine-hp 5.15.0-1-MANJARO #1 SMP PREEMPT Sun Sep 26 21:53:21 UTC 2021 x86_64 GNU/Linux
[cy-machine-hp cy6ergn0m]# lsusb
Bus 001 Device 004: ID 0bda:b00a Realtek Semiconductor Corp. Realtek Bluetooth 4.2 Adapter

[cy-machine-hp cy6ergn0m]# lspci | grep Realtek
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821CE 802.11ac PCIe Wireless Network Adapter

[cy-machine-hp cy6ergn0m]# lsmod | grep bt
btusb                  65536  0
btrtl                  28672  1 btusb
btbcm                  20480  1 btusb
btintel                45056  1 btusb
bluetooth             729088  43 btrtl,btintel,btbcm,bnep,btusb,rfcomm

[cy-machine-hp cy6ergn0m]# rfkill 
ID TYPE      DEVICE      SOFT      HARD
 0 wlan      phy0   unblocked unblocked
51 bluetooth hci0   unblocked unblocked

I’ve discovered that in Fedora 35 bleutooth works well and survive suspensions. Also, I see that now BT doesn’t work anymore in Manjaro even after reboot. No workarounds.

Also tried different Fedora 35 versions (had older iso image at first).

Fedora system info
Older fedora:

Linux localhost-live 5.14.0-60.fc35.x86_64 #1 SMP Mon Aug 30 16:45:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

fcebbd1461a605c0d57d3d4a21145ac5dafe18f2  /run/media/liveuser/66ed6134-966b-47d6-868d-f5c4c3a74d99/usr/lib/firmware/rtl_bt/rtl8821c_fw.bin

[liveuser@localhost-live ~]$ unxz -c /usr/lib/firmware/rtl_bt/rtl8821c_fw.bin.xz | sha1sum 
fcebbd1461a605c0d57d3d4a21145ac5dafe18f2  -

So the firmware image is completely the same. While Manjaro with 5.14 kernel doesn’t fix the issue.

Slightly newer Fedora kernel has different firmare

[liveuser@localhost-live ~]$ xz -c /usr/lib/firmware/rtl_bt/rtl8821c_fw.bin.xz | sha1sum 
ad7097c12320b2a36e0239acbede24ff900fb3d9  -
[liveuser@localhost-live ~]$ uname -a
Linux localhost-live 5.14.10-300.fc35.x86_64 #1 SMP Thu Oct 7 20:48:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[liveuser@localhost-live ~]$ 

Any thoughts, what I can compare to narrow down the cause?

What about unloading modules, suspend, load modules again ?
Also may be worth checking anything power management related … like maybe just disabling TLP.

Now a see a little bit more kernel errors:

[ 9810.694726] Bluetooth: hci0: command 0x0c24 tx timeout
[ 9812.825067] Bluetooth: hci0: command 0x0c52 tx timeout
[ 9824.477761] rtw_8821ce 0000:03:00.0: firmware failed to leave lps state
[ 9828.811221] ACPI Error: No handler for Region [RCM0] (0000000011ecfbf7) [SystemCMOS] (20210730/evregion-130)
[ 9828.811237] ACPI Error: Region SystemCMOS (ID=5) has no handler (20210730/exfldio-261)
[ 9828.811249] ACPI Error: Aborting method \_SB.WMID.ESDT due to previous error (AE_NOT_EXIST) (20210730/psparse-529)
[ 9828.811261] ACPI Error: Aborting method \_SB.PCI0.LPC0.EC0._Q42 due to previous error (AE_NOT_EXIST) (20210730/psparse-529)

Are you not able to manually load modules and bluetooth appears again?

If so, you can easily create systemd service that do this for you everytime you do login and after suspend.

Unfortunately, it doesn’t always help. Don’t know why, but at some point it also stops helping :frowning:

After few hours experimenting, I found that you were right, it is all about PM. Initially I discovered that the issue is only reproducible when AC is unplugged (working on battery). The issue is that the device is unable to resume from autosuspend however it works well after manual suspend-resume. So complete prevention workaround is to disable it.

$ lsusb --tree
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 480M
    |__ Port 6: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
        |__ Port 1: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 3: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M
        |__ Port 3: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M

Port 1 > Port 6 > Port 3

$ cat /sys/bus/usb/devices/1-6.3/power/control 
auto

auto mode means that the device will be suspended when not used after /sys/bus/usb/devices/1-6.3/power/autosuspend_delay_ms milliseconds.
on mode - the device will be never autosuspended. The first idea was to use this mode. Unfortunately, plugging-unplugging the power cable toggles this mode. This is why the issue is not reproducible when working from AC.

Woraround
The alternative way is to disable autosuspend at all for this device that will work even when the mode is auto

$ echo 0 > /sys/bus/usb/devices/1-6.3/power/autosuspend

If you device is already got stuck, the following may help

echo 0 > /sys/bus/usb/devices/1-6.3/power/autosuspend
echo on > /sys/bus/usb/devices/1-6.3/power/control
modprobe -ra btusb btrtl
modprobe -a btrtl btusb
bluetoothctl
[bluetooth] power on

Sending on to the device power control should wake it up if it’s already autosuspeded. Unfortunately, it may not work depending on something unknown. If it doesn’t help, plug the power cable, reboot machine and disable autosuspend as descibed earlier. After that you may unplug it again, do manual suspend and everything will work. The only disadvantage is that the device will always work and drain battery.

Open question
Is there way to make this config persistent to have autosuspend=0 for the particular device after reboot?

I am pretty sure we compile/include usbcore
(it exists in my modules)
And is likely the source here … so a boot param like this should work:

usbcore.autosuspend=0

(that is, add it to /etc/default/grub and run sudo update-grub … more info on forums/wiki)

But this will disable autosuspend for all devices while I want to disable it only for the particular device.

Try adding a startup script to change /sys/bus/usb/devices/1-6.3/power/autosuspend maybe?

After playing more I decided to use udev to apply usb device PM options.

cat /etc/udev/rules.d/10-bluetooth.rules
ACTION=="add" \
  , ATTR{idProduct}=="b00a" \
  , ATTR{idVendor}=="0bda" \
  , ATTR{power/autosuspend_delay_ms}="-1" \
  , ATTR{power/control}="on" 

Use udevadm control --reload to apply in runtime or reboot if already stopped working.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.