Skip to content

Commit 8a48a2d

Browse files
committed
Merge tag 'for-net-next-2023-12-22' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Luiz Augusto von Dentz says: ==================== bluetooth-next pull request for net-next: - btnxpuart: Fix recv_buf return value - L2CAP: Fix responding with multiple rejects - Fix atomicity violation in {min,max}_key_size_set - ISO: Allow binding a PA sync socket - ISO: Reassociate a socket with an active BIS - ISO: Avoid creating child socket if PA sync is terminating - Add device 13d3:3572 IMC Networks Bluetooth Radio - Don't suspend when there are connections - Remove le_restart_scan work - Fix bogus check for re-auth not supported with non-ssp - lib: Add documentation to exported functions - Support HFP offload for QCA2066 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 7df5418 + da9065c commit 8a48a2d

File tree

15 files changed

+386
-163
lines changed

15 files changed

+386
-163
lines changed

drivers/bluetooth/btintel.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ static int btintel_version_info_tlv(struct hci_dev *hdev,
535535
bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant,
536536
2000 + (version->timestamp >> 8), version->timestamp & 0xff,
537537
version->build_type, version->build_num);
538+
if (version->img_type == 0x03)
539+
bt_dev_info(hdev, "Firmware SHA1: 0x%8.8x", version->git_sha1);
538540

539541
return 0;
540542
}
@@ -630,6 +632,9 @@ static int btintel_parse_version_tlv(struct hci_dev *hdev,
630632
memcpy(&version->otp_bd_addr, tlv->val,
631633
sizeof(bdaddr_t));
632634
break;
635+
case INTEL_TLV_GIT_SHA1:
636+
version->git_sha1 = get_unaligned_le32(tlv->val);
637+
break;
633638
default:
634639
/* Ignore rest of information */
635640
break;

drivers/bluetooth/btintel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ enum {
4141
INTEL_TLV_LIMITED_CCE,
4242
INTEL_TLV_SBE_TYPE,
4343
INTEL_TLV_OTP_BDADDR,
44-
INTEL_TLV_UNLOCKED_STATE
44+
INTEL_TLV_UNLOCKED_STATE,
45+
INTEL_TLV_GIT_SHA1
4546
};
4647

4748
struct intel_tlv {
@@ -69,6 +70,7 @@ struct intel_version_tlv {
6970
u8 min_fw_build_yy;
7071
u8 limited_cce;
7172
u8 sbe_type;
73+
u32 git_sha1;
7274
bdaddr_t otp_bd_addr;
7375
};
7476

drivers/bluetooth/btmtkuart.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ mtk_stp_split(struct btmtkuart_dev *bdev, const unsigned char *data, int count,
336336
return data;
337337
}
338338

339-
static int btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
339+
static void btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
340340
{
341341
struct btmtkuart_dev *bdev = hci_get_drvdata(hdev);
342342
const unsigned char *p_left = data, *p_h4;
@@ -375,25 +375,20 @@ static int btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
375375
bt_dev_err(bdev->hdev,
376376
"Frame reassembly failed (%d)", err);
377377
bdev->rx_skb = NULL;
378-
return err;
378+
return;
379379
}
380380

381381
sz_left -= sz_h4;
382382
p_left += sz_h4;
383383
}
384-
385-
return 0;
386384
}
387385

388386
static int btmtkuart_receive_buf(struct serdev_device *serdev, const u8 *data,
389387
size_t count)
390388
{
391389
struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev);
392-
int err;
393390

394-
err = btmtkuart_recv(bdev->hdev, data, count);
395-
if (err < 0)
396-
return err;
391+
btmtkuart_recv(bdev->hdev, data, count);
397392

398393
bdev->hdev->stat.byte_rx += count;
399394

drivers/bluetooth/btnxpuart.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,11 +1276,9 @@ static int btnxpuart_receive_buf(struct serdev_device *serdev, const u8 *data,
12761276
if (IS_ERR(nxpdev->rx_skb)) {
12771277
int err = PTR_ERR(nxpdev->rx_skb);
12781278
/* Safe to ignore out-of-sync bootloader signatures */
1279-
if (is_fw_downloading(nxpdev))
1280-
return count;
1281-
bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err);
1282-
nxpdev->rx_skb = NULL;
1283-
return err;
1279+
if (!is_fw_downloading(nxpdev))
1280+
bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err);
1281+
return count;
12841282
}
12851283
if (!is_fw_downloading(nxpdev))
12861284
nxpdev->hdev->stat.byte_rx += count;

drivers/bluetooth/btusb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ static const struct usb_device_id quirks_table[] = {
550550
BTUSB_WIDEBAND_SPEECH },
551551
{ USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK |
552552
BTUSB_WIDEBAND_SPEECH },
553+
{ USB_DEVICE(0x13d3, 0x3572), .driver_info = BTUSB_REALTEK |
554+
BTUSB_WIDEBAND_SPEECH },
553555

554556
/* Realtek Bluetooth devices */
555557
{ USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
@@ -4629,6 +4631,10 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
46294631

46304632
BT_DBG("intf %p", intf);
46314633

4634+
/* Don't suspend if there are connections */
4635+
if (hci_conn_count(data->hdev))
4636+
return -EBUSY;
4637+
46324638
if (data->suspend_count++)
46334639
return 0;
46344640

drivers/bluetooth/hci_qca.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,24 @@ static void hci_coredump_qca(struct hci_dev *hdev)
18151815
kfree_skb(skb);
18161816
}
18171817

1818+
static int qca_get_data_path_id(struct hci_dev *hdev, __u8 *data_path_id)
1819+
{
1820+
/* QCA uses 1 as non-HCI data path id for HFP */
1821+
*data_path_id = 1;
1822+
return 0;
1823+
}
1824+
1825+
static int qca_configure_hfp_offload(struct hci_dev *hdev)
1826+
{
1827+
bt_dev_info(hdev, "HFP non-HCI data transport is supported");
1828+
hdev->get_data_path_id = qca_get_data_path_id;
1829+
/* Do not need to send HCI_Configure_Data_Path to configure non-HCI
1830+
* data transport path for QCA controllers, so set below field as NULL.
1831+
*/
1832+
hdev->get_codec_config_data = NULL;
1833+
return 0;
1834+
}
1835+
18181836
static int qca_setup(struct hci_uart *hu)
18191837
{
18201838
struct hci_dev *hdev = hu->hdev;
@@ -1969,6 +1987,10 @@ static int qca_setup(struct hci_uart *hu)
19691987
hu->hdev->set_bdaddr = qca_set_bdaddr_rome;
19701988
else
19711989
hu->hdev->set_bdaddr = qca_set_bdaddr;
1990+
1991+
if (soc_type == QCA_QCA2066)
1992+
qca_configure_hfp_offload(hdev);
1993+
19721994
qca->fw_version = le16_to_cpu(ver.patch_ver);
19731995
qca->controller_id = le16_to_cpu(ver.rom_ver);
19741996
hci_devcd_register(hdev, hci_coredump_qca, qca_dmp_hdr, NULL);
@@ -2039,6 +2061,7 @@ static const struct qca_device_data qca_soc_data_wcn3998 __maybe_unused = {
20392061
static const struct qca_device_data qca_soc_data_qca2066 __maybe_unused = {
20402062
.soc_type = QCA_QCA2066,
20412063
.num_vregs = 0,
2064+
.capabilities = QCA_CAP_WIDEBAND_SPEECH | QCA_CAP_VALID_LE_STATES,
20422065
};
20432066

20442067
static const struct qca_device_data qca_soc_data_qca6390 __maybe_unused = {

include/net/bluetooth/hci_core.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ struct hci_dev {
539539
struct work_struct tx_work;
540540

541541
struct delayed_work le_scan_disable;
542-
struct delayed_work le_scan_restart;
543542

544543
struct sk_buff_head rx_q;
545544
struct sk_buff_head raw_q;
@@ -957,7 +956,6 @@ void hci_inquiry_cache_flush(struct hci_dev *hdev);
957956
/* ----- HCI Connections ----- */
958957
enum {
959958
HCI_CONN_AUTH_PEND,
960-
HCI_CONN_REAUTH_PEND,
961959
HCI_CONN_ENCRYPT_PEND,
962960
HCI_CONN_RSWITCH_PEND,
963961
HCI_CONN_MODE_CHANGE_PEND,
@@ -1297,6 +1295,30 @@ static inline struct hci_conn *hci_conn_hash_lookup_big(struct hci_dev *hdev,
12971295
return NULL;
12981296
}
12991297

1298+
static inline struct hci_conn *
1299+
hci_conn_hash_lookup_big_state(struct hci_dev *hdev, __u8 handle, __u16 state)
1300+
{
1301+
struct hci_conn_hash *h = &hdev->conn_hash;
1302+
struct hci_conn *c;
1303+
1304+
rcu_read_lock();
1305+
1306+
list_for_each_entry_rcu(c, &h->list, list) {
1307+
if (bacmp(&c->dst, BDADDR_ANY) || c->type != ISO_LINK ||
1308+
c->state != state)
1309+
continue;
1310+
1311+
if (handle == c->iso_qos.bcast.big) {
1312+
rcu_read_unlock();
1313+
return c;
1314+
}
1315+
}
1316+
1317+
rcu_read_unlock();
1318+
1319+
return NULL;
1320+
}
1321+
13001322
static inline struct hci_conn *
13011323
hci_conn_hash_lookup_pa_sync_big_handle(struct hci_dev *hdev, __u8 big)
13021324
{

net/bluetooth/hci_conn.c

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ static int configure_datapath_sync(struct hci_dev *hdev, struct bt_codec *codec)
300300
__u8 vnd_len, *vnd_data = NULL;
301301
struct hci_op_configure_data_path *cmd = NULL;
302302

303+
if (!codec->data_path || !hdev->get_codec_config_data)
304+
return 0;
305+
306+
/* Do not take me as error */
307+
if (!hdev->get_codec_config_data)
308+
return 0;
309+
303310
err = hdev->get_codec_config_data(hdev, ESCO_LINK, codec, &vnd_len,
304311
&vnd_data);
305312
if (err < 0)
@@ -345,9 +352,7 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)
345352

346353
bt_dev_dbg(hdev, "hcon %p", conn);
347354

348-
/* for offload use case, codec needs to configured before opening SCO */
349-
if (conn->codec.data_path)
350-
configure_datapath_sync(hdev, &conn->codec);
355+
configure_datapath_sync(hdev, &conn->codec);
351356

352357
conn->state = BT_CONNECT;
353358
conn->out = true;
@@ -1086,8 +1091,9 @@ static void hci_conn_cleanup_child(struct hci_conn *conn, u8 reason)
10861091
hci_conn_failed(conn, reason);
10871092
break;
10881093
case ISO_LINK:
1089-
if (conn->state != BT_CONNECTED &&
1090-
!test_bit(HCI_CONN_CREATE_CIS, &conn->flags))
1094+
if ((conn->state != BT_CONNECTED &&
1095+
!test_bit(HCI_CONN_CREATE_CIS, &conn->flags)) ||
1096+
test_bit(HCI_CONN_BIG_CREATED, &conn->flags))
10911097
hci_conn_failed(conn, reason);
10921098
break;
10931099
}
@@ -2228,7 +2234,17 @@ struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst,
22282234
__u8 base_len, __u8 *base)
22292235
{
22302236
struct hci_conn *conn;
2237+
struct hci_conn *parent;
22312238
__u8 eir[HCI_MAX_PER_AD_LENGTH];
2239+
struct hci_link *link;
2240+
2241+
/* Look for any BIS that is open for rebinding */
2242+
conn = hci_conn_hash_lookup_big_state(hdev, qos->bcast.big, BT_OPEN);
2243+
if (conn) {
2244+
memcpy(qos, &conn->iso_qos, sizeof(*qos));
2245+
conn->state = BT_CONNECTED;
2246+
return conn;
2247+
}
22322248

22332249
if (base_len && base)
22342250
base_len = eir_append_service_data(eir, 0, 0x1851,
@@ -2256,6 +2272,20 @@ struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst,
22562272
conn->iso_qos = *qos;
22572273
conn->state = BT_BOUND;
22582274

2275+
/* Link BISes together */
2276+
parent = hci_conn_hash_lookup_big(hdev,
2277+
conn->iso_qos.bcast.big);
2278+
if (parent && parent != conn) {
2279+
link = hci_conn_link(parent, conn);
2280+
if (!link) {
2281+
hci_conn_drop(conn);
2282+
return ERR_PTR(-ENOLINK);
2283+
}
2284+
2285+
/* Link takes the refcount */
2286+
hci_conn_drop(conn);
2287+
}
2288+
22592289
return conn;
22602290
}
22612291

@@ -2287,6 +2317,9 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
22872317
if (IS_ERR(conn))
22882318
return conn;
22892319

2320+
if (conn->state == BT_CONNECTED)
2321+
return conn;
2322+
22902323
data.big = qos->bcast.big;
22912324
data.bis = qos->bcast.bis;
22922325

@@ -2421,12 +2454,10 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
24212454
hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
24222455
sizeof(cp), &cp);
24232456

2424-
/* If we're already encrypted set the REAUTH_PEND flag,
2425-
* otherwise set the ENCRYPT_PEND.
2457+
/* Set the ENCRYPT_PEND to trigger encryption after
2458+
* authentication.
24262459
*/
2427-
if (test_bit(HCI_CONN_ENCRYPT, &conn->flags))
2428-
set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
2429-
else
2460+
if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
24302461
set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
24312462
}
24322463

net/bluetooth/hci_debugfs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,10 +1046,12 @@ static int min_key_size_set(void *data, u64 val)
10461046
{
10471047
struct hci_dev *hdev = data;
10481048

1049-
if (val > hdev->le_max_key_size || val < SMP_MIN_ENC_KEY_SIZE)
1049+
hci_dev_lock(hdev);
1050+
if (val > hdev->le_max_key_size || val < SMP_MIN_ENC_KEY_SIZE) {
1051+
hci_dev_unlock(hdev);
10501052
return -EINVAL;
1053+
}
10511054

1052-
hci_dev_lock(hdev);
10531055
hdev->le_min_key_size = val;
10541056
hci_dev_unlock(hdev);
10551057

@@ -1074,10 +1076,12 @@ static int max_key_size_set(void *data, u64 val)
10741076
{
10751077
struct hci_dev *hdev = data;
10761078

1077-
if (val > SMP_MAX_ENC_KEY_SIZE || val < hdev->le_min_key_size)
1079+
hci_dev_lock(hdev);
1080+
if (val > SMP_MAX_ENC_KEY_SIZE || val < hdev->le_min_key_size) {
1081+
hci_dev_unlock(hdev);
10781082
return -EINVAL;
1083+
}
10791084

1080-
hci_dev_lock(hdev);
10811085
hdev->le_max_key_size = val;
10821086
hci_dev_unlock(hdev);
10831087

net/bluetooth/hci_event.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,14 +3500,8 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, void *data,
35003500

35013501
if (!ev->status) {
35023502
clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
3503-
3504-
if (!hci_conn_ssp_enabled(conn) &&
3505-
test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
3506-
bt_dev_info(hdev, "re-auth of legacy device is not possible.");
3507-
} else {
3508-
set_bit(HCI_CONN_AUTH, &conn->flags);
3509-
conn->sec_level = conn->pending_sec_level;
3510-
}
3503+
set_bit(HCI_CONN_AUTH, &conn->flags);
3504+
conn->sec_level = conn->pending_sec_level;
35113505
} else {
35123506
if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING)
35133507
set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
@@ -3516,7 +3510,6 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, void *data,
35163510
}
35173511

35183512
clear_bit(HCI_CONN_AUTH_PEND, &conn->flags);
3519-
clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
35203513

35213514
if (conn->state == BT_CONFIG) {
35223515
if (!ev->status && hci_conn_ssp_enabled(conn)) {

0 commit comments

Comments
 (0)