Skip to contentSkip to conversation

sink: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle

PATCH Applied Luiz Augusto von Dentz 3 participants 5 messages Nov 6, 2024 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/3 sink: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle

From: Luiz Augusto von Dentz <[email protected]>

If the stream transition to AVDTP_STATE_IDLE it means the stream has been disconnected, not the session, therefore btd_service_disconnecting_complete shall not be called otherwise it may trigger the policy plugin to disconnect AVRCP in cases like codec reconfiguration.

---
 profiles/audio/sink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
profiles/audio/sink.c +1 -2
index 77f195436032..7e02bcca1a01 100644
@@ -110,6 +110,7 @@ static void avdtp_state_callback(struct btd_device *dev,
 	switch (new_state) {
 	case AVDTP_SESSION_STATE_DISCONNECTED:
 		sink_set_state(sink, SINK_STATE_DISCONNECTED);
+		btd_service_disconnecting_complete(sink->service, 0);
 		break;
 	case AVDTP_SESSION_STATE_CONNECTING:
 		sink_set_state(sink, SINK_STATE_CONNECTING);
@@ -135,8 +136,6 @@ static void stream_state_changed(struct avdtp_stream *stream,
 
 	switch (new_state) {
 	case AVDTP_STATE_IDLE:
-		btd_service_disconnecting_complete(sink->service, 0);
-
 		if (sink->connect_id > 0) {
 			a2dp_cancel(sink->connect_id);
 			sink->connect_id = 0;
Signature · 1 line
2.47.0
author maintainer
#1 lore raw

PATCH 2/3 source: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle

From: Luiz Augusto von Dentz <[email protected]>

If the stream transition to AVDTP_STATE_IDLE it means the stream has been disconnected, not the session, therefore btd_service_disconnecting_complete shall not be called otherwise it may trigger the policy plugin to disconnect AVRCP in cases like codec reconfiguration.

---
 profiles/audio/source.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
profiles/audio/source.c +1 -2
index db777e86d542..885e218bfc7c 100644
@@ -107,6 +107,7 @@ static void avdtp_state_callback(struct btd_device *dev, struct avdtp *session,
 	switch (new_state) {
 	case AVDTP_SESSION_STATE_DISCONNECTED:
 		source_set_state(source, SOURCE_STATE_DISCONNECTED);
+		btd_service_disconnecting_complete(source->service, 0);
 		break;
 	case AVDTP_SESSION_STATE_CONNECTING:
 		source_set_state(source, SOURCE_STATE_CONNECTING);
@@ -132,8 +133,6 @@ static void stream_state_changed(struct avdtp_stream *stream,
 
 	switch (new_state) {
 	case AVDTP_STATE_IDLE:
-		btd_service_disconnecting_complete(source->service, 0);
-
 		if (source->connect_id > 0) {
 			a2dp_cancel(source->connect_id);
 			source->connect_id = 0;
Signature · 1 line
2.47.0
author maintainer
#2 lore raw

PATCH 3/3 a2dp: Don't wait to reconfigure

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

If the stream has been confirmed to be closed it should be safe to attempt to send SetConfiguration without having to wait for a period since the remote end can assume no new stream would be created it may end up disconnecting the session.

---
 profiles/audio/a2dp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
profiles/audio/a2dp.c +1 -2
index 37332abcad57..c97bd6e89deb 100644
@@ -58,7 +58,6 @@
 /* The duration that streams without users are allowed to stay in
  * STREAMING state. */
 #define SUSPEND_TIMEOUT 5
-#define RECONFIGURE_TIMEOUT 500
 
 #define AVDTP_PSM 25
 
@@ -1398,7 +1397,7 @@ static bool setup_reconfigure(struct a2dp_setup *setup)
 
 	DBG("%p", setup);
 
-	setup->id = g_timeout_add(RECONFIGURE_TIMEOUT, a2dp_reconfigure, setup);
+	setup->id = g_idle_add(a2dp_reconfigure, setup);
 
 	setup->reconfigure = FALSE;
 
Signature · 1 line
2.47.0
#3 lore raw
In reply to Luiz Augusto von Dentz

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=907010

---Test result---

Test Summary:

CheckPatch                    PASS      1.38 seconds
GitLint                       FAIL      1.21 seconds
BuildEll                      PASS      25.68 seconds
BluezMake                     PASS      1790.46 seconds
MakeCheck                     PASS      13.28 seconds
MakeDistcheck                 PASS      186.93 seconds
CheckValgrind                 PASS      258.13 seconds
CheckSmatch                   PASS      368.44 seconds
bluezmakeextell               PASS      123.71 seconds
IncrementalBuild              PASS      4795.54 seconds
ScanBuild                     WARNING   1057.78 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v1,2/3] source: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (82>80): "[BlueZ,v1,2/3] source: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle"
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
profiles/audio/a2dp.c:371:8: warning: Use of memory after it is freed

                if (!cb->resume_cb)
                     ^~~~~~~~~~~~~

1 warning generated.

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Wed, 6 Nov 2024 10:49:15 -0500 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

If the stream transition to AVDTP_STATE_IDLE it means the stream has been disconnected, not the session, therefore btd_service_disconnecting_complete shall not be called otherwise it may trigger the policy plugin to disconnect AVRCP in cases like codec reconfiguration.

[...]

Here is the summary with links:
- [BlueZ,v1,1/3] sink: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=469a75ae182a
  - [BlueZ,v1,2/3] source: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2aade568ce77
  - [BlueZ,v1,3/3] a2dp: Don't wait to reconfigure
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=aa118e965b02

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html