Skip to content

Commit 5bee2fd

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: hci_sync: Rework background scan
This replaces the use of hci_update_background_scan with hci_update_passive_scan which runs from cmd_work_sync and deal properly with resolving list when LL privacy is enabled. Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent ad383c2 commit 5bee2fd

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

net/bluetooth/hci_conn.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void hci_connect_le_scan_cleanup(struct hci_conn *conn)
108108
break;
109109
}
110110

111-
hci_update_background_scan(hdev);
111+
hci_update_passive_scan(hdev);
112112
}
113113

114114
static void hci_conn_cleanup(struct hci_conn *conn)
@@ -913,7 +913,7 @@ void hci_le_conn_failed(struct hci_conn *conn, u8 status)
913913
/* Since we may have temporarily stopped the background scanning in
914914
* favor of connection establishment, we should restart it.
915915
*/
916-
hci_update_background_scan(hdev);
916+
hci_update_passive_scan(hdev);
917917

918918
/* Re-enable advertising in case this was a failed connection
919919
* attempt as a peripheral.
@@ -1411,7 +1411,7 @@ struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
14111411
conn->conn_timeout = conn_timeout;
14121412
conn->conn_reason = conn_reason;
14131413

1414-
hci_update_background_scan(hdev);
1414+
hci_update_passive_scan(hdev);
14151415

14161416
done:
14171417
hci_conn_hold(conn);

net/bluetooth/hci_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
975975

976976
switch (state) {
977977
case DISCOVERY_STOPPED:
978-
hci_update_background_scan(hdev);
978+
hci_update_passive_scan(hdev);
979979

980980
if (old_state != DISCOVERY_STARTING)
981981
mgmt_discovering(hdev, 0);
@@ -1850,7 +1850,7 @@ int hci_dev_reset_stat(__u16 dev)
18501850
return ret;
18511851
}
18521852

1853-
static void hci_update_scan_state(struct hci_dev *hdev, u8 scan)
1853+
static void hci_update_passive_scan_state(struct hci_dev *hdev, u8 scan)
18541854
{
18551855
bool conn_changed, discov_changed;
18561856

@@ -1951,7 +1951,7 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
19511951
* get correctly modified as this was a non-mgmt change.
19521952
*/
19531953
if (!err)
1954-
hci_update_scan_state(hdev, dr.dev_opt);
1954+
hci_update_passive_scan_state(hdev, dr.dev_opt);
19551955
break;
19561956

19571957
case HCISETLINKPOL:
@@ -3096,7 +3096,7 @@ bool hci_add_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor,
30963096

30973097
switch (hci_get_adv_monitor_offload_ext(hdev)) {
30983098
case HCI_ADV_MONITOR_EXT_NONE:
3099-
hci_update_background_scan(hdev);
3099+
hci_update_passive_scan(hdev);
31003100
bt_dev_dbg(hdev, "%s add monitor status %d", hdev->name, *err);
31013101
/* Message was not forwarded to controller - not an error */
31023102
return false;
@@ -3160,7 +3160,7 @@ bool hci_remove_single_adv_monitor(struct hci_dev *hdev, u16 handle, int *err)
31603160

31613161
pending = hci_remove_adv_monitor(hdev, monitor, handle, err);
31623162
if (!*err && !pending)
3163-
hci_update_background_scan(hdev);
3163+
hci_update_passive_scan(hdev);
31643164

31653165
bt_dev_dbg(hdev, "%s remove monitor handle %d, status %d, %spending",
31663166
hdev->name, handle, *err, pending ? "" : "not ");
@@ -3192,7 +3192,7 @@ bool hci_remove_all_adv_monitor(struct hci_dev *hdev, int *err)
31923192
}
31933193

31943194
if (update)
3195-
hci_update_background_scan(hdev);
3195+
hci_update_passive_scan(hdev);
31963196

31973197
bt_dev_dbg(hdev, "%s remove all monitors status %d, %spending",
31983198
hdev->name, *err, pending ? "" : "not ");
@@ -3486,7 +3486,7 @@ void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
34863486

34873487
hci_conn_params_free(params);
34883488

3489-
hci_update_background_scan(hdev);
3489+
hci_update_passive_scan(hdev);
34903490

34913491
BT_DBG("addr %pMR (type %u)", addr, addr_type);
34923492
}

net/bluetooth/hci_event.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
30283028
case HCI_AUTO_CONN_ALWAYS:
30293029
list_del_init(&params->action);
30303030
list_add(&params->action, &hdev->pend_le_conns);
3031-
hci_update_background_scan(hdev);
3031+
hci_update_passive_scan(hdev);
30323032
break;
30333033

30343034
default:
@@ -5471,7 +5471,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
54715471
}
54725472

54735473
unlock:
5474-
hci_update_background_scan(hdev);
5474+
hci_update_passive_scan(hdev);
54755475
hci_dev_unlock(hdev);
54765476
}
54775477

net/bluetooth/hci_sync.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,5 +2029,14 @@ static int update_passive_scan_sync(struct hci_dev *hdev, void *data)
20292029

20302030
int hci_update_passive_scan(struct hci_dev *hdev)
20312031
{
2032+
/* Only queue if it would have any effect */
2033+
if (!test_bit(HCI_UP, &hdev->flags) ||
2034+
test_bit(HCI_INIT, &hdev->flags) ||
2035+
hci_dev_test_flag(hdev, HCI_SETUP) ||
2036+
hci_dev_test_flag(hdev, HCI_CONFIG) ||
2037+
hci_dev_test_flag(hdev, HCI_AUTO_OFF) ||
2038+
hci_dev_test_flag(hdev, HCI_UNREGISTER))
2039+
return 0;
2040+
20322041
return hci_cmd_sync_queue(hdev, update_passive_scan_sync, NULL, NULL);
20332042
}

net/bluetooth/mgmt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ static int set_connectable_update_settings(struct hci_dev *hdev,
15851585

15861586
if (changed) {
15871587
hci_req_update_scan(hdev);
1588-
hci_update_background_scan(hdev);
1588+
hci_update_passive_scan(hdev);
15891589
return new_settings(hdev, sk);
15901590
}
15911591

@@ -1943,7 +1943,7 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
19431943
__hci_req_update_scan_rsp_data(&req, 0x00);
19441944
}
19451945
hci_req_run(&req, NULL);
1946-
hci_update_background_scan(hdev);
1946+
hci_update_passive_scan(hdev);
19471947
}
19481948

19491949
unlock:
@@ -4488,7 +4488,7 @@ int mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev, u8 status)
44884488
hdev->adv_monitors_cnt++;
44894489
if (monitor->state == ADV_MONITOR_STATE_NOT_REGISTERED)
44904490
monitor->state = ADV_MONITOR_STATE_REGISTERED;
4491-
hci_update_background_scan(hdev);
4491+
hci_update_passive_scan(hdev);
44924492
}
44934493

44944494
err = mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,
@@ -4714,7 +4714,7 @@ int mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, u8 status)
47144714
rp.monitor_handle = cp->monitor_handle;
47154715

47164716
if (!status)
4717-
hci_update_background_scan(hdev);
4717+
hci_update_passive_scan(hdev);
47184718

47194719
err = mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,
47204720
mgmt_status(status), &rp, sizeof(rp));

net/bluetooth/msft.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static void reregister_monitor(struct hci_dev *hdev, int handle)
168168
if (!monitor) {
169169
/* All monitors have been reregistered */
170170
msft->reregistering = false;
171-
hci_update_background_scan(hdev);
171+
hci_update_passive_scan(hdev);
172172
return;
173173
}
174174

0 commit comments

Comments
 (0)