mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pauli Virtanen <pav@iki.fi>
To: linux-bluetooth@vger.kernel.org
Cc: Pauli Virtanen <pav@iki.fi>,
	marcel@holtmann.org, luiz.dentz@gmail.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] Indicate PAST RX ready to userspace
Date: Sun, 11 Oct 2026 23:39:53 +0300	[thread overview]
Message-ID: <cover.1791750397.git.pav@iki.fi> (raw)

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


             reply	other threads:[~2026-10-11 20:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 20:39 Pauli Virtanen [this message]
2026-10-11 20:39 ` [PATCH 1/2] Bluetooth: hci_sync: add request wait hook for __hci_cmd_sync_sk Pauli Virtanen
2026-10-11 22:04   ` Pauli Virtanen
2026-10-11 20:39 ` [PATCH 2/2] Bluetooth: ISO: Signal BIS PAST ready to userspace via POLLOUT Pauli Virtanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1791750397.git.pav@iki.fi \
    --to=pav@iki.fi \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®