public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect
@ 2025-04-14 11:50 Oleg Lyovin
  2025-04-14 11:50 ` [PATCH BlueZ 1/1] " Oleg Lyovin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Oleg Lyovin @ 2025-04-14 11:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Oleg Lyovin

Hello everyone,

While experimenting with a device acting as and A2DP Source, I have
encountered the following very rare case during connection to an
external speaker:

  1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_28_2B_B9_40_00_1B: SINK_STATE_CONNECTING -> SINK_STATE_DISCONNECTED
  1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=1
  1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/a2dp.c:channel_remove() chan 0x17ac468
  1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=0
  1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_free() 0x17c1350
  1970-01-01 00:37:50 debug bluetoothd[240]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c
  1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:dev_disconnected() Device 28:2B:B9:40:00:1B disconnected, reason 2
  1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:adapter_remove_connection() 
  1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_remove_connection() connection removed while Connect() is waiting reply
  1970-01-01 00:37:50 debug bluetoothd[240]: plugins/policy.c:disconnect_cb() reason 2
  1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 28:2B:B9:40:00:1B type 0 status 0xe
  1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
  1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_failed() status 14

Subsequent attempts to connect using bluetoothctl lead to
"br-connection-busy":
  [bluetooth]# connect 28:2B:B9:40:00:1B
  Attempting to connect to 28:2B:B9:40:00:1B
  Failed to connect: org.bluez.Error.InProgress br-connection-busy

The reason is that "connect_profiles" does the following check:
  if (dev->pending || dev->connect || dev->browse)
    return btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);

In the above scenario, "dev->pending" is not NULL. I have prepared
the RFC patch that frees it when a disconnect occurs in the
"device_remove_connection" code path. I'm not sure if this is the
correct way to solve the issue, but with this patch it can no longer
be reproduced.

Oleg Lyovin (1):
  device: Fix rare ERR_BREDR_CONN_BUSY during connect

 src/device.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.34.1


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

* [PATCH BlueZ 1/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect
  2025-04-14 11:50 [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect Oleg Lyovin
@ 2025-04-14 11:50 ` Oleg Lyovin
  2025-04-14 13:50   ` bluez.test.bot
  2025-04-24 17:04   ` bluez.test.bot
  2025-05-16  6:08 ` [RFC PATCH BlueZ 0/1] " Oleg Lyovin
  2025-06-02  7:15 ` Oleg Lyovin
  2 siblings, 2 replies; 6+ messages in thread
From: Oleg Lyovin @ 2025-04-14 11:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Oleg Lyovin

Disconnect may happen while the connection to the device is not
finished, leading to device->pending list is not being freed. As a
result, subsequent connection attempts leads to ERR_BREDR_CONN_BUSY
error, making it impossible to establish a connection.

This patch frees device->pending list in such case.
---
 src/device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/device.c b/src/device.c
index b82a905f9..a6840440c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1907,6 +1907,10 @@ void device_request_disconnect(struct btd_device *device, DBusMessage *msg)
 		g_dbus_send_message(dbus_conn, reply);
 		dbus_message_unref(device->connect);
 		device->connect = NULL;
+
+		/* Connection does not exists anymore, so free pending services */
+		g_slist_free(device->pending);
+		device->pending = NULL;
 	}
 
 	if (btd_device_is_connected(device) && msg)
-- 
2.34.1


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

* RE: device: Fix rare ERR_BREDR_CONN_BUSY during connect
  2025-04-14 11:50 ` [PATCH BlueZ 1/1] " Oleg Lyovin
@ 2025-04-14 13:50   ` bluez.test.bot
  2025-04-24 17:04   ` bluez.test.bot
  1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-04-14 13:50 UTC (permalink / raw)
  To: linux-bluetooth, ovlevin

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=953043

---Test result---

Test Summary:
CheckPatch                    PENDING   0.25 seconds
GitLint                       PENDING   0.24 seconds
BuildEll                      PASS      20.35 seconds
BluezMake                     PASS      2594.14 seconds
MakeCheck                     PASS      20.22 seconds
MakeDistcheck                 PASS      196.59 seconds
CheckValgrind                 PASS      273.29 seconds
CheckSmatch                   PASS      300.77 seconds
bluezmakeextell               PASS      128.38 seconds
IncrementalBuild              PENDING   0.30 seconds
ScanBuild                     PASS      892.02 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* RE: device: Fix rare ERR_BREDR_CONN_BUSY during connect
  2025-04-14 11:50 ` [PATCH BlueZ 1/1] " Oleg Lyovin
  2025-04-14 13:50   ` bluez.test.bot
@ 2025-04-24 17:04   ` bluez.test.bot
  1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-04-24 17:04 UTC (permalink / raw)
  To: linux-bluetooth, ovlevin

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=953043

---Test result---

Test Summary:
CheckPatch                    PENDING   0.32 seconds
GitLint                       PENDING   0.23 seconds
BuildEll                      PASS      20.85 seconds
BluezMake                     PASS      2833.99 seconds
MakeCheck                     PASS      20.23 seconds
MakeDistcheck                 PASS      202.74 seconds
CheckValgrind                 PASS      280.88 seconds
CheckSmatch                   PASS      308.50 seconds
bluezmakeextell               PASS      130.29 seconds
IncrementalBuild              PENDING   0.31 seconds
ScanBuild                     PASS      920.66 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect
  2025-04-14 11:50 [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect Oleg Lyovin
  2025-04-14 11:50 ` [PATCH BlueZ 1/1] " Oleg Lyovin
@ 2025-05-16  6:08 ` Oleg Lyovin
  2025-06-02  7:15 ` Oleg Lyovin
  2 siblings, 0 replies; 6+ messages in thread
From: Oleg Lyovin @ 2025-05-16  6:08 UTC (permalink / raw)
  To: linux-bluetooth

Gently reminder, please check the patch.

On 14.04.2025 14:50, Oleg Lyovin wrote:
> Hello everyone,
> 
> While experimenting with a device acting as and A2DP Source, I have
> encountered the following very rare case during connection to an
> external speaker:
> 
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_28_2B_B9_40_00_1B: SINK_STATE_CONNECTING -> SINK_STATE_DISCONNECTED
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=1
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/a2dp.c:channel_remove() chan 0x17ac468
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=0
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_free() 0x17c1350
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:dev_disconnected() Device 28:2B:B9:40:00:1B disconnected, reason 2
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:adapter_remove_connection() 
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_remove_connection() connection removed while Connect() is waiting reply
>   1970-01-01 00:37:50 debug bluetoothd[240]: plugins/policy.c:disconnect_cb() reason 2
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 28:2B:B9:40:00:1B type 0 status 0xe
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_failed() status 14
> 
> Subsequent attempts to connect using bluetoothctl lead to
> "br-connection-busy":
>   [bluetooth]# connect 28:2B:B9:40:00:1B
>   Attempting to connect to 28:2B:B9:40:00:1B
>   Failed to connect: org.bluez.Error.InProgress br-connection-busy
> 
> The reason is that "connect_profiles" does the following check:
>   if (dev->pending || dev->connect || dev->browse)
>     return btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);
> 
> In the above scenario, "dev->pending" is not NULL. I have prepared
> the RFC patch that frees it when a disconnect occurs in the
> "device_remove_connection" code path. I'm not sure if this is the
> correct way to solve the issue, but with this patch it can no longer
> be reproduced.
> 
> Oleg Lyovin (1):
>   device: Fix rare ERR_BREDR_CONN_BUSY during connect
> 
>  src/device.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 

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

* Re: [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect
  2025-04-14 11:50 [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect Oleg Lyovin
  2025-04-14 11:50 ` [PATCH BlueZ 1/1] " Oleg Lyovin
  2025-05-16  6:08 ` [RFC PATCH BlueZ 0/1] " Oleg Lyovin
@ 2025-06-02  7:15 ` Oleg Lyovin
  2 siblings, 0 replies; 6+ messages in thread
From: Oleg Lyovin @ 2025-06-02  7:15 UTC (permalink / raw)
  To: linux-bluetooth

Gently reminder, please check the patch.

On 14.04.2025 14:50, Oleg Lyovin wrote:
> Hello everyone,
> 
> While experimenting with a device acting as and A2DP Source, I have
> encountered the following very rare case during connection to an
> external speaker:
> 
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_28_2B_B9_40_00_1B: SINK_STATE_CONNECTING -> SINK_STATE_DISCONNECTED
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=1
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/a2dp.c:channel_remove() chan 0x17ac468
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=0
>   1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_free() 0x17c1350
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:dev_disconnected() Device 28:2B:B9:40:00:1B disconnected, reason 2
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:adapter_remove_connection() 
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_remove_connection() connection removed while Connect() is waiting reply
>   1970-01-01 00:37:50 debug bluetoothd[240]: plugins/policy.c:disconnect_cb() reason 2
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 28:2B:B9:40:00:1B type 0 status 0xe
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
>   1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_failed() status 14
> 
> Subsequent attempts to connect using bluetoothctl lead to
> "br-connection-busy":
>   [bluetooth]# connect 28:2B:B9:40:00:1B
>   Attempting to connect to 28:2B:B9:40:00:1B
>   Failed to connect: org.bluez.Error.InProgress br-connection-busy
> 
> The reason is that "connect_profiles" does the following check:
>   if (dev->pending || dev->connect || dev->browse)
>     return btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);
> 
> In the above scenario, "dev->pending" is not NULL. I have prepared
> the RFC patch that frees it when a disconnect occurs in the
> "device_remove_connection" code path. I'm not sure if this is the
> correct way to solve the issue, but with this patch it can no longer
> be reproduced.
> 
> Oleg Lyovin (1):
>   device: Fix rare ERR_BREDR_CONN_BUSY during connect
> 
>  src/device.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 

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

end of thread, other threads:[~2025-06-02  7:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 11:50 [RFC PATCH BlueZ 0/1] device: Fix rare ERR_BREDR_CONN_BUSY during connect Oleg Lyovin
2025-04-14 11:50 ` [PATCH BlueZ 1/1] " Oleg Lyovin
2025-04-14 13:50   ` bluez.test.bot
2025-04-24 17:04   ` bluez.test.bot
2025-05-16  6:08 ` [RFC PATCH BlueZ 0/1] " Oleg Lyovin
2025-06-02  7:15 ` Oleg Lyovin

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