* [PATCH BlueZ bluez v2 0/2] bap for big sync lost
@ 2025-06-30 8:02 Yang Li via B4 Relay
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Yang Li via B4 Relay
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable Yang Li via B4 Relay
0 siblings, 2 replies; 7+ messages in thread
From: Yang Li via B4 Relay @ 2025-06-30 8:02 UTC (permalink / raw)
To: Linux Bluetooth; +Cc: Yang Li
To: Linux Bluetooth <linux-bluetooth@vger.kernel.org>
Signed-off-by: Yang Li <yang.li@amlogic.com>
Changes in v2:
- Add state check in stream_disable.
- Add type check in stream_io_disconnected.
- Link to v1: https://patch.msgid.link/20250624-bap_for_big_sync_lost-v1-1-0df90a0f55d0@amlogic.com
---
Yang Li (2):
shared/bap: Set stream to idle when I/O is disconnected
shared/bap: Add stream state check in stream_disable
src/shared/bap.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
base-commit: ae1b7f6ba805f82742bbc32ff275e268248ef9f8
change-id: 20250624-bap_for_big_sync_lost-63476c679dbb
Best regards,
--
Yang Li <yang.li@amlogic.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected
2025-06-30 8:02 [PATCH BlueZ bluez v2 0/2] bap for big sync lost Yang Li via B4 Relay
@ 2025-06-30 8:02 ` Yang Li via B4 Relay
2025-06-30 9:32 ` bap for big sync lost bluez.test.bot
2025-06-30 14:06 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Luiz Augusto von Dentz
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable Yang Li via B4 Relay
1 sibling, 2 replies; 7+ messages in thread
From: Yang Li via B4 Relay @ 2025-06-30 8:02 UTC (permalink / raw)
To: Linux Bluetooth; +Cc: Yang Li
From: Yang Li <yang.li@amlogic.com>
When BIG sync is lost, the stream status transitions from Streaming to Idle.
> HCI Event: LE Meta Event (0x3e) plen 3 #3189 [hci0] 118.870863
LE Broadcast Isochronous Group Sync Lost (0x1e)
BIG Handle: 0x00
Reason: Remote User Terminated Connection (0x13)
= bluetoothd: src/shared/bap.c:stream_io_disconnected() stream 0.. 118.871183
= bluetoothd: src/shared/bap.c:bap_bcast_set_state() stream 0xdf.. 118.871227
= bluetoothd: profiles/audio/bap.c:bap_state_bcast_sink() stream.. 118.871258
= bluetoothd: profiles/audio/bass.c:bap_state_changed() stream 0.. 118.871307
= bluetoothd: src/gatt-database.c:send_notification_to_device()... 118.871384
= bluetoothd: profiles/audio/transport.c:bap_state_changed() str.. 118.871452
= bluetoothd: profiles/audio/transport.c:transport_bap_update_li.. 118.871509
= bluetoothd: profiles/audio/transport.c:transport_update_playin.. 118.871555
= bluetoothd: profiles/audio/transport.c:transport_set_state() S.. 118.871610
= bluetoothd: src/shared/bap.c:bap_bcast_sink_detach() stream 0x.. 118.871660
= bluetoothd: profiles/audio/media.c:pac_clear() endpoint 0xdd25.. 118.871689
Fixes: https://github.com/bluez/bluez/issues/1343
Signed-off-by: Yang Li <yang.li@amlogic.com>
---
src/shared/bap.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/shared/bap.c b/src/shared/bap.c
index bccbc73ff..984ae782d 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -6584,6 +6584,11 @@ static bool stream_io_disconnected(struct io *io, void *user_data)
DBG(stream->bap, "stream %p io disconnected", stream);
+ if (stream->lpac->type == BT_BAP_BCAST_SINK) {
+ stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE);
+ return false;
+ }
+
if (stream->ep->state == BT_ASCS_ASE_STATE_RELEASING)
stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);
--
2.42.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable
2025-06-30 8:02 [PATCH BlueZ bluez v2 0/2] bap for big sync lost Yang Li via B4 Relay
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Yang Li via B4 Relay
@ 2025-06-30 8:02 ` Yang Li via B4 Relay
2025-06-30 14:00 ` Luiz Augusto von Dentz
1 sibling, 1 reply; 7+ messages in thread
From: Yang Li via B4 Relay @ 2025-06-30 8:02 UTC (permalink / raw)
To: Linux Bluetooth; +Cc: Yang Li
From: Yang Li <yang.li@amlogic.com>
Add a state check so that stream_disable() is a no-op when the stream
is not in ENABLING or STREAMING state. This prevents unexpected state
transitions or redundant operations during cleanup.
Signed-off-by: Yang Li <yang.li@amlogic.com>
---
src/shared/bap.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 984ae782d..5445ddd14 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -2134,10 +2134,14 @@ static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
/* Sink can autonomously transit to QOS while source needs to go to
* Disabling until BT_ASCS_STOP is received.
*/
- if (stream->ep->dir == BT_BAP_SINK)
+ if (stream->ep->dir == BT_BAP_SINK &&
+ (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
+ stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
- if (stream->ep->dir == BT_BAP_SOURCE)
+ if (stream->ep->dir == BT_BAP_SOURCE &&
+ (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
+ stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
return 0;
--
2.42.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: bap for big sync lost
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Yang Li via B4 Relay
@ 2025-06-30 9:32 ` bluez.test.bot
2025-06-30 14:06 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Luiz Augusto von Dentz
1 sibling, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2025-06-30 9:32 UTC (permalink / raw)
To: linux-bluetooth, yang.li
[-- Attachment #1: Type: text/plain, Size: 2365 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=977201
---Test result---
Test Summary:
CheckPatch PENDING 0.30 seconds
GitLint PENDING 0.24 seconds
BuildEll PASS 20.40 seconds
BluezMake PASS 2764.01 seconds
MakeCheck PASS 20.08 seconds
MakeDistcheck PASS 200.91 seconds
CheckValgrind PASS 278.87 seconds
CheckSmatch WARNING 307.37 seconds
bluezmakeextell PASS 129.98 seconds
IncrementalBuild PENDING 0.24 seconds
ScanBuild PASS 911.84 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable Yang Li via B4 Relay
@ 2025-06-30 14:00 ` Luiz Augusto von Dentz
2025-07-01 2:36 ` Yang Li
0 siblings, 1 reply; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-06-30 14:00 UTC (permalink / raw)
To: yang.li; +Cc: Linux Bluetooth
Hi,
On Mon, Jun 30, 2025 at 4:04 AM Yang Li via B4 Relay
<devnull+yang.li.amlogic.com@kernel.org> wrote:
>
> From: Yang Li <yang.li@amlogic.com>
>
> Add a state check so that stream_disable() is a no-op when the stream
> is not in ENABLING or STREAMING state. This prevents unexpected state
> transitions or redundant operations during cleanup.
>
> Signed-off-by: Yang Li <yang.li@amlogic.com>
> ---
> src/shared/bap.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index 984ae782d..5445ddd14 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -2134,10 +2134,14 @@ static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
> /* Sink can autonomously transit to QOS while source needs to go to
> * Disabling until BT_ASCS_STOP is received.
> */
> - if (stream->ep->dir == BT_BAP_SINK)
> + if (stream->ep->dir == BT_BAP_SINK &&
> + (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
> + stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
> stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
>
> - if (stream->ep->dir == BT_BAP_SOURCE)
> + if (stream->ep->dir == BT_BAP_SOURCE &&
> + (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
> + stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
> stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
>
> return 0;
Well we are doing:
if (!stream || stream->ep->state == BT_BAP_STREAM_STATE_QOS ||
stream->ep->state == BT_BAP_STREAM_STATE_IDLE)
return 0;
And on ep_disable we have:
switch (ep->state) {
/* Valid only if ASE_State field = 0x03 (Enabling) */
case BT_ASCS_ASE_STATE_ENABLING:
/* or 0x04 (Streaming) */
case BT_ASCS_ASE_STATE_STREAMING:
break;
default:
DBG(stream->bap, "Invalid state %s",
bt_bap_stream_statestr(ep->state));
ascs_ase_rsp_add(rsp, ep->id,
BT_ASCS_RSP_INVALID_ASE_STATE,
BT_ASCS_REASON_NONE);
return 0;
}
Perhaps on bap_ucast_disable we shall actually call ep_disale rather
than stream disable directly, that said I wonder why stream_disable
change is suggested here since you were attempting to fix broadcast
and for the likes of bt_bap_stream_disable it shall result in
bap_bcast_disable which doesn't call stream_disable:
static unsigned int bap_bcast_disable(struct bt_bap_stream *stream,
bool disable_links,
bt_bap_stream_func_t func,
void *user_data)
{
bap_stream_io_detach(stream);
stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);
return 1;
}
> --
> 2.42.0
>
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Yang Li via B4 Relay
2025-06-30 9:32 ` bap for big sync lost bluez.test.bot
@ 2025-06-30 14:06 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-06-30 14:06 UTC (permalink / raw)
To: yang.li; +Cc: Linux Bluetooth
Hi,
On Mon, Jun 30, 2025 at 4:06 AM Yang Li via B4 Relay
<devnull+yang.li.amlogic.com@kernel.org> wrote:
>
> From: Yang Li <yang.li@amlogic.com>
>
> When BIG sync is lost, the stream status transitions from Streaming to Idle.
>
> > HCI Event: LE Meta Event (0x3e) plen 3 #3189 [hci0] 118.870863
> LE Broadcast Isochronous Group Sync Lost (0x1e)
> BIG Handle: 0x00
> Reason: Remote User Terminated Connection (0x13)
> = bluetoothd: src/shared/bap.c:stream_io_disconnected() stream 0.. 118.871183
> = bluetoothd: src/shared/bap.c:bap_bcast_set_state() stream 0xdf.. 118.871227
> = bluetoothd: profiles/audio/bap.c:bap_state_bcast_sink() stream.. 118.871258
> = bluetoothd: profiles/audio/bass.c:bap_state_changed() stream 0.. 118.871307
> = bluetoothd: src/gatt-database.c:send_notification_to_device()... 118.871384
> = bluetoothd: profiles/audio/transport.c:bap_state_changed() str.. 118.871452
> = bluetoothd: profiles/audio/transport.c:transport_bap_update_li.. 118.871509
> = bluetoothd: profiles/audio/transport.c:transport_update_playin.. 118.871555
> = bluetoothd: profiles/audio/transport.c:transport_set_state() S.. 118.871610
> = bluetoothd: src/shared/bap.c:bap_bcast_sink_detach() stream 0x.. 118.871660
> = bluetoothd: profiles/audio/media.c:pac_clear() endpoint 0xdd25.. 118.871689
>
> Fixes: https://github.com/bluez/bluez/issues/1343
>
> Signed-off-by: Yang Li <yang.li@amlogic.com>
> ---
> src/shared/bap.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index bccbc73ff..984ae782d 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -6584,6 +6584,11 @@ static bool stream_io_disconnected(struct io *io, void *user_data)
>
> DBG(stream->bap, "stream %p io disconnected", stream);
>
> + if (stream->lpac->type == BT_BAP_BCAST_SINK) {
> + stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE);
> + return false;
> + }
The likes of bap_bcast_disable, which is what I assume such event
should result, does set it to BT_BAP_STREAM_STATE_CONFIG which I think
is the correct state since this is a about the BIG Sync not the PA
Sync, or perhaps we always assume the later as well since the socket
is disconnected the PA sync will be cleanup? In that case I'd add a
comment about it.
> if (stream->ep->state == BT_ASCS_ASE_STATE_RELEASING)
> stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);
>
>
> --
> 2.42.0
>
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable
2025-06-30 14:00 ` Luiz Augusto von Dentz
@ 2025-07-01 2:36 ` Yang Li
0 siblings, 0 replies; 7+ messages in thread
From: Yang Li @ 2025-07-01 2:36 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: Linux Bluetooth
Hi Luzi,
> [ EXTERNAL EMAIL ]
>
> Hi,
>
> On Mon, Jun 30, 2025 at 4:04 AM Yang Li via B4 Relay
> <devnull+yang.li.amlogic.com@kernel.org> wrote:
>> From: Yang Li <yang.li@amlogic.com>
>>
>> Add a state check so that stream_disable() is a no-op when the stream
>> is not in ENABLING or STREAMING state. This prevents unexpected state
>> transitions or redundant operations during cleanup.
>>
>> Signed-off-by: Yang Li <yang.li@amlogic.com>
>> ---
>> src/shared/bap.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/shared/bap.c b/src/shared/bap.c
>> index 984ae782d..5445ddd14 100644
>> --- a/src/shared/bap.c
>> +++ b/src/shared/bap.c
>> @@ -2134,10 +2134,14 @@ static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
>> /* Sink can autonomously transit to QOS while source needs to go to
>> * Disabling until BT_ASCS_STOP is received.
>> */
>> - if (stream->ep->dir == BT_BAP_SINK)
>> + if (stream->ep->dir == BT_BAP_SINK &&
>> + (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
>> + stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
>> stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
>>
>> - if (stream->ep->dir == BT_BAP_SOURCE)
>> + if (stream->ep->dir == BT_BAP_SOURCE &&
>> + (stream->ep->state == BT_ASCS_ASE_STATE_ENABLING ||
>> + stream->ep->state == BT_ASCS_ASE_STATE_STREAMING))
>> stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
>>
>> return 0;
> Well we are doing:
>
> if (!stream || stream->ep->state == BT_BAP_STREAM_STATE_QOS ||
> stream->ep->state == BT_BAP_STREAM_STATE_IDLE)
> return 0;
>
> And on ep_disable we have:
>
> switch (ep->state) {
> /* Valid only if ASE_State field = 0x03 (Enabling) */
> case BT_ASCS_ASE_STATE_ENABLING:
> /* or 0x04 (Streaming) */
> case BT_ASCS_ASE_STATE_STREAMING:
> break;
> default:
> DBG(stream->bap, "Invalid state %s",
> bt_bap_stream_statestr(ep->state));
> ascs_ase_rsp_add(rsp, ep->id,
> BT_ASCS_RSP_INVALID_ASE_STATE,
> BT_ASCS_REASON_NONE);
> return 0;
> }
>
> Perhaps on bap_ucast_disable we shall actually call ep_disale rather
> than stream disable directly, that said I wonder why stream_disable
> change is suggested here since you were attempting to fix broadcast
> and for the likes of bt_bap_stream_disable it shall result in
> bap_bcast_disable which doesn't call stream_disable:
>
> static unsigned int bap_bcast_disable(struct bt_bap_stream *stream,
> bool disable_links,
> bt_bap_stream_func_t func,
> void *user_data)
> {
> bap_stream_io_detach(stream);
> stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG);
>
> return 1;
> }
This patch addresses an issue where, after the CIS link is disconnected,
the ASE state incorrectly transitions from config to QoS, which can
cause the CIS client to behave unexpectedly. Detailed discussion can be
found below:
https://lore.kernel.org/all/3ac16d0a7c5569bce0b28f18bc2245bef8ab64c2.camel@iki.fi/
Alternatively, the patch can be refined as follows:
@@ -2131,14 +2131,20 @@ static uint8_t stream_disable(struct
bt_bap_stream *stream, struct iovec *rsp)
ascs_ase_rsp_success(rsp, stream->ep->id);
- /* Sink can autonomously transit to QOS while source needs to go to
- * Disabling until BT_ASCS_STOP is received.
- */
- if (stream->ep->dir == BT_BAP_SINK)
- stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
-
- if (stream->ep->dir == BT_BAP_SOURCE)
- stream_set_state(stream, BT_BAP_STREAM_STATE_DISABLING);
+ switch (stream->ep->state) {
+ case BT_ASCS_ASE_STATE_ENABLING:
+ case BT_ASCS_ASE_STATE_STREAMING:
+ if (stream->ep->dir == BT_BAP_SINK)
+ stream_set_state(stream,
BT_BAP_STREAM_STATE_QOS);
+ else if (stream->ep->dir == BT_BAP_SOURCE)
+ /* Sink can autonomously transit to QOS
while source needs to go to
+ * Disabling until BT_ASCS_STOP is received.
+ */
+ stream_set_state(stream,
BT_BAP_STREAM_STATE_DISABLING);
+ break;
+ default:
+ break;
+ }
return 0;
}
>> --
>> 2.42.0
>>
>>
>>
>
> --
> Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-01 2:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30 8:02 [PATCH BlueZ bluez v2 0/2] bap for big sync lost Yang Li via B4 Relay
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Yang Li via B4 Relay
2025-06-30 9:32 ` bap for big sync lost bluez.test.bot
2025-06-30 14:06 ` [PATCH BlueZ bluez v2 1/2] shared/bap: Set stream to idle when I/O is disconnected Luiz Augusto von Dentz
2025-06-30 8:02 ` [PATCH BlueZ bluez v2 2/2] shared/bap: Add stream state check in stream_disable Yang Li via B4 Relay
2025-06-30 14:00 ` Luiz Augusto von Dentz
2025-07-01 2:36 ` Yang Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox