diff mbox series

[1/2] Bluetooth: ISO: Make iso_get_sock_listen generic

Message ID 20240402113931.3164-2-iulia.tanasescu@nxp.com (mailing list archive)
State New, archived
Headers show
Series Bluetooth: ISO: Handle PA sync when no BIGInfo reports are generated | 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 warning CheckSparse WARNING net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
tedd_an/CheckSmatch fail CheckSparse: FAIL: Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139 make[4]: *** Deleting file 'net/bluetooth/hci_core.o' make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: net] Error 2 make[2]: *** Waiting for unfinished jobs.... Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139 make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o' make[4]: *** Waiting for unfinished jobs.... make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: drivers] Error 2 make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2 make: *** [Makefile:240: __sub-make] Error 2
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 fail TestRunner_iso-tester: Total: 117, Passed: 116 (99.1%), Failed: 1, Not Run: 0
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 April 2, 2024, 11:39 a.m. UTC
This makes iso_get_sock_listen more generic, to return matching socket
in the state provided as argument.

Signed-off-by: Iulia Tanasescu <iulia.tanasescu@nxp.com>
---
 net/bluetooth/iso.c | 75 +++++++++++++++++++++++++--------------------
 1 file changed, 42 insertions(+), 33 deletions(-)

Comments

bluez.test.bot@gmail.com April 2, 2024, 12:42 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=840593

---Test result---

Test Summary:
CheckPatch                    PASS      3.18 seconds
GitLint                       PASS      0.71 seconds
SubjectPrefix                 PASS      0.38 seconds
BuildKernel                   PASS      29.86 seconds
CheckAllWarning               PASS      32.45 seconds
CheckSparse                   WARNING   38.07 seconds
CheckSmatch                   FAIL      41.55 seconds
BuildKernel32                 PASS      28.85 seconds
TestRunnerSetup               PASS      519.08 seconds
TestRunner_l2cap-tester       PASS      17.95 seconds
TestRunner_iso-tester         FAIL      38.42 seconds
TestRunner_bnep-tester        PASS      4.69 seconds
TestRunner_mgmt-tester        PASS      110.75 seconds
TestRunner_rfcomm-tester      PASS      7.29 seconds
TestRunner_sco-tester         PASS      14.86 seconds
TestRunner_ioctl-tester       PASS      7.67 seconds
TestRunner_mesh-tester        PASS      5.83 seconds
TestRunner_smp-tester         PASS      7.54 seconds
TestRunner_userchan-tester    PASS      10.42 seconds
IncrementalBuild              PASS      51.97 seconds

Details
##############################
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: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:

Segmentation fault (core dumped)
make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139
make[4]: *** Deleting file 'net/bluetooth/hci_core.o'
make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:485: net] Error 2
make[2]: *** Waiting for unfinished jobs....
Segmentation fault (core dumped)
make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139
make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o'
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:485: drivers] Error 2
make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 117, Passed: 116 (99.1%), Failed: 1, Not Run: 0

Failed Test Cases
ISO Connect2 Suspend - Success                       Failed       8.248 seconds


---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz April 2, 2024, 3:43 p.m. UTC | #2
Hi Iulia,

On Tue, Apr 2, 2024 at 7:39 AM Iulia Tanasescu <iulia.tanasescu@nxp.com> wrote:
>
> This makes iso_get_sock_listen more generic, to return matching socket
> in the state provided as argument.
>
> Signed-off-by: Iulia Tanasescu <iulia.tanasescu@nxp.com>
> ---
>  net/bluetooth/iso.c | 75 +++++++++++++++++++++++++--------------------
>  1 file changed, 42 insertions(+), 33 deletions(-)
>
> diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
> index 42b4495e019e..3fcaef506bde 100644
> --- a/net/bluetooth/iso.c
> +++ b/net/bluetooth/iso.c
> @@ -85,8 +85,9 @@ static void iso_sock_disconn(struct sock *sk);
>
>  typedef bool (*iso_sock_match_t)(struct sock *sk, void *data);
>
> -static struct sock *iso_get_sock_listen(bdaddr_t *src, bdaddr_t *dst,
> -                                       iso_sock_match_t match, void *data);
> +static struct sock *iso_get_sock(bdaddr_t *src, bdaddr_t *dst,
> +                                unsigned char state,

Lets add a name to the enum in bluetooth.h when the socket states are
defined then we can use it here instead of passing as unsigned char.

> +                                iso_sock_match_t match, void *data);
>
>  /* ---- ISO timers ---- */
>  #define ISO_CONN_TIMEOUT       (HZ * 40)
> @@ -233,10 +234,11 @@ static void iso_conn_del(struct hci_conn *hcon, int err)
>                  * terminated are not processed anymore.
>                  */
>                 if (test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) {
> -                       parent = iso_get_sock_listen(&hcon->src,
> -                                                    &hcon->dst,
> -                                                    iso_match_conn_sync_handle,
> -                                                    hcon);
> +                       parent = iso_get_sock(&hcon->src,
> +                                             &hcon->dst,
> +                                             BT_LISTEN,
> +                                             iso_match_conn_sync_handle,
> +                                             hcon);
>
>                         if (parent) {
>                                 set_bit(BT_SK_PA_SYNC_TERM,
> @@ -584,22 +586,23 @@ static struct sock *__iso_get_sock_listen_by_sid(bdaddr_t *ba, bdaddr_t *bc,
>         return NULL;
>  }
>
> -/* Find socket listening:
> +/* Find socket in given state:
>   * source bdaddr (Unicast)
>   * destination bdaddr (Broadcast only)
>   * match func - pass NULL to ignore
>   * match func data - pass -1 to ignore
>   * Returns closest match.
>   */
> -static struct sock *iso_get_sock_listen(bdaddr_t *src, bdaddr_t *dst,
> -                                       iso_sock_match_t match, void *data)
> +static struct sock *iso_get_sock(bdaddr_t *src, bdaddr_t *dst,
> +                                unsigned char state,
> +                                iso_sock_match_t match, void *data)
>  {
>         struct sock *sk = NULL, *sk1 = NULL;
>
>         read_lock(&iso_sk_list.lock);
>
>         sk_for_each(sk, &iso_sk_list.head) {
> -               if (sk->sk_state != BT_LISTEN)
> +               if (sk->sk_state != state)
>                         continue;
>
>                 /* Match Broadcast destination */
> @@ -1805,32 +1808,37 @@ static void iso_conn_ready(struct iso_conn *conn)
>                                                  HCI_EVT_LE_BIG_SYNC_ESTABILISHED);
>
>                         /* Get reference to PA sync parent socket, if it exists */
> -                       parent = iso_get_sock_listen(&hcon->src,
> -                                                    &hcon->dst,
> -                                                    iso_match_pa_sync_flag, NULL);
> +                       parent = iso_get_sock(&hcon->src, &hcon->dst,
> +                                             BT_LISTEN,
> +                                             iso_match_pa_sync_flag,
> +                                             NULL);
>                         if (!parent && ev)
> -                               parent = iso_get_sock_listen(&hcon->src,
> -                                                            &hcon->dst,
> -                                                            iso_match_big, ev);
> +                               parent = iso_get_sock(&hcon->src,
> +                                                     &hcon->dst,
> +                                                     BT_LISTEN,
> +                                                     iso_match_big, ev);
>                 } else if (test_bit(HCI_CONN_PA_SYNC_FAILED, &hcon->flags)) {
>                         ev2 = hci_recv_event_data(hcon->hdev,
>                                                   HCI_EV_LE_PA_SYNC_ESTABLISHED);
>                         if (ev2)
> -                               parent = iso_get_sock_listen(&hcon->src,
> -                                                            &hcon->dst,
> -                                                            iso_match_sid, ev2);
> +                               parent = iso_get_sock(&hcon->src,
> +                                                     &hcon->dst,
> +                                                     BT_LISTEN,
> +                                                     iso_match_sid, ev2);
>                 } else if (test_bit(HCI_CONN_PA_SYNC, &hcon->flags)) {
>                         ev3 = hci_recv_event_data(hcon->hdev,
>                                                   HCI_EVT_LE_BIG_INFO_ADV_REPORT);
>                         if (ev3)
> -                               parent = iso_get_sock_listen(&hcon->src,
> -                                                            &hcon->dst,
> -                                                            iso_match_sync_handle, ev3);
> +                               parent = iso_get_sock(&hcon->src,
> +                                                     &hcon->dst,
> +                                                     BT_LISTEN,
> +                                                     iso_match_sync_handle,
> +                                                     ev3);
>                 }
>
>                 if (!parent)
> -                       parent = iso_get_sock_listen(&hcon->src,
> -                                                       BDADDR_ANY, NULL, NULL);
> +                       parent = iso_get_sock(&hcon->src, BDADDR_ANY,
> +                                             BT_LISTEN, NULL, NULL);
>
>                 if (!parent)
>                         return;
> @@ -1951,8 +1959,8 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
>          */
>         ev1 = hci_recv_event_data(hdev, HCI_EV_LE_PA_SYNC_ESTABLISHED);
>         if (ev1) {
> -               sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr, iso_match_sid,
> -                                        ev1);
> +               sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
> +                                 iso_match_sid, ev1);
>                 if (sk && !ev1->status)
>                         iso_pi(sk)->sync_handle = le16_to_cpu(ev1->handle);
>
> @@ -1962,12 +1970,12 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
>         ev2 = hci_recv_event_data(hdev, HCI_EVT_LE_BIG_INFO_ADV_REPORT);
>         if (ev2) {
>                 /* Try to get PA sync listening socket, if it exists */
> -               sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
> -                                               iso_match_pa_sync_flag, NULL);
> +               sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
> +                                 iso_match_pa_sync_flag, NULL);
>
>                 if (!sk) {
> -                       sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
> -                                                iso_match_sync_handle, ev2);
> +                       sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
> +                                         iso_match_sync_handle, ev2);
>
>                         /* If PA Sync is in process of terminating,
>                          * do not handle any more BIGInfo adv reports.
> @@ -2007,8 +2015,8 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
>                 u8 *base;
>                 struct hci_conn *hcon;
>
> -               sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
> -                                        iso_match_sync_handle_pa_report, ev3);
> +               sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
> +                                 iso_match_sync_handle_pa_report, ev3);
>                 if (!sk)
>                         goto done;
>
> @@ -2057,7 +2065,8 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
>                         hcon->le_per_adv_data_len = 0;
>                 }
>         } else {
> -               sk = iso_get_sock_listen(&hdev->bdaddr, BDADDR_ANY, NULL, NULL);
> +               sk = iso_get_sock(&hdev->bdaddr, BDADDR_ANY,
> +                                 BT_LISTEN, NULL, NULL);
>         }
>
>  done:
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index 42b4495e019e..3fcaef506bde 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -85,8 +85,9 @@  static void iso_sock_disconn(struct sock *sk);
 
 typedef bool (*iso_sock_match_t)(struct sock *sk, void *data);
 
-static struct sock *iso_get_sock_listen(bdaddr_t *src, bdaddr_t *dst,
-					iso_sock_match_t match, void *data);
+static struct sock *iso_get_sock(bdaddr_t *src, bdaddr_t *dst,
+				 unsigned char state,
+				 iso_sock_match_t match, void *data);
 
 /* ---- ISO timers ---- */
 #define ISO_CONN_TIMEOUT	(HZ * 40)
@@ -233,10 +234,11 @@  static void iso_conn_del(struct hci_conn *hcon, int err)
 		 * terminated are not processed anymore.
 		 */
 		if (test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) {
-			parent = iso_get_sock_listen(&hcon->src,
-						     &hcon->dst,
-						     iso_match_conn_sync_handle,
-						     hcon);
+			parent = iso_get_sock(&hcon->src,
+					      &hcon->dst,
+					      BT_LISTEN,
+					      iso_match_conn_sync_handle,
+					      hcon);
 
 			if (parent) {
 				set_bit(BT_SK_PA_SYNC_TERM,
@@ -584,22 +586,23 @@  static struct sock *__iso_get_sock_listen_by_sid(bdaddr_t *ba, bdaddr_t *bc,
 	return NULL;
 }
 
-/* Find socket listening:
+/* Find socket in given state:
  * source bdaddr (Unicast)
  * destination bdaddr (Broadcast only)
  * match func - pass NULL to ignore
  * match func data - pass -1 to ignore
  * Returns closest match.
  */
-static struct sock *iso_get_sock_listen(bdaddr_t *src, bdaddr_t *dst,
-					iso_sock_match_t match, void *data)
+static struct sock *iso_get_sock(bdaddr_t *src, bdaddr_t *dst,
+				 unsigned char state,
+				 iso_sock_match_t match, void *data)
 {
 	struct sock *sk = NULL, *sk1 = NULL;
 
 	read_lock(&iso_sk_list.lock);
 
 	sk_for_each(sk, &iso_sk_list.head) {
-		if (sk->sk_state != BT_LISTEN)
+		if (sk->sk_state != state)
 			continue;
 
 		/* Match Broadcast destination */
@@ -1805,32 +1808,37 @@  static void iso_conn_ready(struct iso_conn *conn)
 						 HCI_EVT_LE_BIG_SYNC_ESTABILISHED);
 
 			/* Get reference to PA sync parent socket, if it exists */
-			parent = iso_get_sock_listen(&hcon->src,
-						     &hcon->dst,
-						     iso_match_pa_sync_flag, NULL);
+			parent = iso_get_sock(&hcon->src, &hcon->dst,
+					      BT_LISTEN,
+					      iso_match_pa_sync_flag,
+					      NULL);
 			if (!parent && ev)
-				parent = iso_get_sock_listen(&hcon->src,
-							     &hcon->dst,
-							     iso_match_big, ev);
+				parent = iso_get_sock(&hcon->src,
+						      &hcon->dst,
+						      BT_LISTEN,
+						      iso_match_big, ev);
 		} else if (test_bit(HCI_CONN_PA_SYNC_FAILED, &hcon->flags)) {
 			ev2 = hci_recv_event_data(hcon->hdev,
 						  HCI_EV_LE_PA_SYNC_ESTABLISHED);
 			if (ev2)
-				parent = iso_get_sock_listen(&hcon->src,
-							     &hcon->dst,
-							     iso_match_sid, ev2);
+				parent = iso_get_sock(&hcon->src,
+						      &hcon->dst,
+						      BT_LISTEN,
+						      iso_match_sid, ev2);
 		} else if (test_bit(HCI_CONN_PA_SYNC, &hcon->flags)) {
 			ev3 = hci_recv_event_data(hcon->hdev,
 						  HCI_EVT_LE_BIG_INFO_ADV_REPORT);
 			if (ev3)
-				parent = iso_get_sock_listen(&hcon->src,
-							     &hcon->dst,
-							     iso_match_sync_handle, ev3);
+				parent = iso_get_sock(&hcon->src,
+						      &hcon->dst,
+						      BT_LISTEN,
+						      iso_match_sync_handle,
+						      ev3);
 		}
 
 		if (!parent)
-			parent = iso_get_sock_listen(&hcon->src,
-							BDADDR_ANY, NULL, NULL);
+			parent = iso_get_sock(&hcon->src, BDADDR_ANY,
+					      BT_LISTEN, NULL, NULL);
 
 		if (!parent)
 			return;
@@ -1951,8 +1959,8 @@  int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 	 */
 	ev1 = hci_recv_event_data(hdev, HCI_EV_LE_PA_SYNC_ESTABLISHED);
 	if (ev1) {
-		sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr, iso_match_sid,
-					 ev1);
+		sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
+				  iso_match_sid, ev1);
 		if (sk && !ev1->status)
 			iso_pi(sk)->sync_handle = le16_to_cpu(ev1->handle);
 
@@ -1962,12 +1970,12 @@  int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 	ev2 = hci_recv_event_data(hdev, HCI_EVT_LE_BIG_INFO_ADV_REPORT);
 	if (ev2) {
 		/* Try to get PA sync listening socket, if it exists */
-		sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
-						iso_match_pa_sync_flag, NULL);
+		sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
+				  iso_match_pa_sync_flag, NULL);
 
 		if (!sk) {
-			sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
-						 iso_match_sync_handle, ev2);
+			sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
+					  iso_match_sync_handle, ev2);
 
 			/* If PA Sync is in process of terminating,
 			 * do not handle any more BIGInfo adv reports.
@@ -2007,8 +2015,8 @@  int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 		u8 *base;
 		struct hci_conn *hcon;
 
-		sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
-					 iso_match_sync_handle_pa_report, ev3);
+		sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
+				  iso_match_sync_handle_pa_report, ev3);
 		if (!sk)
 			goto done;
 
@@ -2057,7 +2065,8 @@  int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 			hcon->le_per_adv_data_len = 0;
 		}
 	} else {
-		sk = iso_get_sock_listen(&hdev->bdaddr, BDADDR_ANY, NULL, NULL);
+		sk = iso_get_sock(&hdev->bdaddr, BDADDR_ANY,
+				  BT_LISTEN, NULL, NULL);
 	}
 
 done: