Skip to content

Commit 05a524b

Browse files
jwrdegoedegregkh
authored andcommitted
Bluetooth: Add new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk
[ Upstream commit 219991e ] Some devices, e.g. the RTL8723BS bluetooth part, some USB attached devices, completely drop from the bus on a system-suspend. These devices will have their driver unbound and rebound on resume (when the dropping of the bus gets detected) and will show up as a new HCI after resume. These devices do not benefit from the suspend / resume handling work done by the hci_suspend_notifier. At best this unnecessarily adds some time to the suspend/resume time. But this may also actually cause problems, if the code doing the driver unbinding runs after the pm-notifier then the hci_suspend_notifier code will try to talk to a device which is now in an uninitialized state. This commit adds a new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk which allows drivers to opt-out of the hci_suspend_notifier when they know beforehand that their device will be fully re-initialized / reprobed on resume. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6c15e41 commit 05a524b

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

include/net/bluetooth/hci.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ enum {
238238
* during the hdev->setup vendor callback.
239239
*/
240240
HCI_QUIRK_BROKEN_ERR_DATA_REPORTING,
241+
242+
/*
243+
* When this quirk is set, then the hci_suspend_notifier is not
244+
* registered. This is intended for devices which drop completely
245+
* from the bus on system-suspend and which will show up as a new
246+
* HCI after resume.
247+
*/
248+
HCI_QUIRK_NO_SUSPEND_NOTIFIER,
241249
};
242250

243251
/* HCI device flags */

net/bluetooth/hci_core.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3785,10 +3785,12 @@ int hci_register_dev(struct hci_dev *hdev)
37853785
hci_sock_dev_event(hdev, HCI_DEV_REG);
37863786
hci_dev_hold(hdev);
37873787

3788-
hdev->suspend_notifier.notifier_call = hci_suspend_notifier;
3789-
error = register_pm_notifier(&hdev->suspend_notifier);
3790-
if (error)
3791-
goto err_wqueue;
3788+
if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) {
3789+
hdev->suspend_notifier.notifier_call = hci_suspend_notifier;
3790+
error = register_pm_notifier(&hdev->suspend_notifier);
3791+
if (error)
3792+
goto err_wqueue;
3793+
}
37923794

37933795
queue_work(hdev->req_workqueue, &hdev->power_on);
37943796

@@ -3823,9 +3825,11 @@ void hci_unregister_dev(struct hci_dev *hdev)
38233825

38243826
cancel_work_sync(&hdev->power_on);
38253827

3826-
hci_suspend_clear_tasks(hdev);
3827-
unregister_pm_notifier(&hdev->suspend_notifier);
3828-
cancel_work_sync(&hdev->suspend_prepare);
3828+
if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) {
3829+
hci_suspend_clear_tasks(hdev);
3830+
unregister_pm_notifier(&hdev->suspend_notifier);
3831+
cancel_work_sync(&hdev->suspend_prepare);
3832+
}
38293833

38303834
hci_dev_do_close(hdev);
38313835

0 commit comments

Comments
 (0)