Skip to content

Commit 41bf233

Browse files
committed
Bluetooth: hci_conn: Fix not cleaning up PA_LINK connections
Contrary to what was stated on d36349e ("Bluetooth: hci_conn: Fix running bis_cleanup for hci_conn->type PA_LINK") the PA_LINK does in fact needs to run bis_cleanup in order to terminate the PA Sync, since that is bond to the listening socket which is the entity that controls the lifetime of PA Sync, so if it is closed/released the PA Sync shall be terminated, terminating the PA Sync shall not result in the BIG Sync being terminated since once the later is established it doesn't depend on the former anymore. If the use user wants to reconnect/rebind a number of BIS(s) it shall keep the socket open until it no longer needs the PA Sync, which means it retains full control of the lifetime of both PA and BIG Syncs. Fixes: d36349e ("Bluetooth: hci_conn: Fix running bis_cleanup for hci_conn->type PA_LINK") Fixes: a7bcffc ("Bluetooth: Add PA_LINK to distinguish BIG sync and PA sync connections") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 15f32ca commit 41bf233

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

net/bluetooth/hci_conn.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -769,21 +769,23 @@ static void find_bis(struct hci_conn *conn, void *data)
769769
d->count++;
770770
}
771771

772-
static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, struct hci_conn *conn)
772+
static int hci_le_big_terminate(struct hci_dev *hdev, struct hci_conn *conn)
773773
{
774774
struct iso_list_data *d;
775775
int ret;
776776

777-
bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, conn->sync_handle);
777+
bt_dev_dbg(hdev, "hcon %p big 0x%2.2x sync_handle 0x%4.4x", conn,
778+
conn->iso_qos.bcast.big, conn->sync_handle);
778779

779780
d = kzalloc(sizeof(*d), GFP_KERNEL);
780781
if (!d)
781782
return -ENOMEM;
782783

783-
d->big = big;
784+
d->big = conn->iso_qos.bcast.big;
784785
d->sync_handle = conn->sync_handle;
785786

786-
if (test_and_clear_bit(HCI_CONN_PA_SYNC, &conn->flags)) {
787+
if (conn->type == PA_LINK &&
788+
test_and_clear_bit(HCI_CONN_PA_SYNC, &conn->flags)) {
787789
hci_conn_hash_list_flag(hdev, find_bis, PA_LINK,
788790
HCI_CONN_PA_SYNC, d);
789791

@@ -801,6 +803,9 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, struct hci_conn *c
801803
d->big_sync_term = true;
802804
}
803805

806+
if (!d->pa_sync_term && !d->big_sync_term)
807+
return 0;
808+
804809
ret = hci_cmd_sync_queue(hdev, big_terminate_sync, d,
805810
terminate_big_destroy);
806811
if (ret)
@@ -852,8 +857,7 @@ static void bis_cleanup(struct hci_conn *conn)
852857

853858
hci_le_terminate_big(hdev, conn);
854859
} else {
855-
hci_le_big_terminate(hdev, conn->iso_qos.bcast.big,
856-
conn);
860+
hci_le_big_terminate(hdev, conn);
857861
}
858862
}
859863

@@ -994,19 +998,20 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t
994998
conn->mtu = hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu;
995999
break;
9961000
case CIS_LINK:
997-
case BIS_LINK:
998-
case PA_LINK:
9991001
/* conn->src should reflect the local identity address */
10001002
hci_copy_identity_address(hdev, &conn->src, &conn->src_type);
10011003

1002-
/* set proper cleanup function */
1003-
if (!bacmp(dst, BDADDR_ANY))
1004-
conn->cleanup = bis_cleanup;
1005-
else if (conn->role == HCI_ROLE_MASTER)
1004+
if (conn->role == HCI_ROLE_MASTER)
10061005
conn->cleanup = cis_cleanup;
10071006

1008-
conn->mtu = hdev->iso_mtu ? hdev->iso_mtu :
1009-
hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu;
1007+
conn->mtu = hdev->iso_mtu;
1008+
break;
1009+
case PA_LINK:
1010+
case BIS_LINK:
1011+
/* conn->src should reflect the local identity address */
1012+
hci_copy_identity_address(hdev, &conn->src, &conn->src_type);
1013+
conn->cleanup = bis_cleanup;
1014+
conn->mtu = hdev->iso_mtu;
10101015
break;
10111016
case SCO_LINK:
10121017
if (lmp_esco_capable(hdev))

net/bluetooth/hci_event.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7001,14 +7001,9 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,
70017001
continue;
70027002
}
70037003

7004-
if (ev->status != 0x42) {
7004+
if (ev->status != 0x42)
70057005
/* Mark PA sync as established */
70067006
set_bit(HCI_CONN_PA_SYNC, &bis->flags);
7007-
/* Reset cleanup callback of PA Sync so it doesn't
7008-
* terminate the sync when deleting the connection.
7009-
*/
7010-
conn->cleanup = NULL;
7011-
}
70127007

70137008
bis->sync_handle = conn->sync_handle;
70147009
bis->iso_qos.bcast.big = ev->handle;

net/bluetooth/hci_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6999,7 +6999,7 @@ static void create_pa_complete(struct hci_dev *hdev, void *data, int err)
69996999

70007000
hci_dev_lock(hdev);
70017001

7002-
if (!hci_conn_valid(hdev, conn))
7002+
if (hci_conn_valid(hdev, conn))
70037003
clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags);
70047004

70057005
if (!err)

0 commit comments

Comments
 (0)