]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: ISO: Use sk_sndtimeo as conn_timeout
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 13 Aug 2025 19:21:19 +0000 (15:21 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:33 +0000 (15:37 -0500)
[ Upstream commit 339a87883a14d6a818ca436fed41aa5d10e0f4bd ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_conn.c
net/bluetooth/iso.c

index 8a4b2ac15f47053427cc95dbcc5f2abee813d137..8d78cb2b9f1ab2db2665576f8d063c0b2b003875 100644 (file)
@@ -1588,16 +1588,18 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
                                 __u16 setting, struct bt_codec *codec,
                                 u16 timeout);
 struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
-                             __u8 dst_type, struct bt_iso_qos *qos);
+                             __u8 dst_type, struct bt_iso_qos *qos,
+                             u16 timeout);
 struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
                              struct bt_iso_qos *qos,
-                             __u8 base_len, __u8 *base);
+                             __u8 base_len, __u8 *base, u16 timeout);
 struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
-                                __u8 dst_type, struct bt_iso_qos *qos);
+                                __u8 dst_type, struct bt_iso_qos *qos,
+                                u16 timeout);
 struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
                                 __u8 dst_type, __u8 sid,
                                 struct bt_iso_qos *qos,
-                                __u8 data_len, __u8 *data);
+                                __u8 data_len, __u8 *data, u16 timeout);
 struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst,
                       __u8 dst_type, __u8 sid, struct bt_iso_qos *qos);
 int hci_conn_big_create_sync(struct hci_dev *hdev, struct hci_conn *hcon,
index 63ae62fe20bbc5494376f784b999e6e4dacc2593..c021c6cb3d9a5ec75766d2753c9433facc9b9f86 100644 (file)
@@ -1547,7 +1547,7 @@ static int qos_set_bis(struct hci_dev *hdev, struct bt_iso_qos *qos)
 /* This function requires the caller holds hdev->lock */
 static struct hci_conn *hci_add_bis(struct hci_dev *hdev, bdaddr_t *dst,
                                    __u8 sid, struct bt_iso_qos *qos,
-                                   __u8 base_len, __u8 *base)
+                                   __u8 base_len, __u8 *base, u16 timeout)
 {
        struct hci_conn *conn;
        int err;
@@ -1589,6 +1589,7 @@ static struct hci_conn *hci_add_bis(struct hci_dev *hdev, bdaddr_t *dst,
 
        conn->state = BT_CONNECT;
        conn->sid = sid;
+       conn->conn_timeout = timeout;
 
        hci_conn_hold(conn);
        return conn;
@@ -1929,7 +1930,8 @@ done:
 }
 
 struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
-                             __u8 dst_type, struct bt_iso_qos *qos)
+                             __u8 dst_type, struct bt_iso_qos *qos,
+                             u16 timeout)
 {
        struct hci_conn *cis;
 
@@ -1944,6 +1946,7 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
                cis->dst_type = dst_type;
                cis->iso_qos.ucast.cig = BT_ISO_QOS_CIG_UNSET;
                cis->iso_qos.ucast.cis = BT_ISO_QOS_CIS_UNSET;
+               cis->conn_timeout = timeout;
        }
 
        if (cis->state == BT_CONNECTED)
@@ -2183,7 +2186,7 @@ static void create_big_complete(struct hci_dev *hdev, void *data, int err)
 
 struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
                              struct bt_iso_qos *qos,
-                             __u8 base_len, __u8 *base)
+                             __u8 base_len, __u8 *base, u16 timeout)
 {
        struct hci_conn *conn;
        struct hci_conn *parent;
@@ -2204,7 +2207,7 @@ struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
                                                   base, base_len);
 
        /* We need hci_conn object using the BDADDR_ANY as dst */
-       conn = hci_add_bis(hdev, dst, sid, qos, base_len, eir);
+       conn = hci_add_bis(hdev, dst, sid, qos, base_len, eir, timeout);
        if (IS_ERR(conn))
                return conn;
 
@@ -2257,13 +2260,13 @@ static void bis_mark_per_adv(struct hci_conn *conn, void *data)
 struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
                                 __u8 dst_type, __u8 sid,
                                 struct bt_iso_qos *qos,
-                                __u8 base_len, __u8 *base)
+                                __u8 base_len, __u8 *base, u16 timeout)
 {
        struct hci_conn *conn;
        int err;
        struct iso_list_data data;
 
-       conn = hci_bind_bis(hdev, dst, sid, qos, base_len, base);
+       conn = hci_bind_bis(hdev, dst, sid, qos, base_len, base, timeout);
        if (IS_ERR(conn))
                return conn;
 
@@ -2306,7 +2309,8 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
 }
 
 struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
-                                __u8 dst_type, struct bt_iso_qos *qos)
+                                __u8 dst_type, struct bt_iso_qos *qos,
+                                u16 timeout)
 {
        struct hci_conn *le;
        struct hci_conn *cis;
@@ -2330,7 +2334,7 @@ struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
        hci_iso_qos_setup(hdev, le, &qos->ucast.in,
                          le->le_rx_phy ? le->le_rx_phy : hdev->le_rx_def_phys);
 
-       cis = hci_bind_cis(hdev, dst, dst_type, qos);
+       cis = hci_bind_cis(hdev, dst, dst_type, qos, timeout);
        if (IS_ERR(cis)) {
                hci_conn_drop(le);
                return cis;
index 3b2a4a9d79d615f3fc8fd0b8a61a8957970c9905..3d98cb6291da67a9e234fbc705aff457bc9bf424 100644 (file)
@@ -91,8 +91,8 @@ static struct sock *iso_get_sock(bdaddr_t *src, bdaddr_t *dst,
                                 iso_sock_match_t match, void *data);
 
 /* ---- ISO timers ---- */
-#define ISO_CONN_TIMEOUT       (HZ * 40)
-#define ISO_DISCONN_TIMEOUT    (HZ * 2)
+#define ISO_CONN_TIMEOUT       secs_to_jiffies(20)
+#define ISO_DISCONN_TIMEOUT    secs_to_jiffies(2)
 
 static void iso_conn_free(struct kref *ref)
 {
@@ -369,7 +369,8 @@ static int iso_connect_bis(struct sock *sk)
        if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
                hcon = hci_bind_bis(hdev, &iso_pi(sk)->dst, iso_pi(sk)->bc_sid,
                                    &iso_pi(sk)->qos, iso_pi(sk)->base_len,
-                                   iso_pi(sk)->base);
+                                   iso_pi(sk)->base,
+                                   READ_ONCE(sk->sk_sndtimeo));
                if (IS_ERR(hcon)) {
                        err = PTR_ERR(hcon);
                        goto unlock;
@@ -378,7 +379,8 @@ static int iso_connect_bis(struct sock *sk)
                hcon = hci_connect_bis(hdev, &iso_pi(sk)->dst,
                                       le_addr_type(iso_pi(sk)->dst_type),
                                       iso_pi(sk)->bc_sid, &iso_pi(sk)->qos,
-                                      iso_pi(sk)->base_len, iso_pi(sk)->base);
+                                      iso_pi(sk)->base_len, iso_pi(sk)->base,
+                                      READ_ONCE(sk->sk_sndtimeo));
                if (IS_ERR(hcon)) {
                        err = PTR_ERR(hcon);
                        goto unlock;
@@ -471,7 +473,8 @@ static int iso_connect_cis(struct sock *sk)
        if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
                hcon = hci_bind_cis(hdev, &iso_pi(sk)->dst,
                                    le_addr_type(iso_pi(sk)->dst_type),
-                                   &iso_pi(sk)->qos);
+                                   &iso_pi(sk)->qos,
+                                   READ_ONCE(sk->sk_sndtimeo));
                if (IS_ERR(hcon)) {
                        err = PTR_ERR(hcon);
                        goto unlock;
@@ -479,7 +482,8 @@ static int iso_connect_cis(struct sock *sk)
        } else {
                hcon = hci_connect_cis(hdev, &iso_pi(sk)->dst,
                                       le_addr_type(iso_pi(sk)->dst_type),
-                                      &iso_pi(sk)->qos);
+                                      &iso_pi(sk)->qos,
+                                      READ_ONCE(sk->sk_sndtimeo));
                if (IS_ERR(hcon)) {
                        err = PTR_ERR(hcon);
                        goto unlock;