Skip to content

Indicate PAST RX ready to userspace

Pauli Virtanen linux-bluetooth lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Bluetooth: hci_sync: add request wait hook for __hci_cmd_sync_skinclude/net/bluetooth/hci_sync.h net/bluetooth/hci_core.c net/bluetooth/hci_sync.c+86 -202 replies
2/2Bluetooth: ISO: Signal BIS PAST ready to userspace via POLLOUTinclude/net/bluetooth/bluetooth.h net/bluetooth/hci_sync.c net/bluetooth/iso.c+64 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Indicate PAST RX ready to userspace

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(-)
Signature · 1 line
2.56.0