Linux bluetooth development
 help / color / mirror / Atom feed
From: Weihong Guan <weihong.guan@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Weihong Guan <weihong.guan@gmail.com>
Subject: [PATCH v2 0/3] Bluetooth: Advertising sets on a single-set controller
Date: Wed, 11 Nov 2026 01:09:37 +0000	[thread overview]
Message-ID: <20261111010940.728149-1-weihong.guan@gmail.com> (raw)

When the controller supports a single advertising set,
hci_add_adv_instance() gives instance 1 handle 0x00, the handle Global
Advertising uses too. The parameters, data and enable commands already
use adv->handle; these patches cover what still takes the instance
number for the handle: setting the set's random address, removing the
set, and the Advertising Set Terminated event.

Changes in v2, addressing the review at
https://sashiko.dev/#/patchset/20261023132421.1889022-1-weihong.guan%40gmail.com
(I hadn't seen it, sorry):

 - The instance is looked up, and adv->handle read, with hdev->lock held.
 - Patch 1: hci_cc_le_set_adv_set_random_addr() records the address of
   the instance numbered as the handle and leaves handle 0x00 alone, so
   instance 1's address on handle 0x00 went unrecorded. It is now
   recorded in hci_set_adv_set_random_addr_sync() when the instance and
   its handle differ.
 - Patch 2: hci_cc_le_remove_adv_set() looked up instance 0 for handle
   0x00 and left instance 1 in hdev->adv_instances. The completion can't
   tell instance 1 from instance 0, which MGMT's Set Advertising also
   removes on handle 0x00, so instance 1 is removed in
   hci_remove_ext_adv_instance_sync() once the command succeeds.
 - Patch 2: while Global Advertising is on it owns handle 0x00, and the
   controller would refuse to remove an enabled set, so only the instance
   is removed then.
 - Patch 3 (new): the Advertising Set Terminated event finds the instance
   owning handle 0x00, the one enabled on it as hci_le_ext_adv_set_enabled()
   tracks, for the connection's responder address (which SMP checks), the
   instance re-enabled after the disconnection, and the removal on an
   error.

Tested on a Raspberry Pi 5 (rpi-7.4.y, 7.4-rc2, with net/bluetooth and
include/net/bluetooth from bluetooth-next and these patches) with a
controller reporting one advertising set (LE Read Number of Supported
Advertising Sets = 1), btmgmt and btmon:

  - A non-connectable instance (a random address) starts: its address
    goes to handle 0x00 and the set advertises from it.
  - Removing it sends LE Remove Advertising Set for handle 0x00; the
    instance leaves the list (Read Advertising Features: none) and
    Advertising Removed goes out.
  - With Global Advertising on, removing instance 1 sends no LE Remove
    Advertising Set, the instance still leaves the list, and the set
    keeps advertising for Global Advertising.
  - A connectable instance from a random static address
    (force_static_address) on handle 0x00: Advertising Set Terminated
    for handle 0x00, LE Secure Connections pairing completes (DHKey
    Check both ways, so the responder address is the one advertised),
    and after the disconnection instance 1 advertises again.

Built with W=1; checkpatch clean but for the Assisted-by tag.

v1: https://lore.kernel.org/linux-bluetooth/20261023132421.1889022-1-weihong.guan@gmail.com/

Weihong Guan (3):
  Bluetooth: hci_sync: Set an advertising set's random address on its
    handle
  Bluetooth: hci_sync: Remove an advertising set by its handle
  Bluetooth: hci_event: Find the instance owning a terminated
    advertising set

 net/bluetooth/hci_event.c | 42 ++++++++++++-----
 net/bluetooth/hci_sync.c  | 94 +++++++++++++++++++++++++++++++++++----
 2 files changed, 116 insertions(+), 20 deletions(-)

-- 
2.47.3


             reply	other threads:[~2026-11-11  1:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  1:09 Weihong Guan [this message]
2026-11-11  1:09 ` [PATCH v2 1/3] Bluetooth: hci_sync: Set an advertising set's random address on its handle Weihong Guan
2026-11-11  3:38   ` Bluetooth: Advertising sets on a single-set controller bluez.test.bot
2026-11-11  1:09 ` [PATCH v2 2/3] Bluetooth: hci_sync: Remove an advertising set by its handle Weihong Guan
2026-11-11  1:09 ` [PATCH v2 3/3] Bluetooth: hci_event: Find the instance owning a terminated advertising set Weihong Guan
2026-11-11 15:47   ` Luiz Augusto von Dentz
2026-11-11 16:58     ` Weihong Guan

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=20261111010940.728149-1-weihong.guan@gmail.com \
    --to=weihong.guan@gmail.com \
    --cc=linux-bluetooth@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