public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Bluetooth: hci_event: Fix connection state issues during suspend/resume
@ 2025-08-12 15:55 Ludovico de Nittis
  2025-08-12 15:55 ` [PATCH v2 1/2] Bluetooth: hci_event: Treat UNKNOWN_CONN_ID on disconnect as success Ludovico de Nittis
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ludovico de Nittis @ 2025-08-12 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ludovico de Nittis

This patch series addresses connection state synchronization issues
between the Bluetooth controller and kernel during suspend/resume cycles.

The problem seems to be visible when using devices that very quickly try
to send multiple reconnect events without waiting enough for the host
to fully resume from suspend.

Fixes the issues reported in https://github.com/bluez/bluez/issues/1226.

v2:
- Add an explicit check for hdev->suspended
- Include the btmon log in the commit message

Ludovico de Nittis (2):
  Bluetooth: hci_event: Treat UNKNOWN_CONN_ID on disconnect as success
  Bluetooth: hci_event: Mark connection as closed during suspend
    disconnect

 net/bluetooth/hci_event.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH 1/2] Bluetooth: hci_event: Treat UNKNOWN_CONN_ID on disconnect as success
@ 2025-08-12 14:10 Ludovico de Nittis
  2025-08-12 14:36 ` Bluetooth: hci_event: Fix connection state issues during suspend/resume bluez.test.bot
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovico de Nittis @ 2025-08-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ludovico de Nittis

When the host sends an HCI_OP_DISCONNECT command, the controller may
respond with the status HCI_ERROR_UNKNOWN_CONN_ID. E.g. this can happen
on resume from suspend, if the link was terminated by the remote device
before the event mask was correctly set.

Currently, the hci_cs_disconnect function treats any non-zero status
as a command failure. This can be misleading because the connection is
indeed being terminated and the controller is confirming that is has no
knowledge of that connection handle. Meaning that the initial request of
disconnecting a device should be treated as done.

With this change we allow the function to proceed, following the success
path, which correctly calls `mgmt_device_disconnected` and ensures a
consistent state.

Link: https://github.com/bluez/bluez/issues/1226
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
---
 net/bluetooth/hci_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index fe7cdd67a..6c67dfa13 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2703,7 +2703,7 @@ static void hci_cs_disconnect(struct hci_dev *hdev, u8 status)
 	if (!conn)
 		goto unlock;
 
-	if (status) {
+	if (status && status != HCI_ERROR_UNKNOWN_CONN_ID) {
 		mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
 				       conn->dst_type, status);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-19 14:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 15:55 [PATCH v2 0/2] Bluetooth: hci_event: Fix connection state issues during suspend/resume Ludovico de Nittis
2025-08-12 15:55 ` [PATCH v2 1/2] Bluetooth: hci_event: Treat UNKNOWN_CONN_ID on disconnect as success Ludovico de Nittis
2025-08-12 16:40   ` Bluetooth: hci_event: Fix connection state issues during suspend/resume bluez.test.bot
2025-08-12 15:55 ` [PATCH v2 2/2] Bluetooth: hci_event: Mark connection as closed during suspend disconnect Ludovico de Nittis
2025-08-19 14:30 ` [PATCH v2 0/2] Bluetooth: hci_event: Fix connection state issues during suspend/resume patchwork-bot+bluetooth
  -- strict thread matches above, loose matches on Subject: below --
2025-08-12 14:10 [PATCH 1/2] Bluetooth: hci_event: Treat UNKNOWN_CONN_ID on disconnect as success Ludovico de Nittis
2025-08-12 14:36 ` Bluetooth: hci_event: Fix connection state issues during suspend/resume bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox