All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bluez] bap: add PA sync monitor timeout
@ 2025-12-16  9:55 ` Ye He via B4 Relay
  0 siblings, 0 replies; 3+ messages in thread
From: Ye He @ 2025-12-16  9:55 UTC (permalink / raw)
  To: Linux Bluetooth; +Cc: Ye He

When PA sync times out, the BAP broadcast probe may remain
pending and fail to exit, even if LE scanning is triggered
again.

This adds a monitor timeout to ensure the pending probe
is properly aborted when PA sync does not complete, avoiding
stuck states.

err print from kernel:
  hci0: command 0x0000 tx timeout

Signed-off-by: Ye He <ye.he@amlogic.com>
---
 profiles/audio/bap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index cda10a643fdea8314c8717b81961546403bc2dc3..61aad856ff9156fc9048e7a215397abb4f473458 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -48,6 +48,7 @@
 #include "src/shared/bap.h"
 #include "src/shared/tmap.h"
 #include "src/shared/gmap.h"
+#include "src/shared/timeout.h"
 
 #include "btio/btio.h"
 #include "src/plugin.h"
@@ -139,6 +140,7 @@ struct bap_data {
 	struct queue *bcast_snks;
 	struct queue *server_streams;
 	GIOChannel *listen_io;
+	unsigned int listen_timer;
 	unsigned int io_id;
 	unsigned int cig_update_id;
 	bool services_ready;
@@ -174,6 +176,9 @@ static void setup_free(void *data);
 
 static void bap_data_free(struct bap_data *data)
 {
+	if (data->listen_timer)
+		timeout_remove(data->listen_timer);
+
 	if (data->listen_io) {
 		g_io_channel_shutdown(data->listen_io, TRUE, NULL);
 		g_io_channel_unref(data->listen_io);
@@ -1559,6 +1564,11 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,
 
 	DBG("BIG Info received");
 
+	if (data->listen_timer) {
+		timeout_remove(data->listen_timer);
+		data->listen_timer = 0;
+	}
+
 	bt_io_get(io, &err,
 			BT_IO_OPT_BASE, &base,
 			BT_IO_OPT_QOS, &qos,
@@ -3566,6 +3576,21 @@ static void bap_detached(struct bt_bap *bap, void *user_data)
 	bap_data_remove(data);
 }
 
+static bool pa_sync_timeout_callback(gpointer user_data)
+{
+	struct bap_data *data = user_data;
+
+	error("PA sync timeout, remove broadcast source device %s",
+				device_get_path(data->device));
+
+	data->listen_timer = 0;
+
+	/* remove device to force exit from pending bcast probe */
+	btd_adapter_remove_device(data->adapter, data->device);
+
+	return FALSE;
+}
+
 static int pa_sync(struct bap_data *data)
 {
 	GError *err = NULL;
@@ -3595,8 +3620,14 @@ static int pa_sync(struct bap_data *data)
 	if (!data->listen_io) {
 		error("%s", err->message);
 		g_error_free(err);
+		return -1;
 	}
 
+	data->listen_timer = timeout_add(
+				/* unit: 10ms */
+				bap_sink_pa_qos.bcast.sync_timeout * 10,
+				pa_sync_timeout_callback,
+				data, NULL);
 	return 0;
 }
 
@@ -3647,6 +3678,11 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 
 	DBG("PA Sync done");
 
+	if (data->listen_timer) {
+		timeout_remove(data->listen_timer);
+		data->listen_timer = 0;
+	}
+
 	g_io_channel_unref(data->listen_io);
 	g_io_channel_shutdown(data->listen_io, TRUE, NULL);
 	data->listen_io = io;
@@ -3702,7 +3738,15 @@ static void pa_and_big_sync(struct bap_setup *setup)
 	if (!bap_data->listen_io) {
 		error("%s", err->message);
 		g_error_free(err);
+		return;
 	}
+
+	bap_data->listen_timer = timeout_add(
+				/* unit: 10ms */
+				bap_sink_pa_qos.bcast.sync_timeout * 10,
+				pa_sync_timeout_callback,
+				bap_data, NULL);
+
 }
 
 static void bap_ready(struct bt_bap *bap, void *user_data)

---
base-commit: ba4978255c3cfb244a89782b30b115c2c9b58c81
change-id: 20251216-bap-pa-sync-84812e28828d

Best regards,
-- 
Ye He <ye.he@amlogic.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH bluez] bap: add PA sync monitor timeout
@ 2025-12-16  9:55 ` Ye He via B4 Relay
  0 siblings, 0 replies; 3+ messages in thread
From: Ye He via B4 Relay @ 2025-12-16  9:55 UTC (permalink / raw)
  To: Linux Bluetooth; +Cc: Ye He

From: Ye He <ye.he@amlogic.com>

When PA sync times out, the BAP broadcast probe may remain
pending and fail to exit, even if LE scanning is triggered
again.

This adds a monitor timeout to ensure the pending probe
is properly aborted when PA sync does not complete, avoiding
stuck states.

err print from kernel:
  hci0: command 0x0000 tx timeout

Signed-off-by: Ye He <ye.he@amlogic.com>
---
 profiles/audio/bap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index cda10a643fdea8314c8717b81961546403bc2dc3..61aad856ff9156fc9048e7a215397abb4f473458 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -48,6 +48,7 @@
 #include "src/shared/bap.h"
 #include "src/shared/tmap.h"
 #include "src/shared/gmap.h"
+#include "src/shared/timeout.h"
 
 #include "btio/btio.h"
 #include "src/plugin.h"
@@ -139,6 +140,7 @@ struct bap_data {
 	struct queue *bcast_snks;
 	struct queue *server_streams;
 	GIOChannel *listen_io;
+	unsigned int listen_timer;
 	unsigned int io_id;
 	unsigned int cig_update_id;
 	bool services_ready;
@@ -174,6 +176,9 @@ static void setup_free(void *data);
 
 static void bap_data_free(struct bap_data *data)
 {
+	if (data->listen_timer)
+		timeout_remove(data->listen_timer);
+
 	if (data->listen_io) {
 		g_io_channel_shutdown(data->listen_io, TRUE, NULL);
 		g_io_channel_unref(data->listen_io);
@@ -1559,6 +1564,11 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond,
 
 	DBG("BIG Info received");
 
+	if (data->listen_timer) {
+		timeout_remove(data->listen_timer);
+		data->listen_timer = 0;
+	}
+
 	bt_io_get(io, &err,
 			BT_IO_OPT_BASE, &base,
 			BT_IO_OPT_QOS, &qos,
@@ -3566,6 +3576,21 @@ static void bap_detached(struct bt_bap *bap, void *user_data)
 	bap_data_remove(data);
 }
 
+static bool pa_sync_timeout_callback(gpointer user_data)
+{
+	struct bap_data *data = user_data;
+
+	error("PA sync timeout, remove broadcast source device %s",
+				device_get_path(data->device));
+
+	data->listen_timer = 0;
+
+	/* remove device to force exit from pending bcast probe */
+	btd_adapter_remove_device(data->adapter, data->device);
+
+	return FALSE;
+}
+
 static int pa_sync(struct bap_data *data)
 {
 	GError *err = NULL;
@@ -3595,8 +3620,14 @@ static int pa_sync(struct bap_data *data)
 	if (!data->listen_io) {
 		error("%s", err->message);
 		g_error_free(err);
+		return -1;
 	}
 
+	data->listen_timer = timeout_add(
+				/* unit: 10ms */
+				bap_sink_pa_qos.bcast.sync_timeout * 10,
+				pa_sync_timeout_callback,
+				data, NULL);
 	return 0;
 }
 
@@ -3647,6 +3678,11 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 
 	DBG("PA Sync done");
 
+	if (data->listen_timer) {
+		timeout_remove(data->listen_timer);
+		data->listen_timer = 0;
+	}
+
 	g_io_channel_unref(data->listen_io);
 	g_io_channel_shutdown(data->listen_io, TRUE, NULL);
 	data->listen_io = io;
@@ -3702,7 +3738,15 @@ static void pa_and_big_sync(struct bap_setup *setup)
 	if (!bap_data->listen_io) {
 		error("%s", err->message);
 		g_error_free(err);
+		return;
 	}
+
+	bap_data->listen_timer = timeout_add(
+				/* unit: 10ms */
+				bap_sink_pa_qos.bcast.sync_timeout * 10,
+				pa_sync_timeout_callback,
+				bap_data, NULL);
+
 }
 
 static void bap_ready(struct bt_bap *bap, void *user_data)

---
base-commit: ba4978255c3cfb244a89782b30b115c2c9b58c81
change-id: 20251216-bap-pa-sync-84812e28828d

Best regards,
-- 
Ye He <ye.he@amlogic.com>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [bluez] bap: add PA sync monitor timeout
  2025-12-16  9:55 ` Ye He via B4 Relay
  (?)
@ 2025-12-16 11:01 ` bluez.test.bot
  -1 siblings, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2025-12-16 11:01 UTC (permalink / raw)
  To: linux-bluetooth, ye.he

[-- Attachment #1: Type: text/plain, Size: 1262 bytes --]

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=1033710

---Test result---

Test Summary:
CheckPatch                    PENDING   0.44 seconds
GitLint                       PENDING   0.34 seconds
BuildEll                      PASS      20.51 seconds
BluezMake                     PASS      653.41 seconds
MakeCheck                     PASS      22.26 seconds
MakeDistcheck                 PASS      243.82 seconds
CheckValgrind                 PASS      303.47 seconds
CheckSmatch                   PASS      350.59 seconds
bluezmakeextell               PASS      182.97 seconds
IncrementalBuild              PENDING   0.38 seconds
ScanBuild                     PASS      1031.24 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-16 11:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16  9:55 [PATCH bluez] bap: add PA sync monitor timeout Ye He
2025-12-16  9:55 ` Ye He via B4 Relay
2025-12-16 11:01 ` [bluez] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.