public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: StefanCondorache <condorachest@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, StefanCondorache <condorachest@gmail.com>
Subject: [PATCH 2/2] adapter: remove connected device from kernel accept list on connect
Date: Sat, 18 Apr 2026 19:26:52 +0300	[thread overview]
Message-ID: <20260418162652.287637-2-condorachest@gmail.com> (raw)
In-Reply-To: <20260418162652.287637-1-condorachest@gmail.com>

When DisableDiscoveryOnConnect is enabled, remove the device from the
kernel accept list once it has successfully connected. This prevents
the kernel from continuing background LE scanning for a device that
is already connected, eliminating antenna contention on combo chips
with shared Wi-Fi/Bluetooth radios.

The device is re-added to the accept list upon disconnection to
restore auto-reconnect capability.

Signed-off-by: StefanCondorache <condorachest@gmail.com>
---
 src/adapter.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 4a18adfe0..48f0f2cc4 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9533,6 +9533,7 @@ static void disconnected_callback(uint16_t index, uint16_t length,
 {
 	const struct mgmt_ev_device_disconnected *ev = param;
 	struct btd_adapter *adapter = user_data;
+	struct btd_device *device = NULL;
 	uint8_t reason;
 
 	if (length < sizeof(struct mgmt_addr_info)) {
@@ -9546,7 +9547,18 @@ static void disconnected_callback(uint16_t index, uint16_t length,
 	else
 		reason = ev->reason;
 
+	if (btd_opts.disable_discovery_on_connect)
+		device = btd_adapter_find_device(adapter, &ev->addr.bdaddr,
+							ev->addr.type);
+
 	dev_disconnected(adapter, &ev->addr, reason);
+
+	/*
+	 * Re-add the device to the kernel accept list after disconnection
+	 * so it can auto-reconnect in the future.
+	 */
+	if (btd_opts.disable_discovery_on_connect && device)
+		adapter_auto_connect_add(adapter, device);
 }
 
 static void connected_callback(uint16_t index, uint16_t length,
@@ -9593,6 +9605,15 @@ static void connected_callback(uint16_t index, uint16_t length,
 	adapter_add_connection(adapter, device, ev->addr.type,
 					le32_to_cpu(ev->flags));
 
+	/*
+	 * If DisableDiscoveryOnConnect is enabled, remove the device from
+	 * the kernel accept list once it has connected. This stops the kernel
+	 * from continuing to scan for a device that is already connected,
+	 * eliminating antenna contention on combo chips.
+	 */
+	if (btd_opts.disable_discovery_on_connect)
+		adapter_auto_connect_remove(adapter, device);
+
 	name_known = device_name_known(device);
 
 	if (eir_data.name && (eir_data.name_complete || !name_known)) {
-- 
2.53.0


  reply	other threads:[~2026-04-18 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-18 16:26 [PATCH 1/2] adapter: add DisableDiscoveryOnConnect option for combo chip coexistence StefanCondorache
2026-04-18 16:26 ` StefanCondorache [this message]
2026-04-18 17:57 ` [1/2] " 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=20260418162652.287637-2-condorachest@gmail.com \
    --to=condorachest@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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