Bluetooth: hci_sync: fix mesh adv timeout units
Subsystems (2)
cover Bluetooth: hci_sync: fix mesh adv timeout units
For mesh advertisements = adv_info::mesh nonzero, the time units are milliseconds instead of seconds like normally.
This was forgotten in hci_schedule_adv_instance_sync() and hci_enable_ext_advertising_sync() which scheduled 1000x too large timeouts.
Fix that. This is the cause for the mesh-tester "Mesh - Send cancel" failures.
Since the timeout units depend on the adv type, make hdev->adv_instance_timeout to just bool indicating if timeout is active or not.
Triaged via LLM. I wrote the patches.
Pauli Virtanen (2):
Bluetooth: hci_sync: fix mesh adv timeout units
Bluetooth: make hdev->adv_instance_timeout a boolean
include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_core.c | 6 +++--- net/bluetooth/hci_sync.c | 14 ++++++++------ net/bluetooth/mgmt.c | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/2 Bluetooth: hci_sync: fix mesh adv timeout units
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.
--- net/bluetooth/hci_sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/hci_sync.c +4 -2
@@ -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
Signature · 1 line
2.55.0
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/1179822/
---Test result---
Test Summary:
CheckPatch PASS 2.14 seconds VerifyFixes PASS 0.13 seconds VerifySignedoff PASS 0.13 seconds GitLint PASS 0.69 seconds SubjectPrefix PASS 1.87 seconds BuildKernel PASS 29.74 seconds CheckAllWarning PASS 33.57 seconds CheckSparse PASS 36.52 seconds BuildKernel32 PASS 29.49 seconds CheckKernelLLVM PASS 37.48 seconds TestRunnerSetup PASS 781.61 seconds TestRunner_l2cap-tester PASS 12.58 seconds TestRunner_iso-tester PASS 10.75 seconds TestRunner_bnep-tester PASS 3.13 seconds TestRunner_mgmt-tester PASS 61.35 seconds TestRunner_rfcomm-tester PASS 4.49 seconds TestRunner_sco-tester PASS 5.60 seconds TestRunner_ioctl-tester PASS 4.66 seconds TestRunner_mesh-tester PASS 5.51 seconds TestRunner_smp-tester PASS 4.33 seconds TestRunner_userchan-tester PASS 3.17 seconds TestRunner_6lowpan-tester PASS 15.96 seconds IncrementalBuild PASS 60.62 seconds
https://github.com/bluez/bluetooth-next/pull/863
---
Regards,
Linux Bluetooth
PATCH 2/2 Bluetooth: make hdev->adv_instance_timeout a boolean
In reply to Pauli VirtanenMesh 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.
--- 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(-)
include/net/bluetooth/hci_core.h +1 -1
@@ -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;
net/bluetooth/hci_core.c +3 -3
@@ -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 ;
net/bluetooth/hci_sync.c +4 -4
@@ -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);
net/bluetooth/mgmt.c +1 -1
@@ -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); } }
Signature · 1 line
2.55.0
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Mon, 5 Oct 2026 21:13:53 +0300 you wrote:
For mesh advertisements =
adv_info::meshnonzero, the time units are milliseconds instead of seconds like normally.This was forgotten in
hci_schedule_adv_instance_sync()andhci_enable_ext_advertising_sync()which scheduled 1000x too large timeouts.[...]
Here is the summary with links:
- [1/2] Bluetooth: hci_sync: fix mesh adv timeout units
https://git.kernel.org/bluetooth/bluetooth-next/c/87a49b610708
- [2/2] Bluetooth: make hdev->adv_instance_timeout a boolean (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Mon, 5 Oct 2026 21:13:53 +0300 you wrote:
For mesh advertisements =
adv_info::meshnonzero, the time units are milliseconds instead of seconds like normally.This was forgotten in
hci_schedule_adv_instance_sync()andhci_enable_ext_advertising_sync()which scheduled 1000x too large timeouts.[...]
Here is the summary with links:
- [1/2] Bluetooth: hci_sync: fix mesh adv timeout units (no matching commit)
- [2/2] Bluetooth: make hdev->adv_instance_timeout a boolean
https://git.kernel.org/bluetooth/bluetooth-next/c/dedfbdb9bf06
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html