Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_sync: Disable PA before removing an advertising set
@ 2026-11-27 21:34 Roland Schober
  2026-11-27 22:39 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Schober @ 2026-11-27 21:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, marcel, Roland Schober

The controller answers LE Remove Advertising Set and LE Clear Advertising
Sets with Command Disallowed while periodic advertising is enabled on
a set (Core specification, Vol 4, Part E, 7.8.59 and 7.8.60). Both are
sent without disabling periodic advertising first.

A BIG is the one user of periodic advertising so far. Its own removal
disables periodic advertising, but powering the controller off does not:
hci_power_off_sync() clears the advertising sets before the connections
are terminated, so with a BIG running the command fails and the power
off with it:

  Bluetooth: hci0: Opcode 0x203d failed: -16

  # btmgmt power off
  Set Powered for hci0 failed with status 0x0a (Busy)

The BlueZ emulator accepts both commands in that state, which is why no
tester shows it. With the emulator following the specification [1] the
BAP broadcast cases of test-functional fail, as the controller is power
cycled between two cases.

Disable periodic advertising in the removal itself, for one set in
hci_remove_ext_adv_instance_sync() and for all of them before LE Clear
Advertising Sets.

[1] https://patchwork.kernel.org/project/bluetooth/patch/20261127085525.264299-8-rolandschober1968@gmail.com/

Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Roland Schober <rolandschober1968@gmail.com>
---
 net/bluetooth/hci_sync.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index ee426ffeaa03..a1c723aad55e 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -2263,6 +2263,13 @@ int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance,
 	if (err)
 		return err;
 
+	/* The controller refuses to remove an advertising set which has
+	 * periodic advertising enabled.
+	 */
+	err = hci_disable_per_advertising_sync(hdev, instance);
+	if (err)
+		return err;
+
 	if (instance) {
 		hci_dev_lock(hdev);
 
@@ -2392,6 +2399,32 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
 	return hci_start_adv_sync(hdev, instance);
 }
 
+/* The controller refuses to clear the advertising sets while one of them has
+ * periodic advertising enabled.
+ */
+static int hci_disable_per_advertising_all_sync(struct hci_dev *hdev)
+{
+	u8 instances[HCI_MAX_ADV_INSTANCES];
+	struct adv_info *adv;
+	u8 i, n = 0;
+	int err;
+
+	hci_dev_lock(hdev);
+	list_for_each_entry(adv, &hdev->adv_instances, list) {
+		if (adv->periodic_enabled && n < ARRAY_SIZE(instances))
+			instances[n++] = adv->instance;
+	}
+	hci_dev_unlock(hdev);
+
+	for (i = 0; i < n; i++) {
+		err = hci_disable_per_advertising_sync(hdev, instances[i]);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
 static int hci_clear_adv_sets_sync(struct hci_dev *hdev, struct sock *sk)
 {
 	int err;
@@ -2404,6 +2437,10 @@ static int hci_clear_adv_sets_sync(struct hci_dev *hdev, struct sock *sk)
 	if (err)
 		return err;
 
+	err = hci_disable_per_advertising_all_sync(hdev);
+	if (err)
+		return err;
+
 	return __hci_cmd_sync_status_sk(hdev, HCI_OP_LE_CLEAR_ADV_SETS,
 					0, NULL, 0, HCI_CMD_TIMEOUT, sk);
 }

base-commit: f57f78086ab54f3b3122fbaeba2c842ba7bb6d00
-- 
2.47.3


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

* RE: Bluetooth: hci_sync: Disable PA before removing an advertising set
  2026-11-27 21:34 [PATCH] Bluetooth: hci_sync: Disable PA before removing an advertising set Roland Schober
@ 2026-11-27 22:39 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-27 22:39 UTC (permalink / raw)
  To: linux-bluetooth, rolandschober1968

[-- Attachment #1: Type: text/plain, Size: 2659 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/1224867/

---Test result---

Test Summary:
CheckPatch                    FAIL      0.61 seconds
VerifyFixes                   PASS      0.10 seconds
VerifySignedoff               PASS      0.09 seconds
GitLint                       PASS      0.26 seconds
SubjectPrefix                 PASS      0.09 seconds
BuildKernel                   PASS      23.55 seconds
CheckAllWarning               PASS      27.15 seconds
CheckSparse                   PASS      29.01 seconds
BuildKernel32                 PASS      23.43 seconds
CheckKernelLLVM               PASS      24.62 seconds
TestRunnerSetup               PASS      555.22 seconds
TestRunner_l2cap-tester       PASS      15.19 seconds
TestRunner_iso-tester         PASS      11.34 seconds
TestRunner_bnep-tester        PASS      2.88 seconds
TestRunner_mgmt-tester        PASS      85.05 seconds
TestRunner_rfcomm-tester      PASS      4.10 seconds
TestRunner_sco-tester         PASS      5.17 seconds
TestRunner_ioctl-tester       PASS      4.27 seconds
TestRunner_mesh-tester        PASS      4.16 seconds
TestRunner_smp-tester         PASS      4.02 seconds
TestRunner_userchan-tester    PASS      2.95 seconds
TestRunner_6lowpan-tester     PASS      4.11 seconds
IncrementalBuild              PASS      23.19 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
Bluetooth: hci_sync: Disable PA before removing an advertising set
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#141: 
[1] https://patchwork.kernel.org/project/bluetooth/patch/20261127085525.264299-8-rolandschober1968@gmail.com/

WARNING: Non-standard signature: Assisted-by:
#144: 
Assisted-by: Claude:claude-fable-5-2

ERROR: Unrecognized email address: 'Claude:claude-fable-5-2'
#144: 
Assisted-by: Claude:claude-fable-5-2

total: 1 errors, 2 warnings, 0 checks, 55 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/home/runner/work/bluetooth-next/bluetooth-next/src/patch/15031776.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.




https://github.com/bluez/bluetooth-next/pull/1249

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-11-27 22:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 21:34 [PATCH] Bluetooth: hci_sync: Disable PA before removing an advertising set Roland Schober
2026-11-27 22:39 ` 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