FROMGIT: Bluetooth: Clear suspend tasks on unregister

While unregistering, make sure to clear the suspend tasks before
cancelling the work. If the unregister is called during resume from
suspend, this will unnecessarily add 2s to the resume time otherwise.

Fixes: 4e8c36c3b0d73d (Bluetooth: Fix suspend notifier race)
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 0e9952804ec9c8ba60f131225eab80634339f042
 https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/ master)

BUG=b:167430555, b:157448009
TEST=On Ezkinil, suspend+resume and verify resume time < 2s

Change-Id: I80ca6804558dabf8ea0ad5c4ed042f487ad5376c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2393082
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Tested-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Commit-Queue: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index fcf6fc9..4ef9fdd 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3067,6 +3067,16 @@
 	}
 }
 
+static void hci_suspend_clear_tasks(struct hci_dev *hdev)
+{
+	int i;
+
+	for (i = 0; i < __SUSPEND_NUM_TASKS; i++)
+		clear_bit(i, hdev->suspend_tasks);
+
+	wake_up(&hdev->suspend_wait_q);
+}
+
 static int hci_suspend_wait_event(struct hci_dev *hdev)
 {
 #define WAKE_COND                                                              \
@@ -3406,6 +3416,7 @@
 	cancel_work_sync(&hdev->power_on);
 
 	unregister_pm_notifier(&hdev->suspend_notifier);
+	hci_suspend_clear_tasks(hdev);
 	cancel_work_sync(&hdev->suspend_prepare);
 
 	hci_dev_do_close(hdev);