Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures
@ 2026-07-24  8:54 zhangchen200426
  2026-07-24  9:23 ` Paul Menzel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: zhangchen200426 @ 2026-07-24  8:54 UTC (permalink / raw)
  To: luiz.von.dentz, yang.li, tim.bird, naga.akella, gustavoars, pav
  Cc: zhangchen01, linux-bluetooth

From: Chen Zhang <zhangchen01@kylinos.cn>

Some speakers do not actively initiate disconnection when power off. As
a result, the center can only wait for a timeout to disconnect, with the
default timeout being 20s. In certain scenarios, this can significantly
impact user experience. For example, if a speaker is playing music and
is then turned off, it takes 20s before the music starts playing from
the center.

Define HCI_Write_Link_Supervision_Timeout command, event structure, and
corresponding event handler function, set the timeout to 5s after ACL
link is established.

Signed-off-by: Chen Zhang <zhangchen01@kylinos.cn>
---
 include/net/bluetooth/hci.h      | 10 +++++++
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_event.c        | 50 ++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 50f0eef71fb1..18a5a17eb218 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1239,6 +1239,16 @@ struct hci_cp_host_buffer_size {
 	__le16   sco_max_pkt;
 } __packed;
 
+#define HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT	0x0c37
+struct hci_cp_write_link_supervision_timeout {
+	__le16	 handle;
+	__le16	 timeout;
+} __packed;
+struct hci_rp_write_link_supervision_timeout {
+	__u8	 status;
+	__le16	 handle;
+} __packed;
+
 #define HCI_OP_READ_NUM_SUPPORTED_IAC	0x0c38
 struct hci_rp_read_num_supported_iac {
 	__u8	status;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e7133ff87fbf..866903a9b5c8 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -702,6 +702,7 @@ struct hci_conn {
 	__u8		le_features[248];
 	__u16		pkt_type;
 	__u16		link_policy;
+	__u16		link_supervision_timeout;
 	__u8		key_type;
 	__u8		auth_type;
 	__u8		sec_level;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 741d658e9630..653184d0dfc7 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -606,6 +606,44 @@ static u8 hci_cc_write_voice_setting(struct hci_dev *hdev, void *data,
 	return rp->status;
 }
 
+static u8 hci_cc_write_link_supervision_timeout(struct hci_dev *hdev, void *data,
+						struct sk_buff *skb)
+{
+	struct hci_ev_status *rp = data;
+	struct hci_cp_write_link_supervision_timeout *sent;
+	struct hci_conn *conn;
+	u16 handle;
+	u8 status = rp->status;
+
+	bt_dev_dbg(hdev, "status 0x%2.2x", status);
+
+	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT);
+	if (!sent)
+		return status;
+
+	handle = le16_to_cpu(sent->handle);
+
+	hci_dev_lock(hdev);
+
+	conn = hci_conn_hash_lookup_handle(hdev, handle);
+	if (!conn) {
+		status = 0xFF;
+		goto done;
+	}
+
+	if (!status) {
+		conn->link_supervision_timeout = __le16_to_cpu(sent->timeout);
+		bt_dev_dbg(hdev, "handle 0x%4.4x timeout set to 0x%4.4x (%u ms)",
+			   handle, conn->link_supervision_timeout,
+			   conn->link_supervision_timeout * 5 / 8);
+	}
+
+done:
+	hci_dev_unlock(hdev);
+
+	return status;
+}
+
 static u8 hci_cc_read_num_supported_iac(struct hci_dev *hdev, void *data,
 					struct sk_buff *skb)
 {
@@ -3240,6 +3278,16 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
 			hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
 				     &cp);
 		}
+
+		if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) {
+			struct hci_cp_write_link_supervision_timeout cp;
+
+			cp.handle = ev->handle;
+			cp.timeout = 0x1F40;	/* 8000 * 0.625ms = 5000ms */
+			hci_send_cmd(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT,
+				     sizeof(cp), &cp);
+		}
+
 	}
 
 	if (conn->type == ACL_LINK)
@@ -4097,6 +4145,8 @@ static const struct hci_cc {
 	HCI_CC_STATUS(HCI_OP_WRITE_CLASS_OF_DEV, hci_cc_write_class_of_dev),
 	HCI_CC(HCI_OP_READ_VOICE_SETTING, hci_cc_read_voice_setting,
 	       sizeof(struct hci_rp_read_voice_setting)),
+	HCI_CC(HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT, hci_cc_write_link_supervision_timeout,
+	       sizeof(struct hci_rp_write_link_supervision_timeout)),
 	HCI_CC_STATUS(HCI_OP_WRITE_VOICE_SETTING, hci_cc_write_voice_setting),
 	HCI_CC(HCI_OP_READ_NUM_SUPPORTED_IAC, hci_cc_read_num_supported_iac,
 	       sizeof(struct hci_rp_read_num_supported_iac)),
-- 
2.25.1


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

* Re: [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures
  2026-07-24  8:54 [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures zhangchen200426
@ 2026-07-24  9:23 ` Paul Menzel
  2026-07-25  9:52   ` zhangchen200426
  2026-07-24  9:48 ` [v2] " bluez.test.bot
  2026-08-07 21:58 ` [PATCH v2] " kernel test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Paul Menzel @ 2026-07-24  9:23 UTC (permalink / raw)
  To: Chen Zhang
  Cc: luiz.von.dentz, yang.li, tim.bird, naga.akella, gustavoars, pav,
	zhangchen01, linux-bluetooth

Dear Chen,


Thank you for your patch.

Am 24.07.26 um 10:54 schrieb zhangchen200426@163.com:
> From: Chen Zhang <zhangchen01@kylinos.cn>
> 
> Some speakers do not actively initiate disconnection when power off. As

… powering …

> a result, the center can only wait for a timeout to disconnect, with the

What does “the center” refer to?

> default timeout being 20s. In certain scenarios, this can significantly
> impact user experience. For example, if a speaker is playing music and
> is then turned off, it takes 20s before the music starts playing from
> the center.
> 
> Define HCI_Write_Link_Supervision_Timeout command, event structure, and
> corresponding event handler function, set the timeout to 5s after ACL
> link is established.

Why five seconds and not less? How do Chromium OS or Android do it?

Please also document one test setup up, where you could reproduce it.

> Signed-off-by: Chen Zhang <zhangchen01@kylinos.cn>
> ---
>   include/net/bluetooth/hci.h      | 10 +++++++
>   include/net/bluetooth/hci_core.h |  1 +
>   net/bluetooth/hci_event.c        | 50 ++++++++++++++++++++++++++++++++
>   3 files changed, 61 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 50f0eef71fb1..18a5a17eb218 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -1239,6 +1239,16 @@ struct hci_cp_host_buffer_size {
>   	__le16   sco_max_pkt;
>   } __packed;
>   
> +#define HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT	0x0c37
> +struct hci_cp_write_link_supervision_timeout {
> +	__le16	 handle;
> +	__le16	 timeout;

How about appending the unit for the timeout: timeout_s.

> +} __packed;
> +struct hci_rp_write_link_supervision_timeout {
> +	__u8	 status;
> +	__le16	 handle;
> +} __packed;
> +
>   #define HCI_OP_READ_NUM_SUPPORTED_IAC	0x0c38
>   struct hci_rp_read_num_supported_iac {
>   	__u8	status;
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index e7133ff87fbf..866903a9b5c8 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -702,6 +702,7 @@ struct hci_conn {
>   	__u8		le_features[248];
>   	__u16		pkt_type;
>   	__u16		link_policy;
> +	__u16		link_supervision_timeout;

Ditto.

>   	__u8		key_type;
>   	__u8		auth_type;
>   	__u8		sec_level;
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 741d658e9630..653184d0dfc7 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -606,6 +606,44 @@ static u8 hci_cc_write_voice_setting(struct hci_dev *hdev, void *data,
>   	return rp->status;
>   }
>   
> +static u8 hci_cc_write_link_supervision_timeout(struct hci_dev *hdev, void *data,
> +						struct sk_buff *skb)
> +{
> +	struct hci_ev_status *rp = data;
> +	struct hci_cp_write_link_supervision_timeout *sent;
> +	struct hci_conn *conn;
> +	u16 handle;
> +	u8 status = rp->status;
> +
> +	bt_dev_dbg(hdev, "status 0x%2.2x", status);
> +
> +	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT);
> +	if (!sent)
> +		return status;
> +
> +	handle = le16_to_cpu(sent->handle);
> +
> +	hci_dev_lock(hdev);
> +
> +	conn = hci_conn_hash_lookup_handle(hdev, handle);
> +	if (!conn) {
> +		status = 0xFF;
> +		goto done;
> +	}
> +
> +	if (!status) {
> +		conn->link_supervision_timeout = __le16_to_cpu(sent->timeout);
> +		bt_dev_dbg(hdev, "handle 0x%4.4x timeout set to 0x%4.4x (%u ms)",
> +			   handle, conn->link_supervision_timeout,
> +			   conn->link_supervision_timeout * 5 / 8);
> +	}
> +
> +done:
> +	hci_dev_unlock(hdev);
> +
> +	return status;
> +}
> +
>   static u8 hci_cc_read_num_supported_iac(struct hci_dev *hdev, void *data,
>   					struct sk_buff *skb)
>   {
> @@ -3240,6 +3278,16 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
>   			hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
>   				     &cp);
>   		}
> +
> +		if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) {
> +			struct hci_cp_write_link_supervision_timeout cp;
> +
> +			cp.handle = ev->handle;
> +			cp.timeout = 0x1F40;	/* 8000 * 0.625ms = 5000ms */
> +			hci_send_cmd(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT,
> +				     sizeof(cp), &cp);
> +		}
> +
>   	}
>   
>   	if (conn->type == ACL_LINK)
> @@ -4097,6 +4145,8 @@ static const struct hci_cc {
>   	HCI_CC_STATUS(HCI_OP_WRITE_CLASS_OF_DEV, hci_cc_write_class_of_dev),
>   	HCI_CC(HCI_OP_READ_VOICE_SETTING, hci_cc_read_voice_setting,
>   	       sizeof(struct hci_rp_read_voice_setting)),
> +	HCI_CC(HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT, hci_cc_write_link_supervision_timeout,
> +	       sizeof(struct hci_rp_write_link_supervision_timeout)),
>   	HCI_CC_STATUS(HCI_OP_WRITE_VOICE_SETTING, hci_cc_write_voice_setting),
>   	HCI_CC(HCI_OP_READ_NUM_SUPPORTED_IAC, hci_cc_read_num_supported_iac,
>   	       sizeof(struct hci_rp_read_num_supported_iac)),


Kind regards,

Paul

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

* RE: [v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures
  2026-07-24  8:54 [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures zhangchen200426
  2026-07-24  9:23 ` Paul Menzel
@ 2026-07-24  9:48 ` bluez.test.bot
  2026-08-07 21:58 ` [PATCH v2] " kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-07-24  9:48 UTC (permalink / raw)
  To: linux-bluetooth, zhangchen200426

[-- Attachment #1: Type: text/plain, Size: 2692 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=1133794

---Test result---

Test Summary:
CheckPatch                    PASS      0.99 seconds
VerifyFixes                   PASS      0.10 seconds
VerifySignedoff               PASS      0.09 seconds
GitLint                       FAIL      0.60 seconds
SubjectPrefix                 PASS      0.09 seconds
BuildKernel                   PASS      25.25 seconds
CheckAllWarning               PASS      27.95 seconds
CheckSparse                   PASS      26.43 seconds
BuildKernel32                 PASS      24.33 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      459.76 seconds
TestRunner_l2cap-tester       PASS      63.85 seconds
TestRunner_iso-tester         PASS      87.04 seconds
TestRunner_bnep-tester        PASS      18.93 seconds
TestRunner_mgmt-tester        FAIL      223.71 seconds
TestRunner_rfcomm-tester      PASS      25.73 seconds
TestRunner_sco-tester         PASS      31.72 seconds
TestRunner_ioctl-tester       PASS      26.33 seconds
TestRunner_mesh-tester        FAIL      25.90 seconds
TestRunner_smp-tester         PASS      23.82 seconds
TestRunner_userchan-tester    PASS      20.64 seconds
TestRunner_6lowpan-tester     PASS      24.26 seconds
IncrementalBuild              PASS      24.03 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures

1: T1 Title exceeds max length (90>80): "[v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures"
##############################
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.264 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.260 seconds
Mesh - Send cancel - 2                               Timed out    1.986 seconds


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

---
Regards,
Linux Bluetooth


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

* Re: [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures
  2026-07-24  9:23 ` Paul Menzel
@ 2026-07-25  9:52   ` zhangchen200426
  0 siblings, 0 replies; 5+ messages in thread
From: zhangchen200426 @ 2026-07-25  9:52 UTC (permalink / raw)
  To: pmenzel
  Cc: gustavoars, linux-bluetooth, luiz.von.dentz, naga.akella, pav,
	tim.bird, yang.li, zhangchen01, zhangchen200426

Dear Paul

Thank you for providing the comments.

On Fri, 24 Jul 2026 11:23:26 +0200, Paul Menzel <pmenzel@molgen.mpg.de> wrote:
>
> Dear Chen,
>
>
> Thank you for your patch.
>
> Am 24.07.26 um 10:54 schrieb zhangchen200426@163.com:
> > From: Chen Zhang <zhangchen01@kylinos.cn>
> > 
> > Some speakers do not actively initiate disconnection when power off. As
>
> … powering …
>
> > a result, the center can only wait for a timeout to disconnect, with the
>
> What does “the center” refer to?
In the scenario where a phone actively connects to a speaker, the phone acts as the central device and the speaker is the peripheral device. You can also say the phone is the master and the speaker is the slave. The center refers to the central device.
>
> > default timeout being 20s. In certain scenarios, this can significantly
> > impact user experience. For example, if a speaker is playing music and
> > is then turned off, it takes 20s before the music starts playing from
> > the center.
> > 
> > Define HCI_Write_Link_Supervision_Timeout command, event structure, and
> > corresponding event handler function, set the timeout to 5s after ACL
> > link is established.
>
> Why five seconds and not less? How do Chromium OS or Android do it?
In environments with significant interference, a larger timeout value should generally lead to better connection stability. The 5-second value was chosen based on a comprehensive evaluation and can be considered an empirical value. For reference, the Android system defaults to 8 seconds. You can find the corresponding logic in the on_acl_br_edr_connected and btm_acl_role_changed functions in the Android 17 source code at packages/modules/Bluetooth/system/stack/acl/btm_acl.cc.
>
> Please also document one test setup up, where you could reproduce it.
The local setup uses RTL8852BU and MT7922 modules.
After connecting the PC to the speaker via scanning, use the hcitool to query the link supervision timeout. The steps are as follows:
hcitool con
Connections:
        < ACL BE:EC:CC:19:7C:D9 handle 70 state 1 lm CENTRAL AUTH ENCRYPT

hcitool cmd 0x03 0x0036 0x46 0x00
< HCI Command: ogf 0x03, ocf 0x0036, plen 2
  46 00
> HCI Event: 0x0e plen 8
  01 36 0C 00 46 00 00 7D
Here, 00 7D represents the timeout value 0x7D00, which converts to the actual time: 32000*0.625ms = 20000ms.

Then, power off the speaker and observe how long it takes for btmon to print the HCI disconnection message.
The reason for the disconnection is Connection Timeout.
> HCI Event: Disconnect Complete (0x05) plen 4        #1 [hci0] 17:17:48.806247
        Status: Success (0x00)
        Handle: 70
        Reason: Connection Timeout (0x08)

Some devices actively initiate a disconnection when powered off. In this case, the link supervision timeout will not take effect, so the issue cannot be reproduced.
The reason for the disconnection is Remote User Terminated Connection.
> ACL Data RX: Handle 69 flags 0x02 dlen 12        #1158 [hci0] 17:22:17.418475
      L2CAP: Disconnection Request (0x06) ident 16 len 4
        Destination CID: 66
        Source CID: 68
< ACL Data TX: Handle 69 flags 0x00 dlen 12        #1159 [hci0] 17:22:17.418514
      L2CAP: Disconnection Response (0x07) ident 16 len 4
        Destination CID: 66
        Source CID: 68
> HCI Event: Disconnect Complete (0x05) plen 4     #1161 [hci0] 17:22:17.671651
        Status: Success (0x00)
        Handle: 69
        Reason: Remote User Terminated Connection (0x13)
>
> > Signed-off-by: Chen Zhang <zhangchen01@kylinos.cn>
> > ---
> >   include/net/bluetooth/hci.h      | 10 +++++++
> >   include/net/bluetooth/hci_core.h |  1 +
> >   net/bluetooth/hci_event.c        | 50 ++++++++++++++++++++++++++++++++
> >   3 files changed, 61 insertions(+)
> > 
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 50f0eef71fb1..18a5a17eb218 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -1239,6 +1239,16 @@ struct hci_cp_host_buffer_size {
> >   	__le16   sco_max_pkt;
> >   } __packed;
> >   
> > +#define HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT	0x0c37
> > +struct hci_cp_write_link_supervision_timeout {
> > +	__le16	 handle;
> > +	__le16	 timeout;
>
> How about appending the unit for the timeout: timeout_s.
If there are no other issues with this patch review, I'll upload a v3 version and update the 'timeout' to 'timeout_ms'.
>
> > +} __packed;
> > +struct hci_rp_write_link_supervision_timeout {
> > +	__u8	 status;
> > +	__le16	 handle;
> > +} __packed;
> > +
> >   #define HCI_OP_READ_NUM_SUPPORTED_IAC	0x0c38
> >   struct hci_rp_read_num_supported_iac {
> >   	__u8	status;
> > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> > index e7133ff87fbf..866903a9b5c8 100644
> > --- a/include/net/bluetooth/hci_core.h
> > +++ b/include/net/bluetooth/hci_core.h
> > @@ -702,6 +702,7 @@ struct hci_conn {
> >   	__u8		le_features[248];
> >   	__u16		pkt_type;
> >   	__u16		link_policy;
> > +	__u16		link_supervision_timeout;
>
> Ditto.
>
> >   	__u8		key_type;
> >   	__u8		auth_type;
> >   	__u8		sec_level;
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 741d658e9630..653184d0dfc7 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -606,6 +606,44 @@ static u8 hci_cc_write_voice_setting(struct hci_dev *hdev, void *data,
> >   	return rp->status;
> >   }
> >   
> > +static u8 hci_cc_write_link_supervision_timeout(struct hci_dev *hdev, void *data,
> > +						struct sk_buff *skb)
> > +{
> > +	struct hci_ev_status *rp = data;
> > +	struct hci_cp_write_link_supervision_timeout *sent;
> > +	struct hci_conn *conn;
> > +	u16 handle;
> > +	u8 status = rp->status;
> > +
> > +	bt_dev_dbg(hdev, "status 0x%2.2x", status);
> > +
> > +	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT);
> > +	if (!sent)
> > +		return status;
> > +
> > +	handle = le16_to_cpu(sent->handle);
> > +
> > +	hci_dev_lock(hdev);
> > +
> > +	conn = hci_conn_hash_lookup_handle(hdev, handle);
> > +	if (!conn) {
> > +		status = 0xFF;
> > +		goto done;
> > +	}
> > +
> > +	if (!status) {
> > +		conn->link_supervision_timeout = __le16_to_cpu(sent->timeout);
> > +		bt_dev_dbg(hdev, "handle 0x%4.4x timeout set to 0x%4.4x (%u ms)",
> > +			   handle, conn->link_supervision_timeout,
> > +			   conn->link_supervision_timeout * 5 / 8);
> > +	}
> > +
> > +done:
> > +	hci_dev_unlock(hdev);
> > +
> > +	return status;
> > +}
> > +
> >   static u8 hci_cc_read_num_supported_iac(struct hci_dev *hdev, void *data,
> >   					struct sk_buff *skb)
> >   {
> > @@ -3240,6 +3278,16 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
> >   			hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
> >   				     &cp);
> >   		}
> > +
> > +		if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) {
> > +			struct hci_cp_write_link_supervision_timeout cp;
> > +
> > +			cp.handle = ev->handle;
> > +			cp.timeout = 0x1F40;	/* 8000 * 0.625ms = 5000ms */
> > +			hci_send_cmd(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT,
> > +				     sizeof(cp), &cp);
> > +		}
> > +
> >   	}
> >   
> >   	if (conn->type == ACL_LINK)
> > @@ -4097,6 +4145,8 @@ static const struct hci_cc {
> >   	HCI_CC_STATUS(HCI_OP_WRITE_CLASS_OF_DEV, hci_cc_write_class_of_dev),
> >   	HCI_CC(HCI_OP_READ_VOICE_SETTING, hci_cc_read_voice_setting,
> >   	       sizeof(struct hci_rp_read_voice_setting)),
> > +	HCI_CC(HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT, hci_cc_write_link_supervision_timeout,
> > +	       sizeof(struct hci_rp_write_link_supervision_timeout)),
> >   	HCI_CC_STATUS(HCI_OP_WRITE_VOICE_SETTING, hci_cc_write_voice_setting),
> >   	HCI_CC(HCI_OP_READ_NUM_SUPPORTED_IAC, hci_cc_read_num_supported_iac,
> >   	       sizeof(struct hci_rp_read_num_supported_iac)),
>
>


-- 
Regards,
    Chen Zhang


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

* Re: [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures
  2026-07-24  8:54 [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures zhangchen200426
  2026-07-24  9:23 ` Paul Menzel
  2026-07-24  9:48 ` [v2] " bluez.test.bot
@ 2026-08-07 21:58 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-08-07 21:58 UTC (permalink / raw)
  To: zhangchen200426, luiz.von.dentz, yang.li, tim.bird, naga.akella,
	gustavoars, pav
  Cc: oe-kbuild-all, zhangchen01, linux-bluetooth

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on bluetooth/master linus/master v7.2-rc6 next-20260807]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/zhangchen200426-163-com/Bluetooth-hci_event-Add-HCI_Write_Link_Supervision_Timeout-command-event-structures/20260806-180202
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link:    https://lore.kernel.org/r/20260724085406.1884991-1-zhangchen200426%40163.com
patch subject: [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures
config: riscv-randconfig-r111-20260807 (https://download.01.org/0day-ci/archive/20260808/202608080528.0kc5JCoL-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 16.1.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260808/202608080528.0kc5JCoL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608080528.0kc5JCoL-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   WARNING: invalid argument to '-march': '_zacas_zabha'
>> net/bluetooth/hci_event.c:3324:36: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le16 [assigned] [usertype] timeout @@     got int @@
   net/bluetooth/hci_event.c:3324:36: sparse:     expected restricted __le16 [assigned] [usertype] timeout
   net/bluetooth/hci_event.c:3324:36: sparse:     got int
   net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
   include/net/bluetooth/hci.h:2985:47: sparse: sparse: array of flexible structures
   include/net/bluetooth/hci.h:3071:43: sparse: sparse: array of flexible structures

vim +3324 net/bluetooth/hci_event.c

  3187	
  3188	static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
  3189					  struct sk_buff *skb)
  3190	{
  3191		struct hci_ev_conn_complete *ev = data;
  3192		struct hci_conn *conn;
  3193		u8 status = ev->status;
  3194	
  3195		bt_dev_dbg(hdev, "status 0x%2.2x", status);
  3196	
  3197		hci_dev_lock(hdev);
  3198		hci_store_wake_reason(hdev, &ev->bdaddr, BDADDR_BREDR);
  3199	
  3200		/* Check for existing connection:
  3201		 *
  3202		 * 1. If it doesn't exist then it must be receiver/slave role.
  3203		 * 2. If it does exist confirm that it is connecting/BT_CONNECT in case
  3204		 *    of initiator/master role since there could be a collision where
  3205		 *    either side is attempting to connect or something like a fuzzing
  3206		 *    testing is trying to play tricks to destroy the hcon object before
  3207		 *    it even attempts to connect (e.g. hcon->state == BT_OPEN).
  3208		 */
  3209		conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
  3210		if (!conn ||
  3211		    (conn->role == HCI_ROLE_MASTER && conn->state != BT_CONNECT)) {
  3212			/* In case of error status and there is no connection pending
  3213			 * just unlock as there is nothing to cleanup.
  3214			 */
  3215			if (ev->status)
  3216				goto unlock;
  3217	
  3218			/* Connection may not exist if auto-connected. Check the bredr
  3219			 * allowlist to see if this device is allowed to auto connect.
  3220			 * If link is an ACL type, create a connection class
  3221			 * automatically.
  3222			 *
  3223			 * Auto-connect will only occur if the event filter is
  3224			 * programmed with a given address. Right now, event filter is
  3225			 * only used during suspend.
  3226			 */
  3227			if (ev->link_type == ACL_LINK &&
  3228			    hci_bdaddr_list_lookup_with_flags(&hdev->accept_list,
  3229							      &ev->bdaddr,
  3230							      BDADDR_BREDR)) {
  3231				conn = hci_conn_add_unset(hdev, ev->link_type,
  3232							  &ev->bdaddr, 0,
  3233							  HCI_ROLE_SLAVE);
  3234				if (IS_ERR(conn)) {
  3235					bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn));
  3236					goto unlock;
  3237				}
  3238			} else {
  3239				if (ev->link_type != SCO_LINK)
  3240					goto unlock;
  3241	
  3242				conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK,
  3243							       &ev->bdaddr);
  3244				if (!conn)
  3245					goto unlock;
  3246	
  3247				conn->type = SCO_LINK;
  3248			}
  3249		}
  3250	
  3251		/* The HCI_Connection_Complete event is only sent once per connection.
  3252		 * Processing it more than once per connection can corrupt kernel memory.
  3253		 *
  3254		 * As the connection handle is set here for the first time, it indicates
  3255		 * whether the connection is already set up.
  3256		 */
  3257		if (!HCI_CONN_HANDLE_UNSET(conn->handle)) {
  3258			bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection");
  3259			goto unlock;
  3260		}
  3261	
  3262		if (!status) {
  3263			status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle));
  3264			if (status)
  3265				goto done;
  3266	
  3267			if (conn->type == ACL_LINK) {
  3268				conn->state = BT_CONFIG;
  3269				hci_conn_hold(conn);
  3270	
  3271				if (!conn->out && !hci_conn_ssp_enabled(conn) &&
  3272				    !hci_find_link_key(hdev, &ev->bdaddr))
  3273					conn->disc_timeout = HCI_PAIRING_TIMEOUT;
  3274				else
  3275					conn->disc_timeout = HCI_DISCONN_TIMEOUT;
  3276			} else
  3277				conn->state = BT_CONNECTED;
  3278	
  3279			hci_debugfs_create_conn(conn);
  3280			hci_conn_add_sysfs(conn);
  3281	
  3282			if (test_bit(HCI_AUTH, &hdev->flags))
  3283				set_bit(HCI_CONN_AUTH, &conn->flags);
  3284	
  3285			if (test_bit(HCI_ENCRYPT, &hdev->flags))
  3286				set_bit(HCI_CONN_ENCRYPT, &conn->flags);
  3287	
  3288			/* "Link key request" completed ahead of "connect request" completes */
  3289			if (ev->encr_mode == 1 && !test_bit(HCI_CONN_ENCRYPT, &conn->flags) &&
  3290			    ev->link_type == ACL_LINK) {
  3291				struct link_key *key;
  3292	
  3293				key = hci_find_link_key(hdev, &ev->bdaddr);
  3294				if (key) {
  3295					set_bit(HCI_CONN_ENCRYPT, &conn->flags);
  3296					hci_read_enc_key_size(hdev, conn);
  3297					hci_encrypt_cfm(conn, ev->status);
  3298				}
  3299			}
  3300	
  3301			/* Get remote features */
  3302			if (conn->type == ACL_LINK) {
  3303				struct hci_cp_read_remote_features cp;
  3304				cp.handle = ev->handle;
  3305				hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES,
  3306					     sizeof(cp), &cp);
  3307	
  3308				hci_update_scan(hdev);
  3309			}
  3310	
  3311			/* Set packet type for incoming connection */
  3312			if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) {
  3313				struct hci_cp_change_conn_ptype cp;
  3314				cp.handle = ev->handle;
  3315				cp.pkt_type = cpu_to_le16(conn->pkt_type);
  3316				hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
  3317					     &cp);
  3318			}
  3319	
  3320			if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) {
  3321				struct hci_cp_write_link_supervision_timeout cp;
  3322	
  3323				cp.handle = ev->handle;
> 3324				cp.timeout = 0x1F40;	/* 8000 * 0.625ms = 5000ms */
  3325				hci_send_cmd(hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT,
  3326					     sizeof(cp), &cp);
  3327			}
  3328	
  3329		}
  3330	
  3331		if (conn->type == ACL_LINK)
  3332			hci_sco_setup(conn, ev->status);
  3333	
  3334	done:
  3335		if (status) {
  3336			hci_conn_failed(conn, status);
  3337		} else if (ev->link_type == SCO_LINK) {
  3338			switch (conn->setting & SCO_AIRMODE_MASK) {
  3339			case SCO_AIRMODE_CVSD:
  3340				if (hdev->notify)
  3341					hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD);
  3342				break;
  3343			}
  3344	
  3345			hci_connect_cfm(conn, status);
  3346		}
  3347	
  3348	unlock:
  3349		hci_dev_unlock(hdev);
  3350	}
  3351	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2026-08-07 21:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24  8:54 [PATCH v2] Bluetooth: hci_event: Add HCI_Write_Link_Supervision_Timeout command/event structures zhangchen200426
2026-07-24  9:23 ` Paul Menzel
2026-07-25  9:52   ` zhangchen200426
2026-07-24  9:48 ` [v2] " bluez.test.bot
2026-08-07 21:58 ` [PATCH v2] " kernel test robot

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