Bug 214823 - RTL8821CE Bluetooth adapter randomly stopped working, only suspend then resume can reset it
Summary: RTL8821CE Bluetooth adapter randomly stopped working, only suspend then resum...
Status: RESOLVED WILL_NOT_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Bluetooth (show other bugs)
Hardware: All Linux
: P1 high
Assignee: linux-bluetooth@vger.kernel.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-26 09:08 UTC by tuwuna
Modified: 2023-11-08 09:40 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.14.16
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments

Description tuwuna 2021-10-26 09:08:36 UTC
Tried to downgrade rtl8821c version, bluetooth adapter still randomly stop working

The only fix I found was to suspend then resume, restarting doesn't help

~ > sudo dmesg | grep 'Bluetooth: hci'
[sudo] password for nellowly:
[   32.269597] Bluetooth: hci0: RTL: examining hci_ver=08 hci_rev=000c lmp_ver=08 lmp_subver=8821
[   32.272590] Bluetooth: hci0: RTL: rom_version status=0 version=1
[   32.272595] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_fw.bin
[   32.272611] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_config.bin
[   32.272626] Bluetooth: hci0: RTL: cfg_sz 10, total sz 21678
[   32.858653] Bluetooth: hci0: RTL: fw version 0x826ca99e
[11324.989363] Bluetooth: hci0: command 0x2005 tx timeout
[11327.038375] Bluetooth: hci0: command 0x200b tx timeout
[11329.085367] Bluetooth: hci0: command 0x200c tx timeout
[11331.133356] Bluetooth: hci0: command 0x0401 tx timeout
[11337.968450] Bluetooth: hci0: link tx timeout
[11337.968455] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11340.030351] Bluetooth: hci0: command 0x041f tx timeout
[11340.030362] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[11342.078353] Bluetooth: hci0: command 0x0406 tx timeout
[11342.078362] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[11348.001581] Bluetooth: hci0: link tx timeout
[11348.001591] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11348.003695] Bluetooth: hci0: link tx timeout
[11348.003703] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11348.004799] Bluetooth: hci0: link tx timeout
[11348.004807] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11348.017537] Bluetooth: hci0: link tx timeout
[11348.017545] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11349.001714] Bluetooth: hci0: link tx timeout
[11349.001719] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11350.077371] Bluetooth: hci0: command 0x0c24 tx timeout
[11350.077383] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[11352.125366] Bluetooth: hci0: command 0x0c52 tx timeout
[11352.125371] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[11354.173357] Bluetooth: hci0: command 0x0405 tx timeout
[11354.173365] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[11356.221372] Bluetooth: hci0: command 0x0408 tx timeout
[11356.221377] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[11370.557366] Bluetooth: hci0: link tx timeout
[11370.557376] Bluetooth: hci0: killing stalled connection 94:db:56:17:9e:c2
[11372.605355] Bluetooth: hci0: command 0x0408 tx timeout
[11372.605359] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[12701.885371] Bluetooth: hci0: Timed out waiting for suspend events
[12701.885380] Bluetooth: hci0: Suspend timeout bit: 6
[12701.885388] Bluetooth: hci0: command 0x0408 tx timeout
[12701.885394] Bluetooth: hci0: No gpio to reset Realtek device, ignoring
[12701.885406] Bluetooth: hci0: Suspend notifier action (3) failed: -110

I am not familiar with kernel's source but there is this part I found that seems revelant for at least a work around (can fast reset bluetooth adapter when it stops working). I just don't know how to patch kernel so...

drivers/bluetooth/hci_h5.c

/* Suspend/resume support. On many devices the RTL BT device loses power during
 * suspend/resume, causing it to lose its firmware and all state. So we simply
 * turn it off on suspend and reprobe on resume.  This mirrors how RTL devices
 * are handled in the USB driver, where the USB_QUIRK_RESET_RESUME is used which
 * also causes a reprobe on resume.
 */
static int h5_btrtl_suspend(struct h5 *h5)
{
    serdev_device_set_flow_control(h5->hu->serdev, false);
    gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
    gpiod_set_value_cansleep(h5->enable_gpio, 0);
    return 0;
}
Comment 1 tuwuna 2021-10-26 17:08:57 UTC
Downgraded to kernel version 5.10.75, no issue were found

In this kernel, bluetooth don't work after suspend because there was a bug in power management. I believe the issue appear after https://github.com/lwfinger/rtw88 was brought to kernel code on 25 Sep 2020.
Comment 2 tuwuna 2021-11-06 15:29:13 UTC
Alright, since no one on the team is responding anytime soon, I even reported to https://github.com/lwfinger/rtw88/issues/72 also with no respond

I will leave my workaround here:

Add blacklist rtw88_8821ce to /etc/modprobe.d/blacklist.conf

Install https://github.com/tomaspinho/rtl8821ce

modprobe rtw88_8821ce before suspend
modprobe -r rtw88_8821ce after resume

To do this automatically see https://wiki.archlinux.org/title/Power_management#Sleep_hooks
Comment 3 tuwuna 2021-11-08 16:36:02 UTC
That workaround only works for 5.10 kernel

For a better workaround see https://github.com/lwfinger/rtw88/issues/72

In case the link die for whatever reason, quote:

Add usbcore.autosuspend=0 to kernel parameter or blacklist only bluetooth adapter using https://wiki.archlinux.org/title/Power_management#USB_autosuspend
Comment 4 tuwuna 2021-11-10 07:50:12 UTC
And this workaround doesn't work for me after a suspend resume cycle (It disconnects after a few hours) D:
Comment 5 tuwuna 2021-11-10 08:35:17 UTC
Here is an updated log on 5.14.16 kernel

> sudo dmesg | grep 'hci'

[ 3489.447794] Bluetooth: hci0: RTL: examining hci_ver=08 hci_rev=000c lmp_ver=08 lmp_subver=8821
[ 3489.450797] Bluetooth: hci0: RTL: rom_version status=0 version=1
[ 3489.450803] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_fw.bin
[ 3489.450817] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_config.bin
[ 3489.450829] Bluetooth: hci0: RTL: cfg_sz 10, total sz 31990
[ 3490.156772] Bluetooth: hci0: RTL: fw version 0x829a7644
[16782.570629] usb 1-2: new full-speed USB device number 5 using xhci_hcd

(suspend then resume event)

[26765.726605] Bluetooth: hci0: command 0x041f tx timeout
[26765.726616] Bluetooth: hci0: Timed out waiting for suspend events
[26765.726623] Bluetooth: hci0: Suspend timeout bit: 6
[26765.726646] Bluetooth: hci0: Suspend notifier action (3) failed: -110
[26766.591682] usb 3-1: reset full-speed USB device number 2 using xhci_hcd
[26766.605552] usb 1-4: reset high-speed USB device number 4 using xhci_hcd
[26766.796709] Bluetooth: hci0: RTL: examining hci_ver=08 hci_rev=000c lmp_ver=08 lmp_subver=8821
[26766.799656] Bluetooth: hci0: RTL: rom_version status=0 version=1
[26766.799662] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_fw.bin
[26766.805135] Bluetooth: hci0: RTL: loading rtl_bt/rtl8821c_config.bin
[26766.805399] Bluetooth: hci0: RTL: cfg_sz 10, total sz 31990
[26767.513646] Bluetooth: hci0: RTL: fw version 0x829a7644
Comment 6 tuwuna 2022-03-07 15:31:21 UTC
To anyone hoping for a fix just buy a AX200 because these guy don't fucking care about linux users.

Note You need to log in before you can comment on or make changes to this bug.