]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: hci_core: Fix not accounting for BIS/CIS/PA links separately
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 14 Aug 2025 15:57:19 +0000 (11:57 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:45 +0000 (16:34 +0200)
[ Upstream commit 9d4b01a0bf8d2163ae129c9c537cb0753ad5a2aa ]

This fixes the likes of hci_conn_num(CIS_LINK) returning the total of
ISO connection which includes BIS_LINK as well, so this splits the
iso_num into each link type and introduces hci_iso_num that can be used
in places where the total number of ISO connection still needs to be
used.

Fixes: 23205562ffc8 ("Bluetooth: separate CIS_LINK and BIS_LINK link types")
Fixes: a7bcffc673de ("Bluetooth: Add PA_LINK to distinguish BIG sync and PA sync connections")
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

index 459f26d63451690c81f6ac33a4f8bb6a854ea283..439bc124ce7098f834719b1292da2df32777364f 100644 (file)
@@ -129,7 +129,9 @@ struct hci_conn_hash {
        struct list_head list;
        unsigned int     acl_num;
        unsigned int     sco_num;
-       unsigned int     iso_num;
+       unsigned int     cis_num;
+       unsigned int     bis_num;
+       unsigned int     pa_num;
        unsigned int     le_num;
        unsigned int     le_num_peripheral;
 };
@@ -1014,9 +1016,13 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
                h->sco_num++;
                break;
        case CIS_LINK:
+               h->cis_num++;
+               break;
        case BIS_LINK:
+               h->bis_num++;
+               break;
        case PA_LINK:
-               h->iso_num++;
+               h->pa_num++;
                break;
        }
 }
@@ -1042,9 +1048,13 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
                h->sco_num--;
                break;
        case CIS_LINK:
+               h->cis_num--;
+               break;
        case BIS_LINK:
+               h->bis_num--;
+               break;
        case PA_LINK:
-               h->iso_num--;
+               h->pa_num--;
                break;
        }
 }
@@ -1061,9 +1071,11 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
        case ESCO_LINK:
                return h->sco_num;
        case CIS_LINK:
+               return h->cis_num;
        case BIS_LINK:
+               return h->bis_num;
        case PA_LINK:
-               return h->iso_num;
+               return h->pa_num;
        default:
                return 0;
        }
@@ -1073,7 +1085,15 @@ static inline unsigned int hci_conn_count(struct hci_dev *hdev)
 {
        struct hci_conn_hash *c = &hdev->conn_hash;
 
-       return c->acl_num + c->sco_num + c->le_num + c->iso_num;
+       return c->acl_num + c->sco_num + c->le_num + c->cis_num + c->bis_num +
+               c->pa_num;
+}
+
+static inline unsigned int hci_iso_count(struct hci_dev *hdev)
+{
+       struct hci_conn_hash *c = &hdev->conn_hash;
+
+       return c->cis_num + c->bis_num;
 }
 
 static inline bool hci_conn_valid(struct hci_dev *hdev, struct hci_conn *conn)