diff mbox series

Bluetooth: Re-order clearing suspend tasks

Message ID 20200909183952.1.Ie55bb8dde9847e8005f24402f3f2d66ea09cd7b2@changeid
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series Bluetooth: Re-order clearing suspend tasks | expand

Commit Message

Abhishek Pandit-Subedi Sept. 10, 2020, 1:40 a.m. UTC
Unregister_pm_notifier is a blocking call so suspend tasks should be
cleared beforehand. Otherwise, the notifier will wait for completion
before returning (and we encounter a 2s timeout on resume).

Fixes: 0e9952804ec9c8 (Bluetooth: Clear suspend tasks on unregister)
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Should have caught that unregister_pm_notifier was blocking last time
but when testing the earlier patch, I got unlucky and saw that the error
message was never hit (the suspend timeout).

When re-testing this patch on the same device, I was able to reproduce
the problem on an older build with the 0e9952804ec9c8 but not on a newer
build with the same patch. Changing the order correctly fixes it
everywhere. Confirmed this by adding debug logs in btusb_disconnect and
hci_suspend_notifier to confirm what order things were getting called.

Sorry about the churn. Next I'm going try to do something about the palm
shaped indentation on my forehead...

 net/bluetooth/hci_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index efc0fe2b47dac2..be9cdf5dabe5dc 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3794,8 +3794,8 @@  void hci_unregister_dev(struct hci_dev *hdev)
-	unregister_pm_notifier(&hdev->suspend_notifier);
+	unregister_pm_notifier(&hdev->suspend_notifier);