[PATCH 0/2] Indicate PAST RX ready to userspace
From: Pauli Virtanen
Date: Sun Oct 11 2026 - 16:40:39 EST
Currently there is the following race in BASS PAST:
1. Assistant: TX Add Source
2. Delegator user: RX Add Source, listen(), TX Bcast Rcv State Nfy
3a. Assistant: RX Bcast Rcv State Nfy, Send PAST
3b. Delegator kernel (hci_sync)
- HCI_OP_LE_PAST_PARAMS queued -> Command Complete
- start waiting for HCI_EV_LE_PAST_RECEIVED
Steps 3a and 3b are not ordered, so LE PAST may arrive when kernel or
controller is not ready to receive it.
This is why test_bass_past_transport_acquire functional test is flaky.
Solve this by new userspace API: listen() socket signals POLLOUT when
kernel is ready for PAST.
Userspace shall notify PAST ready only after that, fixed in separate
BlueZ patch series. Also add related iso-tester tests + uAPI
documentation there.
This needed an extension to the HCI_REQ handling, to set POLLOUT only
after hci_sync has started waiting for the PA events. Didn't see easy
ways to simplify this, without completely changing the
hci_connect_pa_sync() -> create_pa_complete() flow.
***
An alternative uAPI here could be to have listen() block until PAST
listener is ready. The time it blocks is however not well bounded if
hci_sync queue is stuck doing something else first. We probably want to
avoid stalls in bluetoothd, so went with async notification here.
***
Testing: test_bass_past_transport_acquire: 24/24 passed at -n 6
(pre-patch baseline: 6/24 failed). In --btvirt-debug delegator 0x205c
(LE Set PAST Parameters) is before assistant 0x205b (transfer) in every
run. Pre-patch failures show the inverse (0x205b first, or in same
btvirt instant).
Not tested on real hardware, only on the emulator.
LLM was used for triage + patch review + test writing. Design and
implementation is mine.
Assisted-by: opencode:qwen3.8-flash-next opencode:gpt-6-sol
Pauli Virtanen (2):
Bluetooth: hci_sync: add request wait hook for __hci_cmd_sync_sk
Bluetooth: ISO: Signal BIS PAST ready to userspace via POLLOUT
include/net/bluetooth/bluetooth.h | 2 +
include/net/bluetooth/hci_sync.h | 10 ++-
net/bluetooth/hci_core.c | 9 ++-
net/bluetooth/hci_sync.c | 109 ++++++++++++++++++++++++------
net/bluetooth/iso.c | 45 +++++++++++-
5 files changed, 150 insertions(+), 25 deletions(-)
--
2.56.0