From: Kamil Serwus <kserwus@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Alexej Sidorenko <alexej@sidorenko.cz>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>,
regressions@lists.linux.dev, linux-kernel@vger.kernel.org,
Kamil Serwus <kserwus@gmail.com>
Subject: [RFC PATCH 1/2] Bluetooth: hci_sync: latch broken ext scan on Command Disallowed
Date: Sat, 22 Aug 2026 16:11:14 +0200 [thread overview]
Message-ID: <20260822141115.58815-2-kserwus@gmail.com> (raw)
In-Reply-To: <20260822141115.58815-1-kserwus@gmail.com>
HCI_QUIRK_BROKEN_EXT_SCAN exists for controllers that "erroneously claim
to support extended scanning". Today every user of it has to be
recognised up front - by chip id or USB id - which means a controller is
only handled once somebody has owned one, hit the bug and sent a patch.
Recognising them by behaviour instead is both simpler and complete: a
controller that advertises the extended scan commands in its supported
commands bitmap but answers Command Disallowed is exactly the class of
device the quirk describes, and it says so itself on the first attempt.
Latch the quirk there, so every later scan uses the legacy commands.
The cost for an affected controller is one rejected scan round per power
cycle instead of a permanent stream of failures; for everyone else
nothing changes.
Signed-off-by: Kamil Serwus <kserwus@gmail.com>
---
include/net/bluetooth/hci.h | 4 ++--
net/bluetooth/hci_sync.c | 15 +++++++++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 50f0eef71..5cee010f2 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -276,8 +276,8 @@ enum {
* disabled. This is required for some Broadcom controllers which
* erroneously claim to support extended scanning.
*
- * This quirk can be set before hci_register_dev is called or
- * during the hdev->setup vendor callback.
+ * This quirk can be set before hci_register_dev is called, during the
+ * hdev->setup vendor callback, or at runtime on Command Disallowed.
*/
HCI_QUIRK_BROKEN_EXT_SCAN,
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index c8d14128c..eb711f454 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -2265,6 +2265,7 @@ static int hci_le_set_ext_scan_enable_sync(struct hci_dev *hdev, u8 val,
u8 filter_dup)
{
struct hci_cp_le_set_ext_scan_enable cp;
+ int err;
memset(&cp, 0, sizeof(cp));
cp.enable = val;
@@ -2274,8 +2275,18 @@ static int hci_le_set_ext_scan_enable_sync(struct hci_dev *hdev, u8 val,
else
cp.filter_dup = filter_dup;
- return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE,
- sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+ err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE,
+ sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+
+ /* The controller claims extended scan support but rejects it. Latch
+ * the quirk so that every later scan uses the legacy commands.
+ */
+ if (err == -EBUSY) {
+ bt_dev_warn(hdev, "extended scan rejected, using legacy scan");
+ hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_SCAN);
+ }
+
+ return err;
}
static int hci_le_set_scan_enable_sync(struct hci_dev *hdev, u8 val,
--
2.55.0
next prev parent reply other threads:[~2026-08-22 14:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 14:11 [RFC PATCH 0/2] Bluetooth: detect broken extended scan instead of guessing by chip id Kamil Serwus
2026-08-22 14:11 ` Kamil Serwus [this message]
2026-08-22 14:11 ` [RFC PATCH 2/2] Bluetooth: btrtl: drop the blanket RTL8761B extended scan quirk Kamil Serwus
2026-08-23 9:39 ` [RFC PATCH 0/2] Bluetooth: detect broken extended scan instead of guessing by chip id Thorsten Leemhuis
2026-08-23 10:27 ` Kamil Serwus
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=20260822141115.58815-2-kserwus@gmail.com \
--to=kserwus@gmail.com \
--cc=alexej@sidorenko.cz \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=regressions@lists.linux.dev \
/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®