linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Don't restart scanning if paused
@ 2020-06-24 18:34 Abhishek Pandit-Subedi
  2020-06-24 19:40 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-06-24 18:34 UTC (permalink / raw)
  To: marcel, linux-bluetooth, alainm
  Cc: chromeos-bluetooth-upstreaming, Abhishek Pandit-Subedi,
	David S. Miller, Johan Hedberg, netdev, linux-kernel,
	Jakub Kicinski

When restarting LE scanning, check if it's currently paused before
enabling passive scanning.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---
When running suspend stress tests on Chromebooks, we discovered
instances where the Chromebook didn't enter the deepest idle states
(i.e. S0ix). After some debugging, we found that passive scanning was
being enabled AFTER the suspend notifier had run (and disabled all
scanning).

For this fix, I simply looked at all the places where we call
HCI_OP_LE_SET_SCAN_ENABLE and added a guard clause for suspend. With
this fix, we were able to get through 100+ iterations of the suspend
stress test without any problems entering S0ix.


 net/bluetooth/hci_request.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 86ae4b953a011e..116207009dde01 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -819,6 +819,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
 {
 	struct hci_dev *hdev = req->hdev;
 
+	if (hdev->scanning_paused) {
+		bt_dev_dbg(hdev, "Scanning is paused for suspend");
+		return;
+	}
+
 	/* Use ext scanning if set ext scan param and ext scan enable is
 	 * supported
 	 */
@@ -2657,6 +2662,11 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt)
 	if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
 		return 0;
 
+	if (hdev->scanning_paused) {
+		bt_dev_dbg(hdev, "Scanning is paused for suspend");
+		return 0;
+	}
+
 	hci_req_add_le_scan_disable(req);
 
 	if (use_ext_scan(hdev)) {
-- 
2.27.0.111.gc72c7da667-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Bluetooth: Don't restart scanning if paused
  2020-06-24 18:34 [PATCH] Bluetooth: Don't restart scanning if paused Abhishek Pandit-Subedi
@ 2020-06-24 19:40 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2020-06-24 19:40 UTC (permalink / raw)
  To: Abhishek Pandit-Subedi
  Cc: BlueZ, Alain Michaud, ChromeOS Bluetooth Upstreaming,
	David S. Miller, Johan Hedberg, netdev, kernel list,
	Jakub Kicinski

Hi Abhishek,

> When restarting LE scanning, check if it's currently paused before
> enabling passive scanning.
> 
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> ---
> When running suspend stress tests on Chromebooks, we discovered
> instances where the Chromebook didn't enter the deepest idle states
> (i.e. S0ix). After some debugging, we found that passive scanning was
> being enabled AFTER the suspend notifier had run (and disabled all
> scanning).
> 
> For this fix, I simply looked at all the places where we call
> HCI_OP_LE_SET_SCAN_ENABLE and added a guard clause for suspend. With
> this fix, we were able to get through 100+ iterations of the suspend
> stress test without any problems entering S0ix.
> 
> 
> net/bluetooth/hci_request.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-24 19:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24 18:34 [PATCH] Bluetooth: Don't restart scanning if paused Abhishek Pandit-Subedi
2020-06-24 19:40 ` Marcel Holtmann

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).