Skip to content

Commit

Permalink
Bluetooth: Clear suspend tasks on unregister
Browse files Browse the repository at this point in the history
[ Upstream commit 0e99528 ]

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: 4e8c36c (Bluetooth: Fix suspend notifier race)
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
apandit authored and gregkh committed Oct 29, 2020
1 parent 7a15bd2 commit e9f1340
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3280,6 +3280,16 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr,
}
}

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 \
Expand Down Expand Up @@ -3609,6 +3619,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
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);
Expand Down

0 comments on commit e9f1340

Please sign in to comment.