All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andrei A. Bykov" <andreiab9019@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, luiz.dentz@gmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] Bluetooth: hci_core: keep the LE feature hold until completion
Date: Sat, 21 Nov 2026 00:31:04 -0300	[thread overview]
Message-ID: <20261121033104.441146-3-andreiab9019@gmail.com> (raw)
In-Reply-To: <20261121033104.441146-1-andreiab9019@gmail.com>

LE feature discovery owns a connection hold until
le_read_features_complete() runs. If encryption finishes while the
connection is in BT_CONFIG, hci_encrypt_cfm() also drops a hold after
notifying the upper layers.

When an ATT socket has taken its own hold, the sequence is:
  feature discovery:        0 -> 1
  ATT connection:           1 -> 2
  encryption confirmation:  2 -> 1
  feature completion:       1 -> 0

The final drop arms the incoming connection's disconnect timer despite
the open ATT socket. After applying the event-waiter fix, four hardware
attempts showed the same sequence and a local disconnect approximately
four seconds later.

Restrict the drop in hci_encrypt_cfm() to non-LE links. BR/EDR connection
setup takes its configuration hold in hci_conn_complete_evt() and still
needs this drop. LE feature discovery releases its hold in its own
completion callback, including error paths. Keep the state transition
and upper-layer confirmation when encryption finishes first.

With both fixes on Linux 7.3.5, a hardware trace leaves the ATT hold at
one after feature completion and drops it to zero only when the test
explicitly closes the connection.

Fixes: a106e50be74b ("Bluetooth: HCI: Add support for LL Extended Feature Set")
Signed-off-by: Andrei A. Bykov <andreiab9019@gmail.com>
---
 include/net/bluetooth/hci_core.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4aa0b49..227830f 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -2335,7 +2335,9 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status)
 			conn->state = BT_CONNECTED;
 
 		hci_connect_cfm(conn, status);
-		hci_conn_drop(conn);
+		/* LE feature discovery releases its own hold asynchronously. */
+		if (conn->type != LE_LINK)
+			hci_conn_drop(conn);
 		return;
 	}
 

      parent reply	other threads:[~2026-11-21  3:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  3:31 [PATCH 0/2] Bluetooth: fix bonded LE peripheral reconnect completion and holds Andrei A. Bykov
2026-11-21  3:31 ` [PATCH 1/2] Bluetooth: hci_event: keep event waiters pending on unrelated replies Andrei A. Bykov
2026-11-21  3:31 ` Andrei A. Bykov [this message]

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=20261121033104.441146-3-andreiab9019@gmail.com \
    --to=andreiab9019@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.