From: Roland Schober <rolandschober1968@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, marcel@holtmann.org,
Roland Schober <rolandschober1968@gmail.com>
Subject: [RFC PATCH 2/5] Bluetooth: hci_sync: Disable periodic advertising before removing a set
Date: Fri, 27 Nov 2026 09:53:57 +0100 [thread overview]
Message-ID: <20261127085401.263615-3-rolandschober1968@gmail.com> (raw)
In-Reply-To: <20261127085401.263615-1-rolandschober1968@gmail.com>
The controller answers LE Remove Advertising Set and LE Clear Advertising
Sets with Command Disallowed while periodic advertising is enabled on
a set. Only a BIG enables periodic advertising so far, and its removal
disables it first on its own.
Disable it in the removal itself, so that an instance which is made
periodic over MGMT can be removed with Remove Advertising.
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);
}
--
2.47.3
next prev parent reply other threads:[~2026-11-27 8:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 8:53 [RFC PATCH 0/5] Bluetooth: Periodic advertising and PAwR over MGMT Roland Schober
2026-11-27 8:53 ` [RFC PATCH 1/5] Bluetooth: hci: Add Periodic Advertising with Responses definitions Roland Schober
2026-11-27 8:53 ` Roland Schober [this message]
2026-11-27 8:53 ` [RFC PATCH 3/5] Bluetooth: MGMT: Add Add Periodic Advertising Parameters command Roland Schober
2026-11-27 8:53 ` [RFC PATCH 4/5] Bluetooth: MGMT: Add Add Periodic Advertising Data command Roland Schober
2026-11-27 8:54 ` [RFC PATCH 5/5] Bluetooth: MGMT: Add PAwR subevent data and response reports Roland Schober
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127085401.263615-3-rolandschober1968@gmail.com \
--to=rolandschober1968@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox