From: Andrei-Alexandru Bleortu <me@andrei-z.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>
Cc: <linux-bluetooth@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
George Moussalem <george.moussalem@outlook.com>
Subject: [PATCH] Bluetooth: hci_core: program a public address set during auto off
Date: Mon, 12 Oct 2026 01:08:13 +0300 [thread overview]
Message-ID: <20261011220813.1815075-1-me@andrei-z.com> (raw)
When a controller with a set_bdaddr callback registers configured, it is
powered on, mgmt adds its index, and HCI_AUTO_OFF powers it off two
seconds later unless something powers it. Within that window mgmt counts
it as not powered, so Set Public Address is accepted: it sets HCI_CONFIG
and HCI_AUTO_OFF, removes the index and queues power_on. hci_power_on()
then finds the device up with HCI_AUTO_OFF set and takes the "already
up" path: it never opens the device again, so set_bdaddr() is never
called, and HCI_CONFIG is never cleared, so the index is never added
back. The controller stays up, invisible to mgmt, with its old address.
Close the device first when HCI_CONFIG is set, keeping HCI_AUTO_OFF, so
the open procedure programs the address and the configured index is
added as after any configuration change.
Seen on the IPQ5018 Bluetooth controller of a UniFi U6 Enterprise, whose
NVM carries a placeholder address: setting the board's address with
btmgmt right after boot left hci0 up with no mgmt index (bluetoothd saw
no controller); with this change the address is programmed and the
index comes back.
Assisted-by: LLM
Signed-off-by: Andrei-Alexandru Bleortu <me@andrei-z.com>
---
Transparency note: developed with an LLM coding assistant (Claude),
which traced the bug while bringing up Bluetooth on the board below and
wrote the change and this message. Tested on a UniFi U6 Enterprise
(IPQ5018 with George Moussalem's btqcomipc v5, Linux 7.2.8, BlueZ):
btmgmt public-addr right after boot now programs the address and the
mgmt index comes back. W=1 build of net/bluetooth and drivers/bluetooth
on next-20261009 is clean.
net/bluetooth/hci_core.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3ea5ea726..f37f10936 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -908,6 +908,16 @@ static void hci_power_on(struct work_struct *work)
BT_DBG("%s", hdev->name);
+ /* A public address set while the controller was still up from its
+ * initial power on, which mgmt counts as off until the auto off, is
+ * only programmed by the open procedure: close it to open it again.
+ */
+ if (test_bit(HCI_UP, &hdev->flags) &&
+ hci_dev_test_flag(hdev, HCI_CONFIG)) {
+ hci_dev_do_close(hdev);
+ hci_dev_set_flag(hdev, HCI_AUTO_OFF);
+ }
+
if (test_bit(HCI_UP, &hdev->flags) &&
hci_dev_test_flag(hdev, HCI_MGMT) &&
hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF)) {
next reply other threads:[~2026-10-11 22:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 22:08 Andrei-Alexandru Bleortu [this message]
2026-10-12 2:00 ` Bluetooth: hci_core: program a public address set during auto off bluez.test.bot
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=20261011220813.1815075-1-me@andrei-z.com \
--to=me@andrei-z.com \
--cc=george.moussalem@outlook.com \
--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