Bluetooth: Disconnect connected devices before rfkilling adapter
authorJonas Dreßler <verdre@v0yd.nl>
Sun, 7 Jan 2024 18:02:50 +0000 (19:02 +0100)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 6 Mar 2024 22:22:37 +0000 (17:22 -0500)
commitd77433cdd2524cb924a5ec0476429330e9ee9f0e
tree8e12ba5c84b9496a64212ee7329b8861310c04e0
parentb14202aff5acba3b672704d792e821f02f8f562a
Bluetooth: Disconnect connected devices before rfkilling adapter

On a lot of platforms (at least the MS Surface devices, M1 macbooks, and
a few ThinkPads) firmware doesn't do its job when rfkilling a device
and the bluetooth adapter is not actually shut down properly on rfkill.
This leads to connected devices remaining in connected state and the
bluetooth connection eventually timing out after rfkilling an adapter.

Use the rfkill hook in the HCI driver to go through the full power-off
sequence (including stopping scans and disconnecting devices) before
rfkilling it, just like MGMT_OP_SET_POWERED would do.

In case anything during the larger power-off sequence fails, make sure
the device is still closed and the rfkill ends up being effective in
the end.

Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_core.c