diff mbox series

[v2,1/1] Bluetooth: ISO: Fix BIS cleanup

Message ID 20230906135954.9165-2-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit 84aeff2468e58a5eb08d0d301466480e690b2b0e
Headers show
Series Bluetooth: ISO: Fix BIS cleanup | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/BuildKernel success BuildKernel PASS
tedd_an/CheckAllWarning success CheckAllWarning PASS
tedd_an/CheckSparse success CheckSparse PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/BuildKernel32 success BuildKernel32 PASS
tedd_an/TestRunnerSetup success TestRunnerSetup PASS
tedd_an/TestRunner_l2cap-tester success TestRunner PASS
tedd_an/TestRunner_iso-tester success TestRunner PASS
tedd_an/TestRunner_bnep-tester success TestRunner PASS
tedd_an/TestRunner_mgmt-tester success TestRunner PASS
tedd_an/TestRunner_rfcomm-tester success TestRunner PASS
tedd_an/TestRunner_sco-tester success TestRunner PASS
tedd_an/TestRunner_ioctl-tester success TestRunner PASS
tedd_an/TestRunner_mesh-tester success TestRunner PASS
tedd_an/TestRunner_smp-tester success TestRunner PASS
tedd_an/TestRunner_userchan-tester success TestRunner PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Iulia Tanasescu Sept. 6, 2023, 1:59 p.m. UTC
This fixes the master BIS cleanup procedure - as opposed to CIS cleanup,
no HCI disconnect command should be issued. A master BIS should only be
terminated by disabling periodic and extended advertising, and terminating
the BIG.

In case of a Broadcast Receiver, all BIS and PA connections can be
cleaned up by calling hci_conn_failed, since it contains all function
calls that are necessary for successful cleanup.

Signed-off-by: Iulia Tanasescu <iulia.tanasescu@nxp.com>
---
 include/net/bluetooth/hci_sync.h |  2 ++
 net/bluetooth/hci_conn.c         |  7 +++++++
 net/bluetooth/hci_sync.c         | 28 ++++++++++++----------------
 3 files changed, 21 insertions(+), 16 deletions(-)

Comments

bluez.test.bot@gmail.com Sept. 6, 2023, 2:37 p.m. UTC | #1
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=782008

---Test result---

Test Summary:
CheckPatch                    PASS      1.05 seconds
GitLint                       PASS      0.29 seconds
SubjectPrefix                 PASS      0.10 seconds
BuildKernel                   PASS      33.79 seconds
CheckAllWarning               PASS      36.51 seconds
CheckSparse                   PASS      42.30 seconds
CheckSmatch                   PASS      113.23 seconds
BuildKernel32                 PASS      32.19 seconds
TestRunnerSetup               PASS      491.47 seconds
TestRunner_l2cap-tester       PASS      28.54 seconds
TestRunner_iso-tester         PASS      50.90 seconds
TestRunner_bnep-tester        PASS      11.24 seconds
TestRunner_mgmt-tester        PASS      226.03 seconds
TestRunner_rfcomm-tester      PASS      17.05 seconds
TestRunner_sco-tester         PASS      20.13 seconds
TestRunner_ioctl-tester       PASS      18.93 seconds
TestRunner_mesh-tester        PASS      14.16 seconds
TestRunner_smp-tester         PASS      14.98 seconds
TestRunner_userchan-tester    PASS      11.83 seconds
IncrementalBuild              PASS      30.66 seconds



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Sept. 6, 2023, 7:52 p.m. UTC | #2
Hi Iulia,

On Wed, Sep 6, 2023 at 7:00 AM Iulia Tanasescu <iulia.tanasescu@nxp.com> wrote:
>
> This fixes the master BIS cleanup procedure - as opposed to CIS cleanup,
> no HCI disconnect command should be issued. A master BIS should only be
> terminated by disabling periodic and extended advertising, and terminating
> the BIG.
>
> In case of a Broadcast Receiver, all BIS and PA connections can be
> cleaned up by calling hci_conn_failed, since it contains all function
> calls that are necessary for successful cleanup.
>
> Signed-off-by: Iulia Tanasescu <iulia.tanasescu@nxp.com>
> ---
>  include/net/bluetooth/hci_sync.h |  2 ++
>  net/bluetooth/hci_conn.c         |  7 +++++++
>  net/bluetooth/hci_sync.c         | 28 ++++++++++++----------------
>  3 files changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h
> index 57eeb07aeb25..6efbc2152146 100644
> --- a/include/net/bluetooth/hci_sync.h
> +++ b/include/net/bluetooth/hci_sync.h
> @@ -80,6 +80,8 @@ int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len,
>                            u8 *data, u32 flags, u16 min_interval,
>                            u16 max_interval, u16 sync_interval);
>
> +int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);
> +
>  int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
>                                 u8 instance, bool force);
>  int hci_disable_advertising_sync(struct hci_dev *hdev);
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 9d5057cef30a..7c8a5cc72e89 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -759,6 +759,7 @@ static int terminate_big_sync(struct hci_dev *hdev, void *data)
>
>         bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", d->big, d->bis);
>
> +       hci_disable_per_advertising_sync(hdev, d->bis);
>         hci_remove_ext_adv_instance_sync(hdev, d->bis, NULL);
>
>         /* Only terminate BIG if it has been created */
> @@ -1247,6 +1248,12 @@ void hci_conn_failed(struct hci_conn *conn, u8 status)
>                 break;
>         }
>
> +       /* In case of BIG/PA sync failed, clear conn flags so that
> +        * the conns will be correctly cleaned up by ISO layer
> +        */
> +       test_and_clear_bit(HCI_CONN_BIG_SYNC_FAILED, &conn->flags);
> +       test_and_clear_bit(HCI_CONN_PA_SYNC_FAILED, &conn->flags);
> +

I guess we can just use clear_bit here since we won't be using their return.

>         conn->state = BT_CLOSED;
>         hci_connect_cfm(conn, status);
>         hci_conn_del(conn);
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index fd7c5d902856..ec4dfc4c5749 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -1312,7 +1312,7 @@ int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance)
>         return hci_enable_ext_advertising_sync(hdev, instance);
>  }
>
> -static int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
> +int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
>  {
>         struct hci_cp_le_set_per_adv_enable cp;
>         struct adv_info *adv = NULL;
> @@ -5231,6 +5231,17 @@ static int hci_disconnect_sync(struct hci_dev *hdev, struct hci_conn *conn,
>         if (conn->type == AMP_LINK)
>                 return hci_disconnect_phy_link_sync(hdev, conn->handle, reason);
>
> +       if (test_bit(HCI_CONN_BIG_CREATED, &conn->flags)) {
> +               /* This is a BIS connection, hci_conn_del will
> +                * do the necessary cleanup.
> +                */
> +               hci_dev_lock(hdev);
> +               hci_conn_failed(conn, reason);
> +               hci_dev_unlock(hdev);
> +
> +               return 0;
> +       }
> +
>         memset(&cp, 0, sizeof(cp));
>         cp.handle = cpu_to_le16(conn->handle);
>         cp.reason = reason;
> @@ -5382,21 +5393,6 @@ int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason)
>                 err = hci_reject_conn_sync(hdev, conn, reason);
>                 break;
>         case BT_OPEN:
> -               hci_dev_lock(hdev);
> -
> -               /* Cleanup bis or pa sync connections */
> -               if (test_and_clear_bit(HCI_CONN_BIG_SYNC_FAILED, &conn->flags) ||
> -                   test_and_clear_bit(HCI_CONN_PA_SYNC_FAILED, &conn->flags)) {
> -                       hci_conn_failed(conn, reason);
> -               } else if (test_bit(HCI_CONN_PA_SYNC, &conn->flags) ||
> -                          test_bit(HCI_CONN_BIG_SYNC, &conn->flags)) {
> -                       conn->state = BT_CLOSED;
> -                       hci_disconn_cfm(conn, reason);
> -                       hci_conn_del(conn);
> -               }
> -
> -               hci_dev_unlock(hdev);
> -               return 0;
>         case BT_BOUND:
>                 hci_dev_lock(hdev);
>                 hci_conn_failed(conn, reason);
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h
index 57eeb07aeb25..6efbc2152146 100644
--- a/include/net/bluetooth/hci_sync.h
+++ b/include/net/bluetooth/hci_sync.h
@@ -80,6 +80,8 @@  int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len,
 			   u8 *data, u32 flags, u16 min_interval,
 			   u16 max_interval, u16 sync_interval);
 
+int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);
+
 int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
 				u8 instance, bool force);
 int hci_disable_advertising_sync(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 9d5057cef30a..7c8a5cc72e89 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -759,6 +759,7 @@  static int terminate_big_sync(struct hci_dev *hdev, void *data)
 
 	bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", d->big, d->bis);
 
+	hci_disable_per_advertising_sync(hdev, d->bis);
 	hci_remove_ext_adv_instance_sync(hdev, d->bis, NULL);
 
 	/* Only terminate BIG if it has been created */
@@ -1247,6 +1248,12 @@  void hci_conn_failed(struct hci_conn *conn, u8 status)
 		break;
 	}
 
+	/* In case of BIG/PA sync failed, clear conn flags so that
+	 * the conns will be correctly cleaned up by ISO layer
+	 */
+	test_and_clear_bit(HCI_CONN_BIG_SYNC_FAILED, &conn->flags);
+	test_and_clear_bit(HCI_CONN_PA_SYNC_FAILED, &conn->flags);
+
 	conn->state = BT_CLOSED;
 	hci_connect_cfm(conn, status);
 	hci_conn_del(conn);
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index fd7c5d902856..ec4dfc4c5749 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1312,7 +1312,7 @@  int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance)
 	return hci_enable_ext_advertising_sync(hdev, instance);
 }
 
-static int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
+int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
 {
 	struct hci_cp_le_set_per_adv_enable cp;
 	struct adv_info *adv = NULL;
@@ -5231,6 +5231,17 @@  static int hci_disconnect_sync(struct hci_dev *hdev, struct hci_conn *conn,
 	if (conn->type == AMP_LINK)
 		return hci_disconnect_phy_link_sync(hdev, conn->handle, reason);
 
+	if (test_bit(HCI_CONN_BIG_CREATED, &conn->flags)) {
+		/* This is a BIS connection, hci_conn_del will
+		 * do the necessary cleanup.
+		 */
+		hci_dev_lock(hdev);
+		hci_conn_failed(conn, reason);
+		hci_dev_unlock(hdev);
+
+		return 0;
+	}
+
 	memset(&cp, 0, sizeof(cp));
 	cp.handle = cpu_to_le16(conn->handle);
 	cp.reason = reason;
@@ -5382,21 +5393,6 @@  int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason)
 		err = hci_reject_conn_sync(hdev, conn, reason);
 		break;
 	case BT_OPEN:
-		hci_dev_lock(hdev);
-
-		/* Cleanup bis or pa sync connections */
-		if (test_and_clear_bit(HCI_CONN_BIG_SYNC_FAILED, &conn->flags) ||
-		    test_and_clear_bit(HCI_CONN_PA_SYNC_FAILED, &conn->flags)) {
-			hci_conn_failed(conn, reason);
-		} else if (test_bit(HCI_CONN_PA_SYNC, &conn->flags) ||
-			   test_bit(HCI_CONN_BIG_SYNC, &conn->flags)) {
-			conn->state = BT_CLOSED;
-			hci_disconn_cfm(conn, reason);
-			hci_conn_del(conn);
-		}
-
-		hci_dev_unlock(hdev);
-		return 0;
 	case BT_BOUND:
 		hci_dev_lock(hdev);
 		hci_conn_failed(conn, reason);