* [PATCH 0/2] Bluetooth: Suspend related bugfixes
@ 2020-03-20 0:07 Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 1/2] Bluetooth: Restore running state if suspend fails Abhishek Pandit-Subedi
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-20 0:07 UTC (permalink / raw)
To: marcel, linux-bluetooth
Cc: chromeos-bluetooth-upstreaming, Abhishek Pandit-Subedi,
David S. Miller, Johan Hedberg, netdev, linux-kernel,
Jakub Kicinski
Hi Marcel,
After further automated testing of the upstreamed suspend patches,
I found two issues:
- A failure in PM_SUSPEND_PREPARE wasn't calling PM_POST_SUSPEND.
I misread the docs and thought it would call it for all notifiers
already run but it only does so for the ones that returned
successfully from PM_SUSPEND_PREPARE.
- hci_conn_complete_evt wasn't completing on auto-connects (an else
block was removed during a refactor incorrectly)
With the following patches, I've run a suspend stress test on a couple
of Chromebooks for several dozen iterations (each) successfully.
Thanks
Abhishek
Abhishek Pandit-Subedi (2):
Bluetooth: Restore running state if suspend fails
Bluetooth: Fix incorrect branch in connection complete
net/bluetooth/hci_core.c | 39 ++++++++++++++++++++-------------------
net/bluetooth/hci_event.c | 17 +++++++++--------
2 files changed, 29 insertions(+), 27 deletions(-)
--
2.25.1.696.g5e7596f4ac-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] Bluetooth: Restore running state if suspend fails
2020-03-20 0:07 [PATCH 0/2] Bluetooth: Suspend related bugfixes Abhishek Pandit-Subedi
@ 2020-03-20 0:07 ` Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 2/2] Bluetooth: Fix incorrect branch in connection complete Abhishek Pandit-Subedi
2020-03-23 17:50 ` [PATCH 0/2] Bluetooth: Suspend related bugfixes Marcel Holtmann
2 siblings, 0 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-20 0:07 UTC (permalink / raw)
To: marcel, linux-bluetooth
Cc: chromeos-bluetooth-upstreaming, Abhishek Pandit-Subedi,
David S. Miller, Johan Hedberg, netdev, linux-kernel,
Jakub Kicinski
If Bluetooth fails to enter the suspended state correctly, restore the
state to running (re-enabling scans). PM_POST_SUSPEND is only sent to
notifiers that successfully return from PM_PREPARE_SUSPEND notification
so we should recover gracefully if it fails.
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---
net/bluetooth/hci_core.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index dbd2ad3a26ed..2e7bc2da8371 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3305,6 +3305,15 @@ static void hci_prepare_suspend(struct work_struct *work)
hci_dev_unlock(hdev);
}
+static int hci_change_suspend_state(struct hci_dev *hdev,
+ enum suspended_state next)
+{
+ hdev->suspend_state_next = next;
+ set_bit(SUSPEND_PREPARE_NOTIFIER, hdev->suspend_tasks);
+ queue_work(hdev->req_workqueue, &hdev->suspend_prepare);
+ return hci_suspend_wait_event(hdev);
+}
+
static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action,
void *data)
{
@@ -3330,32 +3339,24 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action,
* connectable (disabling scanning)
* - Second, program event filter/whitelist and enable scan
*/
- hdev->suspend_state_next = BT_SUSPEND_DISCONNECT;
- set_bit(SUSPEND_PREPARE_NOTIFIER, hdev->suspend_tasks);
- queue_work(hdev->req_workqueue, &hdev->suspend_prepare);
- ret = hci_suspend_wait_event(hdev);
+ ret = hci_change_suspend_state(hdev, BT_SUSPEND_DISCONNECT);
- /* If the disconnect portion failed, don't attempt to complete
- * by configuring the whitelist. The suspend notifier will
- * follow a cancelled suspend with a PM_POST_SUSPEND
- * notification.
- */
- if (!ret) {
- hdev->suspend_state_next = BT_SUSPEND_COMPLETE;
- set_bit(SUSPEND_PREPARE_NOTIFIER, hdev->suspend_tasks);
- queue_work(hdev->req_workqueue, &hdev->suspend_prepare);
- ret = hci_suspend_wait_event(hdev);
- }
+ /* Only configure whitelist if disconnect succeeded */
+ if (!ret)
+ ret = hci_change_suspend_state(hdev,
+ BT_SUSPEND_COMPLETE);
} else if (action == PM_POST_SUSPEND) {
- hdev->suspend_state_next = BT_RUNNING;
- set_bit(SUSPEND_PREPARE_NOTIFIER, hdev->suspend_tasks);
- queue_work(hdev->req_workqueue, &hdev->suspend_prepare);
- ret = hci_suspend_wait_event(hdev);
+ ret = hci_change_suspend_state(hdev, BT_RUNNING);
}
+ /* If suspend failed, restore it to running */
+ if (ret && action == PM_SUSPEND_PREPARE)
+ hci_change_suspend_state(hdev, BT_RUNNING);
+
done:
return ret ? notifier_from_errno(-EBUSY) : NOTIFY_STOP;
}
+
/* Alloc HCI device */
struct hci_dev *hci_alloc_dev(void)
{
--
2.25.1.696.g5e7596f4ac-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] Bluetooth: Fix incorrect branch in connection complete
2020-03-20 0:07 [PATCH 0/2] Bluetooth: Suspend related bugfixes Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 1/2] Bluetooth: Restore running state if suspend fails Abhishek Pandit-Subedi
@ 2020-03-20 0:07 ` Abhishek Pandit-Subedi
2020-03-23 17:50 ` [PATCH 0/2] Bluetooth: Suspend related bugfixes Marcel Holtmann
2 siblings, 0 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-20 0:07 UTC (permalink / raw)
To: marcel, linux-bluetooth
Cc: chromeos-bluetooth-upstreaming, Abhishek Pandit-Subedi,
David S. Miller, Johan Hedberg, netdev, linux-kernel,
Jakub Kicinski
When handling auto-connected devices, we should execute the rest of the
connection complete when it was previously discovered and it is an ACL
connection.
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---
net/bluetooth/hci_event.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 20408d386268..cd3d7d90029b 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2539,16 +2539,17 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
bt_dev_err(hdev, "no memory for new conn");
goto unlock;
}
- }
-
- if (ev->link_type != SCO_LINK)
- goto unlock;
+ } else {
+ if (ev->link_type != SCO_LINK)
+ goto unlock;
- conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr);
- if (!conn)
- goto unlock;
+ conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK,
+ &ev->bdaddr);
+ if (!conn)
+ goto unlock;
- conn->type = SCO_LINK;
+ conn->type = SCO_LINK;
+ }
}
if (!ev->status) {
--
2.25.1.696.g5e7596f4ac-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Bluetooth: Suspend related bugfixes
2020-03-20 0:07 [PATCH 0/2] Bluetooth: Suspend related bugfixes Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 1/2] Bluetooth: Restore running state if suspend fails Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 2/2] Bluetooth: Fix incorrect branch in connection complete Abhishek Pandit-Subedi
@ 2020-03-23 17:50 ` Marcel Holtmann
2020-03-23 17:59 ` Abhishek Pandit-Subedi
2 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2020-03-23 17:50 UTC (permalink / raw)
To: Abhishek Pandit-Subedi
Cc: Bluez mailing list, ChromeOS Bluetooth Upstreaming,
David S. Miller, Johan Hedberg, Network Development,
linux-kernel, Jakub Kicinski
Hi Abhishek,
> After further automated testing of the upstreamed suspend patches,
> I found two issues:
> - A failure in PM_SUSPEND_PREPARE wasn't calling PM_POST_SUSPEND.
> I misread the docs and thought it would call it for all notifiers
> already run but it only does so for the ones that returned
> successfully from PM_SUSPEND_PREPARE.
> - hci_conn_complete_evt wasn't completing on auto-connects (an else
> block was removed during a refactor incorrectly)
>
> With the following patches, I've run a suspend stress test on a couple
> of Chromebooks for several dozen iterations (each) successfully.
>
> Thanks
> Abhishek
>
>
>
> Abhishek Pandit-Subedi (2):
> Bluetooth: Restore running state if suspend fails
> Bluetooth: Fix incorrect branch in connection complete
>
> net/bluetooth/hci_core.c | 39 ++++++++++++++++++++-------------------
> net/bluetooth/hci_event.c | 17 +++++++++--------
> 2 files changed, 29 insertions(+), 27 deletions(-)
both patches have been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Bluetooth: Suspend related bugfixes
2020-03-23 17:50 ` [PATCH 0/2] Bluetooth: Suspend related bugfixes Marcel Holtmann
@ 2020-03-23 17:59 ` Abhishek Pandit-Subedi
0 siblings, 0 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-23 17:59 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Bluez mailing list, ChromeOS Bluetooth Upstreaming,
David S. Miller, Johan Hedberg, Network Development, LKML,
Jakub Kicinski
Thanks Marcel.
On Mon, Mar 23, 2020 at 10:50 AM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Abhishek,
>
> > After further automated testing of the upstreamed suspend patches,
> > I found two issues:
> > - A failure in PM_SUSPEND_PREPARE wasn't calling PM_POST_SUSPEND.
> > I misread the docs and thought it would call it for all notifiers
> > already run but it only does so for the ones that returned
> > successfully from PM_SUSPEND_PREPARE.
> > - hci_conn_complete_evt wasn't completing on auto-connects (an else
> > block was removed during a refactor incorrectly)
> >
> > With the following patches, I've run a suspend stress test on a couple
> > of Chromebooks for several dozen iterations (each) successfully.
> >
> > Thanks
> > Abhishek
> >
> >
> >
> > Abhishek Pandit-Subedi (2):
> > Bluetooth: Restore running state if suspend fails
> > Bluetooth: Fix incorrect branch in connection complete
> >
> > net/bluetooth/hci_core.c | 39 ++++++++++++++++++++-------------------
> > net/bluetooth/hci_event.c | 17 +++++++++--------
> > 2 files changed, 29 insertions(+), 27 deletions(-)
>
> both patches have been applied to bluetooth-next tree.
>
> Regards
>
> Marcel
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-23 17:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 0:07 [PATCH 0/2] Bluetooth: Suspend related bugfixes Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 1/2] Bluetooth: Restore running state if suspend fails Abhishek Pandit-Subedi
2020-03-20 0:07 ` [PATCH 2/2] Bluetooth: Fix incorrect branch in connection complete Abhishek Pandit-Subedi
2020-03-23 17:50 ` [PATCH 0/2] Bluetooth: Suspend related bugfixes Marcel Holtmann
2020-03-23 17:59 ` Abhishek Pandit-Subedi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).