Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds
@ 2026-07-06 12:15 Shuai Zhang
  2026-07-06 13:11 ` [v1] " bluez.test.bot
  2026-07-06 13:21 ` [PATCH v1] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Shuai Zhang @ 2026-07-06 12:15 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, linux-arm-msm, chejiang,
	quic_chezhou, wei.deng, jinwang.li, mengshi.wu, Shuai Zhang

HCI_AUTO_OFF_TIMEOUT controls how long the kernel waits after an
adapter completes its initial setup before automatically powering
it off, in case userspace (bluetoothd) has not yet issued
MGMT_OP_SET_POWERED. This avoids leaving the controller powered
while unused.

On platforms where other services are ordered ahead of it, the
actual time at which bluetooth.service starts and issues
SET_POWERED can be delayed past this 2 second window. For example,
cloud-init-local.service can perform a network metadata probe
during early boot, delaying bluetooth.service startup by several
seconds:

    $ systemd-analyze critical-chain bluetooth.service
    bluetooth.service +594ms
     `-basic.target @9.342s
        `-sockets.target @9.335s
           `-snapd.socket @9.267s +58ms
              `-sysinit.target @9.025s
                 `-cloud-init.service @8.377s +604ms
                    `-cloud-init-local.service @7.000s +1.340s
                       `-systemd-remount-fs.service @3.257s +44ms
                          `-systemd-fsck-root.service @2.803s +394ms
                             `-systemd-journald.socket @2.223s
                                `-system.slice @1.772s
                                   `--.slice @1.772s

Once the 2 second window is exceeded, HCI_AUTO_OFF fires before
SET_POWERED is received, powering off the controller and losing
its firmware state. The SET_POWERED that bluetoothd eventually
sends then has to reopen the device, triggering an otherwise
avoidable repeat setup and firmware re-download, adding several
more seconds of delay.

Increase the timeout from 2 to 10 seconds to give userspace on
systems with slower service ordering a more realistic window to
take over, avoiding this unnecessary repeat setup, while still
bounding how long an unclaimed controller stays powered on.

Signed-off-by: Shuai Zhang <shuai.zhang@oss.qualcomm.com>
---
 include/net/bluetooth/hci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 50f0eef71..ee3f295f9 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -483,7 +483,7 @@ enum {
 #define HCI_CMD_TIMEOUT		msecs_to_jiffies(2000)	/* 2 seconds */
 #define HCI_NCMD_TIMEOUT	msecs_to_jiffies(4000)	/* 4 seconds */
 #define HCI_ACL_TX_TIMEOUT	msecs_to_jiffies(45000)	/* 45 seconds */
-#define HCI_AUTO_OFF_TIMEOUT	msecs_to_jiffies(2000)	/* 2 seconds */
+#define HCI_AUTO_OFF_TIMEOUT	msecs_to_jiffies(10000)	/* 10 seconds */
 #define HCI_ACL_CONN_TIMEOUT	msecs_to_jiffies(20000)	/* 20 seconds */
 #define HCI_LE_CONN_TIMEOUT	msecs_to_jiffies(20000)	/* 20 seconds */
 #define HCI_ISO_TX_TIMEOUT	usecs_to_jiffies(0x7fffff) /* 8388607 usecs */
-- 
2.34.1


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

* RE: [v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds
  2026-07-06 12:15 [PATCH v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds Shuai Zhang
@ 2026-07-06 13:11 ` bluez.test.bot
  2026-07-06 13:21 ` [PATCH v1] " Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-07-06 13:11 UTC (permalink / raw)
  To: linux-bluetooth, shuai.zhang

[-- Attachment #1: Type: text/plain, Size: 2389 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/project/bluetooth/list/?series=1122329

---Test result---

Test Summary:
CheckPatch                    PASS      0.59 seconds
VerifyFixes                   PASS      0.07 seconds
VerifySignedoff               PASS      0.10 seconds
GitLint                       PASS      0.21 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      28.22 seconds
CheckAllWarning               PASS      31.62 seconds
CheckSparse                   PASS      29.52 seconds
BuildKernel32                 PASS      27.54 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      514.33 seconds
TestRunner_l2cap-tester       PASS      64.26 seconds
TestRunner_iso-tester         PASS      98.47 seconds
TestRunner_bnep-tester        PASS      20.43 seconds
TestRunner_mgmt-tester        FAIL      229.99 seconds
TestRunner_rfcomm-tester      PASS      28.67 seconds
TestRunner_sco-tester         PASS      34.43 seconds
TestRunner_ioctl-tester       PASS      28.20 seconds
TestRunner_mesh-tester        FAIL      27.34 seconds
TestRunner_smp-tester         PASS      24.92 seconds
TestRunner_userchan-tester    PASS      21.42 seconds
TestRunner_6lowpan-tester     PASS      25.81 seconds
IncrementalBuild              PASS      28.01 seconds

Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.277 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    2.442 seconds
Mesh - Send cancel - 2                               Timed out    1.981 seconds


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

---
Regards,
Linux Bluetooth


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

* Re: [PATCH v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds
  2026-07-06 12:15 [PATCH v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds Shuai Zhang
  2026-07-06 13:11 ` [v1] " bluez.test.bot
@ 2026-07-06 13:21 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-07-06 13:21 UTC (permalink / raw)
  To: Shuai Zhang
  Cc: Marcel Holtmann, linux-bluetooth, linux-kernel, linux-arm-msm,
	chejiang, quic_chezhou, wei.deng, jinwang.li, mengshi.wu

Hi Shuai,

On Mon, Jul 6, 2026 at 8:15 AM Shuai Zhang <shuai.zhang@oss.qualcomm.com> wrote:
>
> HCI_AUTO_OFF_TIMEOUT controls how long the kernel waits after an
> adapter completes its initial setup before automatically powering
> it off, in case userspace (bluetoothd) has not yet issued
> MGMT_OP_SET_POWERED. This avoids leaving the controller powered
> while unused.
>
> On platforms where other services are ordered ahead of it, the
> actual time at which bluetooth.service starts and issues
> SET_POWERED can be delayed past this 2 second window. For example,
> cloud-init-local.service can perform a network metadata probe
> during early boot, delaying bluetooth.service startup by several
> seconds:
>
>     $ systemd-analyze critical-chain bluetooth.service
>     bluetooth.service +594ms
>      `-basic.target @9.342s
>         `-sockets.target @9.335s
>            `-snapd.socket @9.267s +58ms
>               `-sysinit.target @9.025s
>                  `-cloud-init.service @8.377s +604ms
>                     `-cloud-init-local.service @7.000s +1.340s
>                        `-systemd-remount-fs.service @3.257s +44ms
>                           `-systemd-fsck-root.service @2.803s +394ms
>                              `-systemd-journald.socket @2.223s
>                                 `-system.slice @1.772s
>                                    `--.slice @1.772s
>
> Once the 2 second window is exceeded, HCI_AUTO_OFF fires before
> SET_POWERED is received, powering off the controller and losing
> its firmware state. The SET_POWERED that bluetoothd eventually
> sends then has to reopen the device, triggering an otherwise
> avoidable repeat setup and firmware re-download, adding several
> more seconds of delay.
>
> Increase the timeout from 2 to 10 seconds to give userspace on
> systems with slower service ordering a more realistic window to
> take over, avoiding this unnecessary repeat setup, while still
> bounding how long an unclaimed controller stays powered on.

Ok, but we have no idea if the system has Bluetooth enabled. Making it
a 10 seconds timeout might leave Bluetooth powered unnecessarily.

> Signed-off-by: Shuai Zhang <shuai.zhang@oss.qualcomm.com>
> ---
>  include/net/bluetooth/hci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 50f0eef71..ee3f295f9 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -483,7 +483,7 @@ enum {
>  #define HCI_CMD_TIMEOUT                msecs_to_jiffies(2000)  /* 2 seconds */
>  #define HCI_NCMD_TIMEOUT       msecs_to_jiffies(4000)  /* 4 seconds */
>  #define HCI_ACL_TX_TIMEOUT     msecs_to_jiffies(45000) /* 45 seconds */
> -#define HCI_AUTO_OFF_TIMEOUT   msecs_to_jiffies(2000)  /* 2 seconds */
> +#define HCI_AUTO_OFF_TIMEOUT   msecs_to_jiffies(10000) /* 10 seconds */
>  #define HCI_ACL_CONN_TIMEOUT   msecs_to_jiffies(20000) /* 20 seconds */
>  #define HCI_LE_CONN_TIMEOUT    msecs_to_jiffies(20000) /* 20 seconds */
>  #define HCI_ISO_TX_TIMEOUT     usecs_to_jiffies(0x7fffff) /* 8388607 usecs */
> --
> 2.34.1
>


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2026-07-06 13:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 12:15 [PATCH v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds Shuai Zhang
2026-07-06 13:11 ` [v1] " bluez.test.bot
2026-07-06 13:21 ` [PATCH v1] " Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox