Skip to content

Commit 0e6dfac

Browse files
iulia-tanasescuVudentz
authored andcommitted
Bluetooth: iso: Allow BIG re-sync
A Broadcast Sink might require BIG sync to be terminated and re-established multiple times, while keeping the same PA sync handle active. This can be possible if the configuration of the listening (PA sync) socket is reset once all bound BISes are established and accepted by the user space: 1. The DEFER setup flag needs to be reset on the parent socket, to allow another BIG create sync procedure to be started on socket read. 2. The BT_SK_BIG_SYNC flag needs to be cleared on the parent socket, to allow another BIG create sync command to be sent. 3. The socket state needs to transition from BT_LISTEN to BT_CONNECTED, to mark that the listening process has completed and another one can be started if needed. Signed-off-by: Iulia Tanasescu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent d90e36f commit 0e6dfac

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

net/bluetooth/iso.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,42 @@ static int iso_sock_accept(struct socket *sock, struct socket *newsock,
12811281

12821282
BT_DBG("new socket %p", ch);
12831283

1284+
/* A Broadcast Sink might require BIG sync to be terminated
1285+
* and re-established multiple times, while keeping the same
1286+
* PA sync handle active. To allow this, once all BIS
1287+
* connections have been accepted on a PA sync parent socket,
1288+
* "reset" socket state, to allow future BIG re-sync procedures.
1289+
*/
1290+
if (test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) {
1291+
/* Iterate through the list of bound BIS indices
1292+
* and clear each BIS as they are accepted by the
1293+
* user space, one by one.
1294+
*/
1295+
for (int i = 0; i < iso_pi(sk)->bc_num_bis; i++) {
1296+
if (iso_pi(sk)->bc_bis[i] > 0) {
1297+
iso_pi(sk)->bc_bis[i] = 0;
1298+
iso_pi(sk)->bc_num_bis--;
1299+
break;
1300+
}
1301+
}
1302+
1303+
if (iso_pi(sk)->bc_num_bis == 0) {
1304+
/* Once the last BIS was accepted, reset parent
1305+
* socket parameters to mark that the listening
1306+
* process for BIS connections has been completed:
1307+
*
1308+
* 1. Reset the DEFER setup flag on the parent sk.
1309+
* 2. Clear the flag marking that the BIG create
1310+
* sync command is pending.
1311+
* 3. Transition socket state from BT_LISTEN to
1312+
* BT_CONNECTED.
1313+
*/
1314+
set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
1315+
clear_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags);
1316+
sk->sk_state = BT_CONNECTED;
1317+
}
1318+
}
1319+
12841320
done:
12851321
release_sock(sk);
12861322
return err;

0 commit comments

Comments
 (0)