Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] shared/asha: send STOP without waiting for a response
@ 2026-10-13  3:44 Kyle Pepper
  2026-10-13  4:49 ` bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kyle Pepper @ 2026-10-13  3:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Marcel Holtmann, Luiz Augusto von Dentz

STOP resets local state without consuming the ATT response. Use a Write
Command so an unresponsive renderer does not hold the request queue
until timeout.

Test command semantics, failure handling and peer STATUS notification.

Fixes: 9948168cca15 ("shared/asha: Don't wait for status notification on stop")
Assisted-by: OpenCode:gpt-6.1-sol
---
Submission review notes (not part of the commit message):
Local validation is for base 7428ca2df9356363079db0f48412c20cbdb9471f.
Compatibility with newer upstream tips has not been verified locally.
This topic uses the verified STOP introducing commit as its Fixes tag.
Existing N8 blocking-STOP failure evidence is retained; the new unit test
mocks setup and GATT writes, not hardware or daemon concurrency.

 .gitignore            |  1 +
 Makefile.am           |  6 +++
 src/shared/asha.c     |  5 ++-
 unit/test-asha-stop.c | 97 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 unit/test-asha-stop.c

diff --git a/.gitignore b/.gitignore
index 06b24735df..8a4195c05a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,6 +112,7 @@ unit/test-lib
 unit/test-mgmt
 unit/test-uhid
 unit/test-hfp
+unit/test-asha-stop
 unit/test-crypto
 unit/test-ecc
 unit/test-hog
diff --git a/Makefile.am b/Makefile.am
index f742458d11..6016913145 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -706,6 +706,12 @@ unit_test_avrcp_LDADD = lib/libbluetooth-internal.la \
 
 unit_tests += unit/test-hfp
 
+unit_tests += unit/test-asha-stop
+
+unit_test_asha_stop_SOURCES = unit/test-asha-stop.c
+unit_test_asha_stop_LDADD = src/libshared-glib.la \
+	lib/libbluetooth-internal.la $(GLIB_LIBS)
+
 unit_test_hfp_SOURCES = unit/test-hfp.c
 unit_test_hfp_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
diff --git a/src/shared/asha.c b/src/shared/asha.c
index 79bb29bf9a..0e6261d37d 100644
--- a/src/shared/asha.c
+++ b/src/shared/asha.c
@@ -284,8 +284,9 @@ unsigned int bt_asha_stop(struct bt_asha *asha)
 
 	asha->state = ASHA_STOPPED;
 
-	ret = asha_send_acp(asha, acp_stop_cmd, sizeof(acp_stop_cmd), NULL,
-			NULL);
+	/* State is reset below without waiting for an ATT response. */
+	ret = asha_send_acp_without_response(asha, acp_stop_cmd,
+			sizeof(acp_stop_cmd));
 	asha_set_send_status(asha, false);
 
 	/* We reset our state without waiting for a response */
diff --git a/unit/test-asha-stop.c b/unit/test-asha-stop.c
new file mode 100644
index 0000000000..5ef6d03623
--- /dev/null
+++ b/unit/test-asha-stop.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+#include <assert.h>
+
+/* Source-level mocks remain effective with link-time optimization. */
+#define bt_gatt_client_write_without_response test_write_command
+#define bt_gatt_client_write_value test_write_request
+#include "src/shared/asha.c"
+#undef bt_gatt_client_write_without_response
+#undef bt_gatt_client_write_value
+#include "src/shared/tester.h"
+
+static unsigned int commands, requests, peer_updates;
+static bool command_ok;
+
+void btd_error(uint16_t index, const char *format, ...)
+{
+}
+
+void btd_debug(uint16_t index, const char *format, ...)
+{
+}
+
+unsigned int test_write_command(struct bt_gatt_client *client, uint16_t handle,
+					bool signed_write,
+					const uint8_t *value, uint16_t length)
+{
+	assert(client && handle == 0x79 && !signed_write);
+
+	if (value[0] == 0x02) {
+		assert(length == 1);
+		commands++;
+		return command_ok;
+	}
+
+	assert(length == 2 && value[0] == 0x03 && value[1] == 0x00);
+	peer_updates++;
+	return 1;
+}
+
+unsigned int test_write_request(struct bt_gatt_client *client, uint16_t handle,
+				const uint8_t *value, uint16_t length,
+				bt_gatt_client_callback_t callback, void *data,
+				bt_gatt_client_destroy_func_t destroy)
+{
+	requests++;
+	return 1;
+}
+
+static void state_callback(int status, void *data)
+{
+	assert(false);
+}
+
+static void test_stop(const void *user_data)
+{
+	unsigned int fail;
+
+	for (fail = 0; fail < 2; fail++) {
+		struct bt_asha left = {
+			.client = (void *) 1, .acp_handle = 0x79,
+			.hisyncid = { 1 }, .state = ASHA_STARTED,
+			.state_cb = state_callback, .state_cb_data = (void *) 1,
+		};
+		struct bt_asha right = {
+			.client = (void *) 2, .acp_handle = 0x79,
+			.hisyncid = { 1 }, .right_side = true,
+			.state = ASHA_STARTED,
+		};
+
+		asha_devices = queue_new();
+		update_asha_set(&left, true);
+		update_asha_set(&right, true);
+		commands = requests = peer_updates = 0;
+		command_ok = !fail;
+		assert(bt_asha_stop(&left) == (fail ? (unsigned int) -1 : 0));
+		assert(commands == 1 && requests == 0 && peer_updates == 1);
+		assert(left.state == ASHA_STOPPED);
+		assert(right.state == ASHA_STARTED);
+		assert(!left.state_cb && !left.state_cb_data);
+
+		/* Repeated stop must not send another control command. */
+		assert(bt_asha_stop(&left) == 0);
+		assert(commands == 1 && requests == 0 && peer_updates == 1);
+		update_asha_set(&left, false);
+		update_asha_set(&right, false);
+		assert(!asha_devices);
+	}
+
+	tester_test_passed();
+}
+
+int main(int argc, char *argv[])
+{
+	tester_init(&argc, &argv);
+	tester_add("ASHA/stop/command", NULL, NULL, test_stop, NULL);
+	return tester_run();
+}

base-commit: 7428ca2df9356363079db0f48412c20cbdb9471f


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

* RE: shared/asha: send STOP without waiting for a response
  2026-10-13  3:44 [PATCH] shared/asha: send STOP without waiting for a response Kyle Pepper
@ 2026-10-13  4:49 ` bluez.test.bot
  2026-10-15  2:05 ` [PATCH] " cochcoder
  2026-10-28  8:26 ` bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-10-13  4:49 UTC (permalink / raw)
  To: linux-bluetooth, cochcoder

[-- Attachment #1: Type: text/plain, Size: 1240 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/series/1184353/

---Test result---

Test Summary:
CheckPatch                    PASS      0.39 seconds
GitLint                       PASS      0.23 seconds
BuildEll                      PASS      15.65 seconds
BluezMake                     PASS      223.77 seconds
MakeCheck                     PASS      13.57 seconds
MakeDistcheck                 PASS      114.78 seconds
CheckValgrind                 PASS      183.82 seconds
CheckSmatch                   PASS      219.50 seconds
bluezmakeextell               PASS      71.55 seconds
TestFunctional                FAIL      958.79 seconds
IncrementalBuild              PASS      225.37 seconds
ScanBuild                     PASS      823.69 seconds

Details
##############################
Test: TestFunctional - FAIL
Desc: Run test-functional
Output:
FAIL functional.test_hog::test_hog[sci-hosts18-vm2]: pytest_bluezenv.rpc.RemoteTimeoutError: Connection recv timed out


https://github.com/bluez/bluez/pull/2664

---
Regards,
Linux Bluetooth


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

* Re: [PATCH] shared/asha: send STOP without waiting for a response
  2026-10-13  3:44 [PATCH] shared/asha: send STOP without waiting for a response Kyle Pepper
  2026-10-13  4:49 ` bluez.test.bot
@ 2026-10-15  2:05 ` cochcoder
  2026-10-28  8:26 ` bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: cochcoder @ 2026-10-15  2:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Marcel Holtmann, Luiz Augusto von Dentz

Could the failed TestFunctional CI check for this patch be reran? The matching checks pass locally.

CI: https://github.com/bluez/bluez/pull/2664

On Monday, October 12th, 2026 at 11:44 PM, Kyle Pepper <cochcoder@proton.me> wrote:

> STOP resets local state without consuming the ATT response. Use a Write
> Command so an unresponsive renderer does not hold the request queue
> until timeout.
> 
> Test command semantics, failure handling and peer STATUS notification.
> 
> Fixes: 9948168cca15 ("shared/asha: Don't wait for status notification on stop")
> Assisted-by: OpenCode:gpt-6.1-sol
> ---
> Submission review notes (not part of the commit message):
> Local validation is for base 7428ca2df9356363079db0f48412c20cbdb9471f.
> Compatibility with newer upstream tips has not been verified locally.
> This topic uses the verified STOP introducing commit as its Fixes tag.
> Existing N8 blocking-STOP failure evidence is retained; the new unit test
> mocks setup and GATT writes, not hardware or daemon concurrency.
> 
>  .gitignore            |  1 +
>  Makefile.am           |  6 +++
>  src/shared/asha.c     |  5 ++-
>  unit/test-asha-stop.c | 97 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 107 insertions(+), 2 deletions(-)
>  create mode 100644 unit/test-asha-stop.c
> 
> diff --git a/.gitignore b/.gitignore
> index 06b24735df..8a4195c05a 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -112,6 +112,7 @@ unit/test-lib
>  unit/test-mgmt
>  unit/test-uhid
>  unit/test-hfp
> +unit/test-asha-stop
>  unit/test-crypto
>  unit/test-ecc
>  unit/test-hog
> diff --git a/Makefile.am b/Makefile.am
> index f742458d11..6016913145 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -706,6 +706,12 @@ unit_test_avrcp_LDADD = lib/libbluetooth-internal.la \
>  
>  unit_tests += unit/test-hfp
>  
> +unit_tests += unit/test-asha-stop
> +
> +unit_test_asha_stop_SOURCES = unit/test-asha-stop.c
> +unit_test_asha_stop_LDADD = src/libshared-glib.la \
> +	lib/libbluetooth-internal.la $(GLIB_LIBS)
> +
>  unit_test_hfp_SOURCES = unit/test-hfp.c
>  unit_test_hfp_LDADD = src/libshared-glib.la $(GLIB_LIBS)
>  
> diff --git a/src/shared/asha.c b/src/shared/asha.c
> index 79bb29bf9a..0e6261d37d 100644
> --- a/src/shared/asha.c
> +++ b/src/shared/asha.c
> @@ -284,8 +284,9 @@ unsigned int bt_asha_stop(struct bt_asha *asha)
>  
>  	asha->state = ASHA_STOPPED;
>  
> -	ret = asha_send_acp(asha, acp_stop_cmd, sizeof(acp_stop_cmd), NULL,
> -			NULL);
> +	/* State is reset below without waiting for an ATT response. */
> +	ret = asha_send_acp_without_response(asha, acp_stop_cmd,
> +			sizeof(acp_stop_cmd));
>  	asha_set_send_status(asha, false);
>  
>  	/* We reset our state without waiting for a response */
> diff --git a/unit/test-asha-stop.c b/unit/test-asha-stop.c
> new file mode 100644
> index 0000000000..5ef6d03623
> --- /dev/null
> +++ b/unit/test-asha-stop.c
> @@ -0,0 +1,97 @@
> +// SPDX-License-Identifier: LGPL-2.1-or-later
> +#include <assert.h>
> +
> +/* Source-level mocks remain effective with link-time optimization. */
> +#define bt_gatt_client_write_without_response test_write_command
> +#define bt_gatt_client_write_value test_write_request
> +#include "src/shared/asha.c"
> +#undef bt_gatt_client_write_without_response
> +#undef bt_gatt_client_write_value
> +#include "src/shared/tester.h"
> +
> +static unsigned int commands, requests, peer_updates;
> +static bool command_ok;
> +
> +void btd_error(uint16_t index, const char *format, ...)
> +{
> +}
> +
> +void btd_debug(uint16_t index, const char *format, ...)
> +{
> +}
> +
> +unsigned int test_write_command(struct bt_gatt_client *client, uint16_t handle,
> +					bool signed_write,
> +					const uint8_t *value, uint16_t length)
> +{
> +	assert(client && handle == 0x79 && !signed_write);
> +
> +	if (value[0] == 0x02) {
> +		assert(length == 1);
> +		commands++;
> +		return command_ok;
> +	}
> +
> +	assert(length == 2 && value[0] == 0x03 && value[1] == 0x00);
> +	peer_updates++;
> +	return 1;
> +}
> +
> +unsigned int test_write_request(struct bt_gatt_client *client, uint16_t handle,
> +				const uint8_t *value, uint16_t length,
> +				bt_gatt_client_callback_t callback, void *data,
> +				bt_gatt_client_destroy_func_t destroy)
> +{
> +	requests++;
> +	return 1;
> +}
> +
> +static void state_callback(int status, void *data)
> +{
> +	assert(false);
> +}
> +
> +static void test_stop(const void *user_data)
> +{
> +	unsigned int fail;
> +
> +	for (fail = 0; fail < 2; fail++) {
> +		struct bt_asha left = {
> +			.client = (void *) 1, .acp_handle = 0x79,
> +			.hisyncid = { 1 }, .state = ASHA_STARTED,
> +			.state_cb = state_callback, .state_cb_data = (void *) 1,
> +		};
> +		struct bt_asha right = {
> +			.client = (void *) 2, .acp_handle = 0x79,
> +			.hisyncid = { 1 }, .right_side = true,
> +			.state = ASHA_STARTED,
> +		};
> +
> +		asha_devices = queue_new();
> +		update_asha_set(&left, true);
> +		update_asha_set(&right, true);
> +		commands = requests = peer_updates = 0;
> +		command_ok = !fail;
> +		assert(bt_asha_stop(&left) == (fail ? (unsigned int) -1 : 0));
> +		assert(commands == 1 && requests == 0 && peer_updates == 1);
> +		assert(left.state == ASHA_STOPPED);
> +		assert(right.state == ASHA_STARTED);
> +		assert(!left.state_cb && !left.state_cb_data);
> +
> +		/* Repeated stop must not send another control command. */
> +		assert(bt_asha_stop(&left) == 0);
> +		assert(commands == 1 && requests == 0 && peer_updates == 1);
> +		update_asha_set(&left, false);
> +		update_asha_set(&right, false);
> +		assert(!asha_devices);
> +	}
> +
> +	tester_test_passed();
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +	tester_init(&argc, &argv);
> +	tester_add("ASHA/stop/command", NULL, NULL, test_stop, NULL);
> +	return tester_run();
> +}
> 
> base-commit: 7428ca2df9356363079db0f48412c20cbdb9471f
>

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

* RE: shared/asha: send STOP without waiting for a response
  2026-10-13  3:44 [PATCH] shared/asha: send STOP without waiting for a response Kyle Pepper
  2026-10-13  4:49 ` bluez.test.bot
  2026-10-15  2:05 ` [PATCH] " cochcoder
@ 2026-10-28  8:26 ` bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-10-28  8:26 UTC (permalink / raw)
  To: linux-bluetooth, cochcoder

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

This is an automated email and please do not reply to this email.

Dear Submitter,

This series was picked up by the CI more than 2 weeks ago and the pull
request created for it is still open, which means the series was never
applied to the tree.

   Series:       shared/asha: send STOP without waiting for a response
   Pull Request: https://github.com/bluez/bluez/pull/2664
   Created:      2026-10-13 04:00:12+00:00

The pull request has been closed and no further action is taken on this
series.

If the change should still be considered, it must be resent to the Linux
Bluetooth mailing list (linux-bluetooth@vger.kernel.org) so that it is
picked up again.

---
Regards,
Linux Bluetooth

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

end of thread, other threads:[~2026-10-28  8:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13  3:44 [PATCH] shared/asha: send STOP without waiting for a response Kyle Pepper
2026-10-13  4:49 ` bluez.test.bot
2026-10-15  2:05 ` [PATCH] " cochcoder
2026-10-28  8:26 ` 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