Skip to content

Commit 0d92808

Browse files
committed
Bluetooth: HCI: Fix tracking of advertisement set/instance 0x00
This fixes the state tracking of advertisement set/instance 0x00 which is considered a legacy instance and is not tracked individually by adv_instances list, previously it was assumed that hci_dev itself would track it via HCI_LE_ADV but that is a global state not specifc to instance 0x00, so to fix it a new flag is introduced that only tracks the state of instance 0x00. Fixes: 1488af7 ("Bluetooth: hci_sync: Fix hci_resume_advertising_sync") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 77343b8 commit 0d92808

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

include/net/bluetooth/hci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ enum {
434434
HCI_USER_CHANNEL,
435435
HCI_EXT_CONFIGURED,
436436
HCI_LE_ADV,
437+
HCI_LE_ADV_0,
437438
HCI_LE_PER_ADV,
438439
HCI_LE_SCAN,
439440
HCI_SSP_ENABLED,

net/bluetooth/hci_event.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,8 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,
16091609

16101610
if (adv && !adv->periodic)
16111611
adv->enabled = true;
1612+
else if (!set->handle)
1613+
hci_dev_set_flag(hdev, HCI_LE_ADV_0);
16121614

16131615
conn = hci_lookup_le_connect(hdev);
16141616
if (conn)
@@ -1619,6 +1621,8 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,
16191621
if (cp->num_of_sets) {
16201622
if (adv)
16211623
adv->enabled = false;
1624+
else if (!set->handle)
1625+
hci_dev_clear_flag(hdev, HCI_LE_ADV_0);
16221626

16231627
/* If just one instance was disabled check if there are
16241628
* any other instance enabled before clearing HCI_LE_ADV

net/bluetooth/hci_sync.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,9 +2606,8 @@ static int hci_resume_advertising_sync(struct hci_dev *hdev)
26062606
/* If current advertising instance is set to instance 0x00
26072607
* then we need to re-enable it.
26082608
*/
2609-
if (!hdev->cur_adv_instance)
2610-
err = hci_enable_ext_advertising_sync(hdev,
2611-
hdev->cur_adv_instance);
2609+
if (hci_dev_test_and_clear_flag(hdev, HCI_LE_ADV_0))
2610+
err = hci_enable_ext_advertising_sync(hdev, 0x00);
26122611
} else {
26132612
/* Schedule for most recent instance to be restarted and begin
26142613
* the software rotation loop

0 commit comments

Comments
 (0)