netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Check scan state before disabling during suspend
@ 2020-06-02  1:42 Manish Mandlik
  2020-06-02  1:48 ` Abhishek Pandit-Subedi
  2020-06-03 17:52 ` Marcel Holtmann
  0 siblings, 2 replies; 4+ messages in thread
From: Manish Mandlik @ 2020-06-02  1:42 UTC (permalink / raw)
  To: marcel, luiz.dentz
  Cc: abhishekpandit, linux-bluetooth, chromeos-bluetooth-upstreaming,
	Manish Mandlik, David S. Miller, Johan Hedberg, netdev,
	linux-kernel, Jakub Kicinski

Check current scan state by checking HCI_LE_SCAN flag and send scan
disable command only if scan is already enabled.

Signed-off-by: Manish Mandlik <mmandlik@google.com>
---

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

diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 1fc55685da62d..1acf5b8e0910c 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -998,8 +998,9 @@ static void hci_req_set_event_filter(struct hci_request *req)
 
 static void hci_req_config_le_suspend_scan(struct hci_request *req)
 {
-	/* Can't change params without disabling first */
-	hci_req_add_le_scan_disable(req);
+	/* Before changing params disable scan if enabled */
+	if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN))
+		hci_req_add_le_scan_disable(req);
 
 	/* Configure params and enable scanning */
 	hci_req_add_le_passive_scan(req);
@@ -1065,8 +1066,9 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next)
 		page_scan = SCAN_DISABLED;
 		hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan);
 
-		/* Disable LE passive scan */
-		hci_req_add_le_scan_disable(&req);
+		/* Disable LE passive scan if enabled */
+		if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
+			hci_req_add_le_scan_disable(&req);
 
 		/* Mark task needing completion */
 		set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks);
-- 
2.27.0.rc2.251.g90737beb825-goog


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

* Re: [PATCH] Bluetooth: Check scan state before disabling during suspend
  2020-06-02  1:42 [PATCH] Bluetooth: Check scan state before disabling during suspend Manish Mandlik
@ 2020-06-02  1:48 ` Abhishek Pandit-Subedi
  2020-06-02 12:26   ` Alain Michaud
  2020-06-03 17:52 ` Marcel Holtmann
  1 sibling, 1 reply; 4+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-06-02  1:48 UTC (permalink / raw)
  To: Manish Mandlik
  Cc: Marcel Holtmann, Luiz Augusto von Dentz, Bluez mailing list,
	ChromeOS Bluetooth Upstreaming, David S. Miller, Johan Hedberg,
	netdev, LKML, Jakub Kicinski

Hey linux-bluetooth,

We found this bug when reverting some Chromium maintained patches in
our repository that was conditionally dropping LE scan enable commands
if it wasn't toggling between true/false. On some Intel controllers,
disabling LE scan when it's already disabled resulted in a "Command
Disallowed" and this was causing suspend to fail.

On Mon, Jun 1, 2020 at 6:43 PM Manish Mandlik <mmandlik@google.com> wrote:
>
> Check current scan state by checking HCI_LE_SCAN flag and send scan
> disable command only if scan is already enabled.
>
> Signed-off-by: Manish Mandlik <mmandlik@google.com>
> ---
>
>  net/bluetooth/hci_request.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
> index 1fc55685da62d..1acf5b8e0910c 100644
> --- a/net/bluetooth/hci_request.c
> +++ b/net/bluetooth/hci_request.c
> @@ -998,8 +998,9 @@ static void hci_req_set_event_filter(struct hci_request *req)
>
>  static void hci_req_config_le_suspend_scan(struct hci_request *req)
>  {
> -       /* Can't change params without disabling first */
> -       hci_req_add_le_scan_disable(req);
> +       /* Before changing params disable scan if enabled */
> +       if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN))
> +               hci_req_add_le_scan_disable(req);
>
>         /* Configure params and enable scanning */
>         hci_req_add_le_passive_scan(req);
> @@ -1065,8 +1066,9 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next)
>                 page_scan = SCAN_DISABLED;
>                 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan);
>
> -               /* Disable LE passive scan */
> -               hci_req_add_le_scan_disable(&req);
> +               /* Disable LE passive scan if enabled */
> +               if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
> +                       hci_req_add_le_scan_disable(&req);
>
>                 /* Mark task needing completion */
>                 set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks);
> --
> 2.27.0.rc2.251.g90737beb825-goog
>

Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>

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

* Re: [PATCH] Bluetooth: Check scan state before disabling during suspend
  2020-06-02  1:48 ` Abhishek Pandit-Subedi
@ 2020-06-02 12:26   ` Alain Michaud
  0 siblings, 0 replies; 4+ messages in thread
From: Alain Michaud @ 2020-06-02 12:26 UTC (permalink / raw)
  To: Abhishek Pandit-Subedi
  Cc: Manish Mandlik, Marcel Holtmann, Luiz Augusto von Dentz,
	Bluez mailing list, ChromeOS Bluetooth Upstreaming,
	David S. Miller, Johan Hedberg, netdev, LKML, Jakub Kicinski

On Mon, Jun 1, 2020 at 9:49 PM Abhishek Pandit-Subedi
<abhishekpandit@chromium.org> wrote:
>
> Hey linux-bluetooth,
>
> We found this bug when reverting some Chromium maintained patches in
> our repository that was conditionally dropping LE scan enable commands
> if it wasn't toggling between true/false. On some Intel controllers,
> disabling LE scan when it's already disabled resulted in a "Command
> Disallowed" and this was causing suspend to fail.
>
> On Mon, Jun 1, 2020 at 6:43 PM Manish Mandlik <mmandlik@google.com> wrote:
> >
> > Check current scan state by checking HCI_LE_SCAN flag and send scan
> > disable command only if scan is already enabled.
> >
> > Signed-off-by: Manish Mandlik <mmandlik@google.com>
> > ---
> >
> >  net/bluetooth/hci_request.c | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
> > index 1fc55685da62d..1acf5b8e0910c 100644
> > --- a/net/bluetooth/hci_request.c
> > +++ b/net/bluetooth/hci_request.c
> > @@ -998,8 +998,9 @@ static void hci_req_set_event_filter(struct hci_request *req)
> >
> >  static void hci_req_config_le_suspend_scan(struct hci_request *req)
> >  {
> > -       /* Can't change params without disabling first */
> > -       hci_req_add_le_scan_disable(req);
> > +       /* Before changing params disable scan if enabled */
> > +       if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN))
> > +               hci_req_add_le_scan_disable(req);
> >
> >         /* Configure params and enable scanning */
> >         hci_req_add_le_passive_scan(req);
> > @@ -1065,8 +1066,9 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next)
> >                 page_scan = SCAN_DISABLED;
> >                 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan);
> >
> > -               /* Disable LE passive scan */
> > -               hci_req_add_le_scan_disable(&req);
> > +               /* Disable LE passive scan if enabled */
> > +               if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
> > +                       hci_req_add_le_scan_disable(&req);
> >
> >                 /* Mark task needing completion */
> >                 set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks);
> > --
> > 2.27.0.rc2.251.g90737beb825-goog
> >
>
> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
>
> --
> You received this message because you are subscribed to the Google Groups "ChromeOS Bluetooth Upstreaming" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org.
> To post to this group, send email to chromeos-bluetooth-upstreaming@chromium.org.
> To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromeos-bluetooth-upstreaming/CANFp7mXDvdicvyEpU-oDu4fBj92nQ7SENVdd_rG9TFQkqDevZg%40mail.gmail.com.

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

* Re: [PATCH] Bluetooth: Check scan state before disabling during suspend
  2020-06-02  1:42 [PATCH] Bluetooth: Check scan state before disabling during suspend Manish Mandlik
  2020-06-02  1:48 ` Abhishek Pandit-Subedi
@ 2020-06-03 17:52 ` Marcel Holtmann
  1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-06-03 17:52 UTC (permalink / raw)
  To: Manish Mandlik
  Cc: Luiz Augusto von Dentz, Abhishek Pandit-Subedi,
	Bluez mailing list, ChromeOS Bluetooth Upstreaming,
	David S. Miller, Johan Hedberg, netdev, open list,
	Jakub Kicinski

Hi Manish,

> Check current scan state by checking HCI_LE_SCAN flag and send scan
> disable command only if scan is already enabled.
> 
> Signed-off-by: Manish Mandlik <mmandlik@google.com>
> ---
> 
> net/bluetooth/hci_request.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, other threads:[~2020-06-03 17:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  1:42 [PATCH] Bluetooth: Check scan state before disabling during suspend Manish Mandlik
2020-06-02  1:48 ` Abhishek Pandit-Subedi
2020-06-02 12:26   ` Alain Michaud
2020-06-03 17:52 ` 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).