Skip to content

Commit 2689df9

Browse files
Vudentzgregkh
authored andcommitted
Bluetooth: ISO: Use sk_sndtimeo as conn_timeout
[ Upstream commit 339a878 ] 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 bf98fee ("Bluetooth: hci_conn: Always use sk_timeo as conn_timeout"). Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent e7d1cad commit 2689df9

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,16 +1588,18 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
15881588
__u16 setting, struct bt_codec *codec,
15891589
u16 timeout);
15901590
struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
1591-
__u8 dst_type, struct bt_iso_qos *qos);
1591+
__u8 dst_type, struct bt_iso_qos *qos,
1592+
u16 timeout);
15921593
struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
15931594
struct bt_iso_qos *qos,
1594-
__u8 base_len, __u8 *base);
1595+
__u8 base_len, __u8 *base, u16 timeout);
15951596
struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
1596-
__u8 dst_type, struct bt_iso_qos *qos);
1597+
__u8 dst_type, struct bt_iso_qos *qos,
1598+
u16 timeout);
15971599
struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
15981600
__u8 dst_type, __u8 sid,
15991601
struct bt_iso_qos *qos,
1600-
__u8 data_len, __u8 *data);
1602+
__u8 data_len, __u8 *data, u16 timeout);
16011603
struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst,
16021604
__u8 dst_type, __u8 sid, struct bt_iso_qos *qos);
16031605
int hci_conn_big_create_sync(struct hci_dev *hdev, struct hci_conn *hcon,

net/bluetooth/hci_conn.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ static int qos_set_bis(struct hci_dev *hdev, struct bt_iso_qos *qos)
15471547
/* This function requires the caller holds hdev->lock */
15481548
static struct hci_conn *hci_add_bis(struct hci_dev *hdev, bdaddr_t *dst,
15491549
__u8 sid, struct bt_iso_qos *qos,
1550-
__u8 base_len, __u8 *base)
1550+
__u8 base_len, __u8 *base, u16 timeout)
15511551
{
15521552
struct hci_conn *conn;
15531553
int err;
@@ -1589,6 +1589,7 @@ static struct hci_conn *hci_add_bis(struct hci_dev *hdev, bdaddr_t *dst,
15891589

15901590
conn->state = BT_CONNECT;
15911591
conn->sid = sid;
1592+
conn->conn_timeout = timeout;
15921593

15931594
hci_conn_hold(conn);
15941595
return conn;
@@ -1929,7 +1930,8 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)
19291930
}
19301931

19311932
struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
1932-
__u8 dst_type, struct bt_iso_qos *qos)
1933+
__u8 dst_type, struct bt_iso_qos *qos,
1934+
u16 timeout)
19331935
{
19341936
struct hci_conn *cis;
19351937

@@ -1944,6 +1946,7 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
19441946
cis->dst_type = dst_type;
19451947
cis->iso_qos.ucast.cig = BT_ISO_QOS_CIG_UNSET;
19461948
cis->iso_qos.ucast.cis = BT_ISO_QOS_CIS_UNSET;
1949+
cis->conn_timeout = timeout;
19471950
}
19481951

19491952
if (cis->state == BT_CONNECTED)
@@ -2183,7 +2186,7 @@ static void create_big_complete(struct hci_dev *hdev, void *data, int err)
21832186

21842187
struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
21852188
struct bt_iso_qos *qos,
2186-
__u8 base_len, __u8 *base)
2189+
__u8 base_len, __u8 *base, u16 timeout)
21872190
{
21882191
struct hci_conn *conn;
21892192
struct hci_conn *parent;
@@ -2204,7 +2207,7 @@ struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
22042207
base, base_len);
22052208

22062209
/* We need hci_conn object using the BDADDR_ANY as dst */
2207-
conn = hci_add_bis(hdev, dst, sid, qos, base_len, eir);
2210+
conn = hci_add_bis(hdev, dst, sid, qos, base_len, eir, timeout);
22082211
if (IS_ERR(conn))
22092212
return conn;
22102213

@@ -2257,13 +2260,13 @@ static void bis_mark_per_adv(struct hci_conn *conn, void *data)
22572260
struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
22582261
__u8 dst_type, __u8 sid,
22592262
struct bt_iso_qos *qos,
2260-
__u8 base_len, __u8 *base)
2263+
__u8 base_len, __u8 *base, u16 timeout)
22612264
{
22622265
struct hci_conn *conn;
22632266
int err;
22642267
struct iso_list_data data;
22652268

2266-
conn = hci_bind_bis(hdev, dst, sid, qos, base_len, base);
2269+
conn = hci_bind_bis(hdev, dst, sid, qos, base_len, base, timeout);
22672270
if (IS_ERR(conn))
22682271
return conn;
22692272

@@ -2306,7 +2309,8 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
23062309
}
23072310

23082311
struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
2309-
__u8 dst_type, struct bt_iso_qos *qos)
2312+
__u8 dst_type, struct bt_iso_qos *qos,
2313+
u16 timeout)
23102314
{
23112315
struct hci_conn *le;
23122316
struct hci_conn *cis;
@@ -2330,7 +2334,7 @@ struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
23302334
hci_iso_qos_setup(hdev, le, &qos->ucast.in,
23312335
le->le_rx_phy ? le->le_rx_phy : hdev->le_rx_def_phys);
23322336

2333-
cis = hci_bind_cis(hdev, dst, dst_type, qos);
2337+
cis = hci_bind_cis(hdev, dst, dst_type, qos, timeout);
23342338
if (IS_ERR(cis)) {
23352339
hci_conn_drop(le);
23362340
return cis;

net/bluetooth/iso.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static struct sock *iso_get_sock(bdaddr_t *src, bdaddr_t *dst,
9191
iso_sock_match_t match, void *data);
9292

9393
/* ---- 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)
9696

9797
static void iso_conn_free(struct kref *ref)
9898
{
@@ -369,7 +369,8 @@ static int iso_connect_bis(struct sock *sk)
369369
if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
370370
hcon = hci_bind_bis(hdev, &iso_pi(sk)->dst, iso_pi(sk)->bc_sid,
371371
&iso_pi(sk)->qos, iso_pi(sk)->base_len,
372-
iso_pi(sk)->base);
372+
iso_pi(sk)->base,
373+
READ_ONCE(sk->sk_sndtimeo));
373374
if (IS_ERR(hcon)) {
374375
err = PTR_ERR(hcon);
375376
goto unlock;
@@ -378,7 +379,8 @@ static int iso_connect_bis(struct sock *sk)
378379
hcon = hci_connect_bis(hdev, &iso_pi(sk)->dst,
379380
le_addr_type(iso_pi(sk)->dst_type),
380381
iso_pi(sk)->bc_sid, &iso_pi(sk)->qos,
381-
iso_pi(sk)->base_len, iso_pi(sk)->base);
382+
iso_pi(sk)->base_len, iso_pi(sk)->base,
383+
READ_ONCE(sk->sk_sndtimeo));
382384
if (IS_ERR(hcon)) {
383385
err = PTR_ERR(hcon);
384386
goto unlock;
@@ -471,15 +473,17 @@ static int iso_connect_cis(struct sock *sk)
471473
if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
472474
hcon = hci_bind_cis(hdev, &iso_pi(sk)->dst,
473475
le_addr_type(iso_pi(sk)->dst_type),
474-
&iso_pi(sk)->qos);
476+
&iso_pi(sk)->qos,
477+
READ_ONCE(sk->sk_sndtimeo));
475478
if (IS_ERR(hcon)) {
476479
err = PTR_ERR(hcon);
477480
goto unlock;
478481
}
479482
} else {
480483
hcon = hci_connect_cis(hdev, &iso_pi(sk)->dst,
481484
le_addr_type(iso_pi(sk)->dst_type),
482-
&iso_pi(sk)->qos);
485+
&iso_pi(sk)->qos,
486+
READ_ONCE(sk->sk_sndtimeo));
483487
if (IS_ERR(hcon)) {
484488
err = PTR_ERR(hcon);
485489
goto unlock;

0 commit comments

Comments
 (0)