Re: [PATCH v1] Bluetooth: Increase HCI_AUTO_OFF_TIMEOUT to 10 seconds

From: Luiz Augusto von Dentz

Date: Mon Jul 06 2026 - 09:33:28 EST


Hi Shuai,

On Mon, Jul 6, 2026 at 8:15 AM Shuai Zhang <shuai.zhang@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxx>
> ---
> 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