Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: ISO: Use sk_sndtimeo as conn_timeout

This aligns the usage of socket sk_sndtimeo as conn_timeout when
initiating a connection and then use it when scheduling the
resulting HCI command, similar to what has been done in bf98feea5b65
("Bluetooth: hci_conn: Always use sk_timeo as conn_timeout").

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+28 -18
+6 -4
include/net/bluetooth/hci_core.h
··· 1587 1587 __u16 setting, struct bt_codec *codec, 1588 1588 u16 timeout); 1589 1589 struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst, 1590 - __u8 dst_type, struct bt_iso_qos *qos); 1590 + __u8 dst_type, struct bt_iso_qos *qos, 1591 + u16 timeout); 1591 1592 struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid, 1592 1593 struct bt_iso_qos *qos, 1593 - __u8 base_len, __u8 *base); 1594 + __u8 base_len, __u8 *base, u16 timeout); 1594 1595 struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst, 1595 - __u8 dst_type, struct bt_iso_qos *qos); 1596 + __u8 dst_type, struct bt_iso_qos *qos, 1597 + u16 timeout); 1596 1598 struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst, 1597 1599 __u8 dst_type, __u8 sid, 1598 1600 struct bt_iso_qos *qos, 1599 - __u8 data_len, __u8 *data); 1601 + __u8 data_len, __u8 *data, u16 timeout); 1600 1602 struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst, 1601 1603 __u8 dst_type, __u8 sid, struct bt_iso_qos *qos); 1602 1604 int hci_conn_big_create_sync(struct hci_dev *hdev, struct hci_conn *hcon,
+12 -8
net/bluetooth/hci_conn.c
··· 1539 1539 /* This function requires the caller holds hdev->lock */ 1540 1540 static struct hci_conn *hci_add_bis(struct hci_dev *hdev, bdaddr_t *dst, 1541 1541 __u8 sid, struct bt_iso_qos *qos, 1542 - __u8 base_len, __u8 *base) 1542 + __u8 base_len, __u8 *base, u16 timeout) 1543 1543 { 1544 1544 struct hci_conn *conn; 1545 1545 int err; ··· 1581 1581 1582 1582 conn->state = BT_CONNECT; 1583 1583 conn->sid = sid; 1584 + conn->conn_timeout = timeout; 1584 1585 1585 1586 hci_conn_hold(conn); 1586 1587 return conn; ··· 1922 1921 } 1923 1922 1924 1923 struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst, 1925 - __u8 dst_type, struct bt_iso_qos *qos) 1924 + __u8 dst_type, struct bt_iso_qos *qos, 1925 + u16 timeout) 1926 1926 { 1927 1927 struct hci_conn *cis; 1928 1928 ··· 1938 1936 cis->dst_type = dst_type; 1939 1937 cis->iso_qos.ucast.cig = BT_ISO_QOS_CIG_UNSET; 1940 1938 cis->iso_qos.ucast.cis = BT_ISO_QOS_CIS_UNSET; 1939 + cis->conn_timeout = timeout; 1941 1940 } 1942 1941 1943 1942 if (cis->state == BT_CONNECTED) ··· 2178 2175 2179 2176 struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid, 2180 2177 struct bt_iso_qos *qos, 2181 - __u8 base_len, __u8 *base) 2178 + __u8 base_len, __u8 *base, u16 timeout) 2182 2179 { 2183 2180 struct hci_conn *conn; 2184 2181 struct hci_conn *parent; ··· 2199 2196 base, base_len); 2200 2197 2201 2198 /* We need hci_conn object using the BDADDR_ANY as dst */ 2202 - conn = hci_add_bis(hdev, dst, sid, qos, base_len, eir); 2199 + conn = hci_add_bis(hdev, dst, sid, qos, base_len, eir, timeout); 2203 2200 if (IS_ERR(conn)) 2204 2201 return conn; 2205 2202 ··· 2252 2249 struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst, 2253 2250 __u8 dst_type, __u8 sid, 2254 2251 struct bt_iso_qos *qos, 2255 - __u8 base_len, __u8 *base) 2252 + __u8 base_len, __u8 *base, u16 timeout) 2256 2253 { 2257 2254 struct hci_conn *conn; 2258 2255 int err; 2259 2256 struct iso_list_data data; 2260 2257 2261 - conn = hci_bind_bis(hdev, dst, sid, qos, base_len, base); 2258 + conn = hci_bind_bis(hdev, dst, sid, qos, base_len, base, timeout); 2262 2259 if (IS_ERR(conn)) 2263 2260 return conn; 2264 2261 ··· 2301 2298 } 2302 2299 2303 2300 struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst, 2304 - __u8 dst_type, struct bt_iso_qos *qos) 2301 + __u8 dst_type, struct bt_iso_qos *qos, 2302 + u16 timeout) 2305 2303 { 2306 2304 struct hci_conn *le; 2307 2305 struct hci_conn *cis; ··· 2326 2322 hci_iso_qos_setup(hdev, le, &qos->ucast.in, 2327 2323 le->le_rx_phy ? le->le_rx_phy : hdev->le_rx_def_phys); 2328 2324 2329 - cis = hci_bind_cis(hdev, dst, dst_type, qos); 2325 + cis = hci_bind_cis(hdev, dst, dst_type, qos, timeout); 2330 2326 if (IS_ERR(cis)) { 2331 2327 hci_conn_drop(le); 2332 2328 return cis;
+10 -6
net/bluetooth/iso.c
··· 91 91 iso_sock_match_t match, void *data); 92 92 93 93 /* ---- ISO timers ---- */ 94 - #define ISO_CONN_TIMEOUT (HZ * 40) 95 - #define ISO_DISCONN_TIMEOUT (HZ * 2) 94 + #define ISO_CONN_TIMEOUT secs_to_jiffies(20) 95 + #define ISO_DISCONN_TIMEOUT secs_to_jiffies(2) 96 96 97 97 static void iso_conn_free(struct kref *ref) 98 98 { ··· 367 367 if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { 368 368 hcon = hci_bind_bis(hdev, &iso_pi(sk)->dst, iso_pi(sk)->bc_sid, 369 369 &iso_pi(sk)->qos, iso_pi(sk)->base_len, 370 - iso_pi(sk)->base); 370 + iso_pi(sk)->base, 371 + READ_ONCE(sk->sk_sndtimeo)); 371 372 if (IS_ERR(hcon)) { 372 373 err = PTR_ERR(hcon); 373 374 goto unlock; ··· 377 376 hcon = hci_connect_bis(hdev, &iso_pi(sk)->dst, 378 377 le_addr_type(iso_pi(sk)->dst_type), 379 378 iso_pi(sk)->bc_sid, &iso_pi(sk)->qos, 380 - iso_pi(sk)->base_len, iso_pi(sk)->base); 379 + iso_pi(sk)->base_len, iso_pi(sk)->base, 380 + READ_ONCE(sk->sk_sndtimeo)); 381 381 if (IS_ERR(hcon)) { 382 382 err = PTR_ERR(hcon); 383 383 goto unlock; ··· 471 469 if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { 472 470 hcon = hci_bind_cis(hdev, &iso_pi(sk)->dst, 473 471 le_addr_type(iso_pi(sk)->dst_type), 474 - &iso_pi(sk)->qos); 472 + &iso_pi(sk)->qos, 473 + READ_ONCE(sk->sk_sndtimeo)); 475 474 if (IS_ERR(hcon)) { 476 475 err = PTR_ERR(hcon); 477 476 goto unlock; ··· 480 477 } else { 481 478 hcon = hci_connect_cis(hdev, &iso_pi(sk)->dst, 482 479 le_addr_type(iso_pi(sk)->dst_type), 483 - &iso_pi(sk)->qos); 480 + &iso_pi(sk)->qos, 481 + READ_ONCE(sk->sk_sndtimeo)); 484 482 if (IS_ERR(hcon)) { 485 483 err = PTR_ERR(hcon); 486 484 goto unlock;