Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v2 1/3] Bluetooth: hci_conn: Fix BIG cleanup while BISes are still bound
@ 2026-11-24 11:40 Simon Mikuda
  2026-11-24 11:40 ` [PATCH v2 2/3] Bluetooth: hci_conn: Terminate a BIG before its periodic advertising Simon Mikuda
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Simon Mikuda @ 2026-11-24 11:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Simon Mikuda, Marcel Holtmann, Luiz Augusto von Dentz

When a broadcast source BIS is closed, bis_cleanup() calls
hci_le_terminate_big() unless another BIS of that BIG is in
BT_CONNECTED, BT_CONNECT or BT_OPEN. Until LE BIG Complete the BISes of
a BIG are in BT_BOUND, so one that is closed in that time does not see
the others, and the teardown is queued while they still wait to be
connected. The BIG is not marked as created yet, so it is not
terminated: terminate_big_sync() only disables the periodic advertising
and removes the advertising set the BIG is being created on.
hci_le_create_big_complete() then connects the BISes that are still
bound, in a BIG that has lost its advertising.

Steps to reproduce, with btmon running:

1. Open two ISO sockets for one BIG as BlueZ does: BT_ISO_QOS and
   BT_ISO_BASE on both, BT_DEFER_SETUP on the first, then connect()
   both, the second one non-blocking. That connect() sends LE Create
   BIG.
2. close() the second socket right after its connect().
3. Keep the first socket open for 12 s and scan for broadcast sources
   with another device in that time.

With the Zephyr controller (on an nRF54L15) and a 7.3-rc2 based kernel:

  < HCI Command: LE Create Broadcast Isochronous Group (0x08|0x0068)
  > HCI Event: Command Status (0x0f) plen 4
          Status: Success (0x00)
  < HCI Command: LE Set Periodic Advertising Enable (0x08|0x0040)
          Periodic advertising: Disabled (0x00)
  > HCI Event: Command Complete (0x0e) plen 4
          Status: Success (0x00)
  < HCI Command: LE Set Extended Advertising Enable (0x08|0x0039)
          Extended advertising: Disabled (0x00)
  > HCI Event: Command Complete (0x0e) plen 4
          Status: Success (0x00)
  < HCI Command: LE Remove Advertising Set (0x08|0x003c)
  > HCI Event: Command Complete (0x0e) plen 4
          Status: Command Disallowed (0x0c)
  > HCI Event: LE Meta Event (0x3e) plen 23
        LE Broadcast Isochronous Group Complete (0x1b)
          Status: Success (0x00)
          Connection Handle #0: 16
          Connection Handle #1: 17
  < HCI Command: LE Setup Isochronous Data Path (0x08|0x006e)
          Handle: 16
  > HCI Event: Command Complete (0x0e) plen 6
          Status: Success (0x00)

  Bluetooth: hci1: Opcode 0x203c failed: -16

The first socket becomes writable, and LE Terminate BIG is sent only
when it is closed, 11.8 s later. The scanning device did not find the
broadcast in 5 of 5 runs.

A Synaptics SYN43756 controller, with a 6.18.2 based vendor kernel,
answers LE Remove Advertising Set with Success. In 3 of 5 runs the BIS
was connected as above, and when its socket was closed the controller
answered LE Terminate BIG with a Command Status, then sent 2690 vendor
events instead of LE Terminate BIG Complete and answered no command
after that:

  < HCI Command: LE Terminate Broadcast Isochronous Group (0x08|0x006a)
          BIG Handle: 0x01
  > HCI Event: Command Status (0x0f) plen 4
          Status: Success (0x00)
  > HCI Event: Vendor (0xff) plen 244

In the other 2 runs the set was removed before LE BIG Complete, which
then never came, and the first socket was neither connected nor given
an error.

hci_le_create_big_complete() connects every BIS in BT_BOUND, so count
them as users of the BIG too. They were counted until the lookup of any
BIS of the BIG was replaced with lookups by state. With that, neither
controller gets an advertising command before the last BIS is closed,
and the scanning device found the broadcast in 5 of 5 runs with each.

Fixes: d36349ea73d8 ("Bluetooth: hci_conn: Fix running bis_cleanup for hci_conn->type PA_LINK")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
Changes in v2:
- 1/3: controller named correctly: Synaptics, not Broadcom/Infineon
- 1/3: message corrected: the early cleanup does not terminate the BIG
- all: traces are hardware captures now, with steps to reproduce
- 2/3: vendor statement and event-handler paragraph dropped
- 2/3: unused struct hci_evt_le_term_big_complete dropped
- 3/3: Realtek claim removed, it was not reproduced

 net/bluetooth/hci_conn.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0b76df1bc5fd..9fa8dab2520e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -939,6 +939,13 @@ static void bis_cleanup(struct hci_conn *conn)
 		if (bis)
 			return;
 
+		bis = hci_conn_hash_lookup_big_state(hdev,
+						     conn->iso_qos.bcast.big,
+						     BT_BOUND,
+						     HCI_ROLE_MASTER);
+		if (bis)
+			return;
+
 		hci_le_terminate_big(hdev, conn);
 	} else {
 		hci_le_big_terminate(hdev, conn);

base-commit: ffb95458a0f70dcab620eee0ecf5ef7750971b2f
-- 
2.43.0


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

end of thread, other threads:[~2026-11-24 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 11:40 [PATCH v2 1/3] Bluetooth: hci_conn: Fix BIG cleanup while BISes are still bound Simon Mikuda
2026-11-24 11:40 ` [PATCH v2 2/3] Bluetooth: hci_conn: Terminate a BIG before its periodic advertising Simon Mikuda
2026-11-24 11:40 ` [PATCH v2 3/3] Bluetooth: hci_sync: Fix closing all BISes while their BIG is created Simon Mikuda
2026-11-24 17:20 ` [PATCH v2 1/3] Bluetooth: hci_conn: Fix BIG cleanup while BISes are still bound patchwork-bot+bluetooth
2026-11-24 18:57 ` [v2,1/3] " bluez.test.bot
2026-11-24 20:40 ` [PATCH v2 1/3] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox