Bluetooth: hci_conn: Fix not cleaning up PA_LINK connections
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 Bluetooth: hci_conn: Fix not cleaning up PA_LINK connections
From: Luiz Augusto von Dentz <[email protected]>
Contrary to what was stated on d36349ea73d8 ("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.
--- net/bluetooth/hci_conn.c | 30 +++++++++++++++++------------- net/bluetooth/hci_event.c | 7 +------ net/bluetooth/hci_sync.c | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-)
net/bluetooth/hci_conn.c +17 -13
@@ -769,18 +769,19 @@ static void find_bis(struct hci_conn *conn, void *data) d->count++; } -static int hci_le_big_terminate (struct hci_dev *hdev,u8 big,struct hci_conn *conn) +static int hci_le_big_terminate (struct hci_dev *hdev,struct hci_conn *conn) {struct iso_list_data *d;int ret; -bt_dev_dbg (hdev,"big 0x%2.2x sync_handle 0x%4.4x" , big, conn->sync_handle); +bt_dev_dbg (hdev,"hcon %p big 0x%2.2x sync_handle 0x%4.4x" , conn, + conn->iso_qos.bcast.big, conn->sync_handle); d =kzalloc (sizeof (*d),GFP_KERNEL );if (!d)return -ENOMEM ; - d->big = big; + d->big = conn->iso_qos.bcast.big; d->sync_handle = conn->sync_handle;if (test_and_clear_bit (HCI_CONN_PA_SYNC , &conn->flags)) {
@@ -801,6 +802,9 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, struct hci_conn *c d->big_sync_term = true; } +if (!d->pa_sync_term && !d->big_sync_term) +return 0 ; + ret =hci_cmd_sync_queue (hdev, big_terminate_sync, d, terminate_big_destroy);if (ret)
@@ -852,8 +856,7 @@ static void bis_cleanup(struct hci_conn *conn)hci_le_terminate_big (hdev, conn); }else { -hci_le_big_terminate (hdev, conn->iso_qos.bcast.big, - conn); +hci_le_big_terminate (hdev, conn); } }
@@ -1006,19 +1009,20 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, conn->mtu = hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu;break ;case CIS_LINK : -case BIS_LINK : -case PA_LINK :/* conn->src should reflect the local identity address */ hci_copy_identity_address (hdev, &conn->src, &conn->src_type); -/* set proper cleanup function */ -if (!bacmp (dst,BDADDR_ANY )) - conn->cleanup = bis_cleanup; -else if (conn->role ==HCI_ROLE_MASTER ) +if (conn->role ==HCI_ROLE_MASTER ) conn->cleanup = cis_cleanup; - conn->mtu = hdev->iso_mtu ? hdev->iso_mtu : - hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu; + conn->mtu = hdev->iso_mtu; +break ; +case PA_LINK : +case BIS_LINK : +/* conn->src should reflect the local identity address */ +hci_copy_identity_address (hdev, &conn->src, &conn->src_type); + conn->cleanup = bis_cleanup; + conn->mtu = hdev->iso_mtu;break ;case SCO_LINK :if (lmp_esco_capable (hdev))
net/bluetooth/hci_event.c +1 -6
@@ -7056,14 +7056,9 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,continue ; } -if (ev->status !=0x42 ) { +if (ev->status !=0x42 )/* Mark PA sync as established */ set_bit (HCI_CONN_PA_SYNC , &bis->flags); -/* Reset cleanup callback of PA Sync so it doesn't -* terminate the sync when deleting the connection. -*/ - conn->cleanup =NULL ; - } bis->sync_handle = conn->sync_handle; bis->iso_qos.bcast.big = ev->handle;
net/bluetooth/hci_sync.c +1 -1
@@ -7006,7 +7006,7 @@ static void create_pa_complete(struct hci_dev *hdev, void *data, int err)hci_dev_lock (hdev); -if (!hci_conn_valid (hdev, conn)) +if (hci_conn_valid (hdev, conn))clear_bit (HCI_CONN_CREATE_PA_SYNC , &conn->flags);if (!err)
Signature · 1 line
2.51.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1019638
---Test result---
Test Summary:
CheckPatch PENDING 0.39 seconds GitLint PENDING 0.37 seconds SubjectPrefix PASS 0.06 seconds BuildKernel PASS 24.34 seconds CheckAllWarning PASS 27.47 seconds CheckSparse WARNING 30.34 seconds BuildKernel32 PASS 24.28 seconds TestRunnerSetup PASS 490.02 seconds TestRunner_l2cap-tester PASS 23.64 seconds TestRunner_iso-tester PASS 69.87 seconds TestRunner_bnep-tester PASS 6.12 seconds TestRunner_mgmt-tester FAIL 111.15 seconds TestRunner_rfcomm-tester PASS 9.08 seconds TestRunner_sco-tester PASS 14.26 seconds TestRunner_ioctl-tester PASS 9.91 seconds TestRunner_mesh-tester FAIL 11.64 seconds TestRunner_smp-tester PASS 8.43 seconds TestRunner_userchan-tester PASS 6.50 seconds IncrementalBuild PENDING 0.65 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.095 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.174 seconds Mesh - Send cancel - 2 Timed out 1.995 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth