btusb Broken after resuming from sleep

Hello,

Everytime after resuming my laptop from sleep KBluetooth says that no adapter is abailable.
It appears that reloading the module with modprobe solves the problem until the next time my laptop goes to sleep.


modprobe -r btusb
modprobe btusb

My bluetooth card is an Intel AC8260 (Wifi + Bluetooth on the same card).

I don’t know what else to say about it as I don’t know much stuff about drivers on linux…

One approach to automating this is to add a custom script located in /usr/lib/systemd/system-sleep/ as explained here
https://wiki.archlinux.org/index.php/Power_management#Hooks_in_.2Fusr.2Flib.2Fsystemd.2Fsystem-sleep

More info

man systemd-sleep.conf

Alternatively, see if this thread is of help with automating the unloading of the module prior to suspend and reloading on resume by the use of custom .service unit files…

https://forum.manjaro.org/t/laptop-wakes-from-sleep-if-bluetooth-is-enabled/50647/41

Hello!
Thanks for the answer! Unfortunately none of those solutions seems to work with my system…

The first one, even though the scripts executes (I logged what happens in a tmp file) it doesn’t seem to properly reset the bluetooth adapter. I still have to run the modprobe commands myself…

The latter is apparently broken now… It seems like the WantedBy argument has become illegal in the [Unit] section. The only way I’ve got it to be accepted by systemd is to simply comment out those lines.
However it didn’t solve the problem either…
Is there anything I’ve missed with these solutions?

I wonder if introducing a delay (eg ‘sleep 10’) on resume might help before loading the driver?

The ‘WantedBy=’ directive is an ‘[Install]’ section option. It should not be included in the ‘[Unit]’ section. Read ‘man systemd.service’ for more information.

However it didn’t solve the problem either…
Is there anything I’ve missed with these solutions?

Did you enable and start the services after creating the custom unit files?

I assume you created the following?
/etc/systemd/system/bluetooth-reload.service

[Unit]
Description=Reload bluetooth driver after system resume
After=hibernate.target suspend.target hybrid-sleep.target

[Service]
Type=oneshot
TimeoutSec=15
ExecStart=/usr/sbin/modprobe btusb

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

/etc/systemd/system/bluetooth-suspend.service

[Unit]
Description=Bluetooth module suspend helper
Before=sleep.target

[Service]
Type=simple
ExecStart=/usr/bin/bluetooth-suspend.sh

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

/usr/bin/bluetooth-suspend.sh

#!/bin/bash
modprobe -r btusb

I wonder if introducing a delay (eg ‘sleep 10’) on resume might help before loading the driver?

I already tried with up to 10 seconds and it didn’t solve the problem. Unfortunately…

The ‘WantedBy=’ directive is an ‘[Install]’ section option. It should not be included in the ‘[Unit]’ section. Read ‘man systemd.service’ for more information.

I will try later this evening if I have the time. I’ve tried with the configs at this address : https://forum.manjaro.org/t/laptop-wakes-from-sleep-if-bluetooth-is-enabled/50647/41 which seems to be the same minus the WantedBy in the [Unit] section…

Hi! Back from testing with the unit files…

At first when I tested yesterday it seemed like the system wouldn’t sleep anymore and would just hangup…

Now that I’ve tested and rebooted properly it just doesn’t solve the problem.
The system doesn’t hangup anymore (maybe it wasn’t what was causing the hangup) but the adapter is still “unavailable” when resuming from sleep.
I did enable and start the two unit files (since the very beginning of this thread do not worry) but it seems like nothing will do…

No errors reported by the respective services?

sudo systemctl status <name_of_service>

It’s interesting that you mentioned that manually unloading and reloading the btusb module on resume works. I wonder if more time is needed, and whether instead of unloading the driver in the via the suspend service, the unloading and reloading might be done in a single resume service unit.

/etc/systemd/system/bluetooth-reload.service

[Unit]
Description=Reload bluetooth driver after system resume
After=hibernate.target suspend.target hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/usr/bin/bluetooth-driver-reload.sh

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

/usr/bin/bluetooth-driver-reload.sh

#!/bin/bash
modprobe -r btusb
sleep 10
modprobe btusb

Hi!
I just tried with disabling and enabling when the computer resumes but it still doesn’t solve the problem…
However I’ve noticed that the problem won’t happen until a bluetooth device has been connected to the computer…
So as long as nothing has been connected resuming won’t mess things up.
However once a bluetooth device has been connected the user has to manually reload btusb in order to re-enable the bluetooth adapter. And it is like this until the next reboot.

However I think that I will stop there… There are way too much problem with Leap 15.0 that makes my system unstable…
This bluetooth thing, the fact that resolv.conf isn’t updated anymore with new connections (Thx networkmanager?), the fact than my keyboard and mouse will randomly not being recognised on boot, btrfs using sometimes 100% cpu, shutting down sometimes takes 2 minutes and sometimes 15 seconds, kernel updates breaking bumblebee… I think I will continue my quest in finding the best distro for my laptop (not an easy thing as it doesn’t seem to be very linux-friendly)…

Thanks for the time and sorry for not staying to solve the problem…

Ok, so not a driver issue then, but connection related.

Thanks for the time and sorry for not staying to solve the problem…

That’s your choice. All good.