* [PATCH 1/2] Bluetooth: hci_sync: fix mesh adv timeout units
2026-10-05 18:13 [PATCH 0/2] Bluetooth: hci_sync: fix mesh adv timeout units Pauli Virtanen
@ 2026-10-05 18:13 ` Pauli Virtanen
2026-10-06 2:18 ` bluez.test.bot
2026-10-05 18:13 ` [PATCH 2/2] Bluetooth: make hdev->adv_instance_timeout a boolean Pauli Virtanen
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Pauli Virtanen @ 2026-10-05 18:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Pauli Virtanen
Mesh adv instance timeout and duration are in milliseconds, see
mesh_send_sync, hci_add_adv_instance. hci_schedule_adv_instance_sync()
and hci_enable_ext_advertising_sync() ignore this, and scale the timeout
wrong.
Fix for mesh instances by using msecs_to_jiffies() in
hci_schedule_adv_instance_sync and fixing the scaling in
hci_enable_ext_advertising_sync.
Fixes BlueZ "Mesh - Send cancel" test failures.
Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
Assisted-by: opencode:qwen3.8-flash-next sashiko
Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
net/bluetooth/hci_sync.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 1fe11d3ef1aa..94dcbbc767e5 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1670,7 +1670,8 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance)
* scheduling it.
*/
if (adv && adv->timeout) {
- u16 duration = adv->timeout * MSEC_PER_SEC;
+ u16 duration = adv->mesh ? adv->timeout :
+ adv->timeout * MSEC_PER_SEC;
/* Time = N * 10 ms */
set->duration = cpu_to_le16(duration / 10);
@@ -2101,7 +2102,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
hdev->adv_instance_timeout = timeout;
queue_delayed_work(hdev->req_workqueue,
&hdev->adv_instance_expire,
- secs_to_jiffies(timeout));
+ adv->mesh ? msecs_to_jiffies(timeout) :
+ secs_to_jiffies(timeout));
}
/* If we're just re-scheduling the same instance again then do not
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] Bluetooth: make hdev->adv_instance_timeout a boolean
2026-10-05 18:13 [PATCH 0/2] Bluetooth: hci_sync: fix mesh adv timeout units Pauli Virtanen
2026-10-05 18:13 ` [PATCH 1/2] " Pauli Virtanen
@ 2026-10-05 18:13 ` Pauli Virtanen
2026-10-06 14:30 ` [PATCH 0/2] Bluetooth: hci_sync: fix mesh adv timeout units patchwork-bot+bluetooth
2026-10-06 15:00 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 6+ messages in thread
From: Pauli Virtanen @ 2026-10-05 18:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Pauli Virtanen
Mesh uses millisecond time units for advertisements instead of seconds
as normally. These values go to hdev->adv_instance_timeout, which then
has mixed units. hdev->adv_instance_timeout is however only used as a
true/false flag.
Make hdev->adv_instance_timeout boolean flag, to avoid possible future
problems with its mixed-units values.
Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
include/net/bluetooth/hci_core.h | 2 +-
net/bluetooth/hci_core.c | 6 +++---
net/bluetooth/hci_sync.c | 8 ++++----
net/bluetooth/mgmt.c | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f631d9484a0b..aa04dec45153 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -601,7 +601,7 @@ struct hci_dev {
struct list_head adv_instances;
unsigned int adv_instance_cnt;
__u8 cur_adv_instance;
- __u16 adv_instance_timeout;
+ bool adv_instance_timeout;
struct delayed_work adv_instance_expire;
struct idr adv_monitors_idr;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 05d1ca25f44f..416803d8d604 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1617,7 +1617,7 @@ int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance)
if (hdev->cur_adv_instance == instance) {
if (hdev->adv_instance_timeout) {
cancel_delayed_work(&hdev->adv_instance_expire);
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
}
hdev->cur_adv_instance = 0x00;
}
@@ -1647,7 +1647,7 @@ void hci_adv_instances_clear(struct hci_dev *hdev)
if (hdev->adv_instance_timeout) {
disable_delayed_work(&hdev->adv_instance_expire);
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
}
list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) {
@@ -2437,7 +2437,7 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
hdev->adv_instance_cnt = 0;
hdev->cur_adv_instance = 0x00;
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
hdev->advmon_allowlist_duration = 300;
hdev->advmon_no_filter_duration = 500;
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 94dcbbc767e5..7a07aba43262 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -468,7 +468,7 @@ static void reenable_adv(struct work_struct *work)
static void cancel_adv_timeout(struct hci_dev *hdev)
{
if (hdev->adv_instance_timeout) {
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
cancel_delayed_work(&hdev->adv_instance_expire);
}
}
@@ -568,7 +568,7 @@ static void adv_timeout_expire(struct work_struct *work)
hci_dev_lock(hdev);
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
if (hdev->cur_adv_instance == 0x00)
goto unlock;
@@ -2099,7 +2099,7 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
/* Only use work for scheduling instances with legacy advertising */
if (!ext_adv_capable(hdev)) {
- hdev->adv_instance_timeout = timeout;
+ hdev->adv_instance_timeout = true;
queue_delayed_work(hdev->req_workqueue,
&hdev->adv_instance_expire,
adv->mesh ? msecs_to_jiffies(timeout) :
@@ -5572,7 +5572,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)
if (hdev->adv_instance_timeout) {
cancel_delayed_work_sync(&hdev->adv_instance_expire);
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
}
err = hci_dev_shutdown(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index aea3482e3893..2e35b09579d3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1299,7 +1299,7 @@ void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev,
static void cancel_adv_timeout(struct hci_dev *hdev)
{
if (hdev->adv_instance_timeout) {
- hdev->adv_instance_timeout = 0;
+ hdev->adv_instance_timeout = false;
cancel_delayed_work(&hdev->adv_instance_expire);
}
}
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread