linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Do not cancel advertising when starting a scan
@ 2020-03-17  5:40 Manish Mandlik
  2020-03-18 11:26 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Manish Mandlik @ 2020-03-17  5:40 UTC (permalink / raw)
  To: marcel
  Cc: Yoni Shavit, Alain Michaud, Miao-chen Chou, linux-bluetooth,
	Dmitry Grinberg, Manish Mandlik, David S. Miller, Johan Hedberg,
	netdev, linux-kernel, Jakub Kicinski

From: Dmitry Grinberg <dmitrygr@google.com>

BlueZ cancels adv when starting a scan, but does not cancel a scan when
starting to adv. Neither is required, so this brings both to a
consistent state (of not affecting each other). Some very rare (I've
never seen one) BT 4.0 chips will fail to do both at once. Even this is
ok since the command that will fail will be the second one, and thus the
common sense logic of first-come-first-served is preserved for BLE
requests.

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

 net/bluetooth/hci_request.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index bf83179ab9d19..649e1e5ed446a 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -2727,23 +2727,6 @@ static int active_scan(struct hci_request *req, unsigned long opt)
 
 	BT_DBG("%s", hdev->name);
 
-	if (hci_dev_test_flag(hdev, HCI_LE_ADV)) {
-		hci_dev_lock(hdev);
-
-		/* Don't let discovery abort an outgoing connection attempt
-		 * that's using directed advertising.
-		 */
-		if (hci_lookup_le_connect(hdev)) {
-			hci_dev_unlock(hdev);
-			return -EBUSY;
-		}
-
-		cancel_adv_timeout(hdev);
-		hci_dev_unlock(hdev);
-
-		__hci_req_disable_advertising(req);
-	}
-
 	/* If controller is scanning, it means the background scanning is
 	 * running. Thus, we should temporarily stop it in order to set the
 	 * discovery scanning parameters.
-- 
2.25.1.481.gfbce0eb801-goog


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

* Re: [PATCH] Bluetooth: Do not cancel advertising when starting a scan
  2020-03-17  5:40 [PATCH] Bluetooth: Do not cancel advertising when starting a scan Manish Mandlik
@ 2020-03-18 11:26 ` Marcel Holtmann
  2020-03-18 11:31   ` Emil Lenngren
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2020-03-18 11:26 UTC (permalink / raw)
  To: Manish Mandlik
  Cc: Yoni Shavit, Alain Michaud, Miao-chen Chou, linux-bluetooth,
	Dmitry Grinberg, David S. Miller, Johan Hedberg, netdev,
	linux-kernel, Jakub Kicinski

Hi Manish,

> BlueZ cancels adv when starting a scan, but does not cancel a scan when
> starting to adv. Neither is required, so this brings both to a
> consistent state (of not affecting each other). Some very rare (I've
> never seen one) BT 4.0 chips will fail to do both at once. Even this is
> ok since the command that will fail will be the second one, and thus the
> common sense logic of first-come-first-served is preserved for BLE
> requests.
> 
> Signed-off-by: Dmitry Grinberg <dmitrygr@google.com>
> Signed-off-by: Manish Mandlik <mmandlik@google.com>
> ---
> 
> net/bluetooth/hci_request.c | 17 -----------------
> 1 file changed, 17 deletions(-)

patch has been applied to bluetooth-next tree.

If you know the controller that doesn’t support this, can we blacklist that one and just disable advertising (peripheral mode) for that controller.

Regards

Marcel


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

* Re: [PATCH] Bluetooth: Do not cancel advertising when starting a scan
  2020-03-18 11:26 ` Marcel Holtmann
@ 2020-03-18 11:31   ` Emil Lenngren
  2020-03-18 11:54     ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Emil Lenngren @ 2020-03-18 11:31 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Manish Mandlik, Yoni Shavit, Alain Michaud, Miao-chen Chou,
	Bluez mailing list, Dmitry Grinberg, David S. Miller,
	Johan Hedberg, Network Development, LKML, Jakub Kicinski

Hi,

Den ons 18 mars 2020 kl 12:27 skrev Marcel Holtmann <marcel@holtmann.org>:
>
> Hi Manish,
>
> > BlueZ cancels adv when starting a scan, but does not cancel a scan when
> > starting to adv. Neither is required, so this brings both to a
> > consistent state (of not affecting each other). Some very rare (I've
> > never seen one) BT 4.0 chips will fail to do both at once. Even this is
> > ok since the command that will fail will be the second one, and thus the
> > common sense logic of first-come-first-served is preserved for BLE
> > requests.
> >
> > Signed-off-by: Dmitry Grinberg <dmitrygr@google.com>
> > Signed-off-by: Manish Mandlik <mmandlik@google.com>
> > ---
> >
> > net/bluetooth/hci_request.c | 17 -----------------
> > 1 file changed, 17 deletions(-)
>
> patch has been applied to bluetooth-next tree.
>
> If you know the controller that doesn’t support this, can we blacklist that one and just disable advertising (peripheral mode) for that controller.

Can't the "LE Supported States" be inspected instead to figure out
what simultaneous capabilities are supported? It seems a bit rough to
always assume the worst.

/Emil

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

* Re: [PATCH] Bluetooth: Do not cancel advertising when starting a scan
  2020-03-18 11:31   ` Emil Lenngren
@ 2020-03-18 11:54     ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-03-18 11:54 UTC (permalink / raw)
  To: Emil Lenngren
  Cc: Manish Mandlik, Yoni Shavit, Alain Michaud, Miao-chen Chou,
	Bluez mailing list, Dmitry Grinberg, David S. Miller,
	Johan Hedberg, Network Development, LKML, Jakub Kicinski

Hi Emil,

>>> BlueZ cancels adv when starting a scan, but does not cancel a scan when
>>> starting to adv. Neither is required, so this brings both to a
>>> consistent state (of not affecting each other). Some very rare (I've
>>> never seen one) BT 4.0 chips will fail to do both at once. Even this is
>>> ok since the command that will fail will be the second one, and thus the
>>> common sense logic of first-come-first-served is preserved for BLE
>>> requests.
>>> 
>>> Signed-off-by: Dmitry Grinberg <dmitrygr@google.com>
>>> Signed-off-by: Manish Mandlik <mmandlik@google.com>
>>> ---
>>> 
>>> net/bluetooth/hci_request.c | 17 -----------------
>>> 1 file changed, 17 deletions(-)
>> 
>> patch has been applied to bluetooth-next tree.
>> 
>> If you know the controller that doesn’t support this, can we blacklist that one and just disable advertising (peripheral mode) for that controller.
> 
> Can't the "LE Supported States" be inspected instead to figure out
> what simultaneous capabilities are supported? It seems a bit rough to
> always assume the worst.

if there are not false-positives, then yes, by all means. However my statement still applies. If a controller can do scanning and advertising at the same time, we should just not indicate support for peripheral mode.

Regards

Marcel


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

end of thread, other threads:[~2020-03-18 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17  5:40 [PATCH] Bluetooth: Do not cancel advertising when starting a scan Manish Mandlik
2020-03-18 11:26 ` Marcel Holtmann
2020-03-18 11:31   ` Emil Lenngren
2020-03-18 11:54     ` 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).