* [RFC PATCH 0/2] Bluetooth: LE connection event length requests
@ 2026-12-02 23:56 Kyle Pepper
2026-12-02 23:56 ` [RFC PATCH 1/2] Bluetooth: Match LE connection update completions Kyle Pepper
2026-12-02 23:56 ` [RFC PATCH 2/2] Bluetooth: Add " Kyle Pepper
0 siblings, 2 replies; 4+ messages in thread
From: Kyle Pepper @ 2026-12-02 23:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, luiz.dentz
Expose connection-wide advisory CE length hints to connected Central LE
sockets so ASHA can request event time and wait for setup before START.
First correct synchronous LE update completion matching and error reporting.
No controller-specific defaults or connection interval changes are added.
The hints are in 0.625 ms units and can be ignored by the controller.
The API uses shared last-writer state, not per-socket reservations. Option 23
is provisional. The getter returns native-endian u16 min/max hints and an
optional s32 completion status; its full result is eight bytes.
AI assistance: Codex (GPT-6).
Base: bluetooth-next 7a1a7a5baa1e0f84d0568fc999421ee7dcbccaf5.
This is a first public kernel CE RFC; local candidate numbers are not
previous public versions. No kernel CE Message-ID is verified.
BlueZ companion, already archived:
https://lore.kernel.org/linux-bluetooth/20261202160403.226082-1-cochcoder@proton.me/
Offline validation: four W=1 objects; GCC/Clang source-extracted LE dispatch
and CE queue tests; getter lengths 0..16 and baseline/negative controls.
The exact source has no hardware, PTS or running-kernel lockdep result.
Older integrated N8/MT7922 trials do not establish general controller support.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC PATCH 1/2] Bluetooth: Match LE connection update completions
2026-12-02 23:56 [RFC PATCH 0/2] Bluetooth: LE connection event length requests Kyle Pepper
@ 2026-12-02 23:56 ` Kyle Pepper
2026-12-03 1:17 ` Bluetooth: LE connection event length requests bluez.test.bot
2026-12-02 23:56 ` [RFC PATCH 2/2] Bluetooth: Add " Kyle Pepper
1 sibling, 1 reply; 4+ messages in thread
From: Kyle Pepper @ 2026-12-02 23:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, luiz.dentz
LE meta dispatch completes synchronous connection updates on the
subevent alone and supplies success without checking the event status.
An update for another handle, or a failed or truncated update, can release
the wait as successful.
Match the requested connection handle and require the complete event body
before completing the request. Propagate its status while still dispatching
unrelated link updates to their normal handler.
AI assistance: Codex (GPT-6).
Signed-off-by: Kyle Pepper <cochcoder@proton.me>
---
Base: bluetooth-next 7a1a7a5baa1e0f84d0568fc999421ee7dcbccaf5.
This is a first public kernel CE RFC; local candidate numbers are not
previous public versions. No kernel CE Message-ID is verified.
BlueZ companion, already archived:
https://lore.kernel.org/linux-bluetooth/20261202160403.226082-1-cochcoder@proton.me/
Offline validation: four W=1 objects; GCC/Clang source-extracted LE dispatch
and CE queue tests; getter lengths 0..16 and baseline/negative controls.
The exact source has no hardware, PTS or running-kernel lockdep result.
Older integrated N8/MT7922 trials do not establish general controller support.
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -8494,11 +8494,29 @@
(hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) == 0x08 ||
hci_skb_opcode(hdev->req_skb) == HCI_OP_NOP) &&
hci_skb_event(hdev->req_skb) == ev->subevent) {
+ if (hci_skb_opcode(hdev->req_skb) == HCI_OP_LE_CONN_UPDATE) {
+ struct hci_cp_le_conn_update *cp;
+ struct hci_ev_le_conn_update_complete *complete;
+
+ if (hdev->req_skb->len < HCI_COMMAND_HDR_SIZE +
+ sizeof(*cp) ||
+ skb->len < sizeof(*complete))
+ goto dispatch;
+
+ cp = (void *)(hdev->req_skb->data + HCI_COMMAND_HDR_SIZE);
+ complete = (void *)skb->data;
+ if (cp->handle != complete->handle)
+ goto dispatch;
+
+ *status = complete->status;
+ }
+
*opcode = hci_skb_opcode(hdev->req_skb);
- hci_req_cmd_complete(hdev, *opcode, 0x00, req_complete,
+ hci_req_cmd_complete(hdev, *opcode, *status, req_complete,
req_complete_skb);
}
+dispatch:
subev = &hci_le_ev_table[ev->subevent];
if (!subev->func)
return;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC PATCH 2/2] Bluetooth: Add LE connection event length requests
2026-12-02 23:56 [RFC PATCH 0/2] Bluetooth: LE connection event length requests Kyle Pepper
2026-12-02 23:56 ` [RFC PATCH 1/2] Bluetooth: Match LE connection update completions Kyle Pepper
@ 2026-12-02 23:56 ` Kyle Pepper
1 sibling, 0 replies; 4+ messages in thread
From: Kyle Pepper @ 2026-12-02 23:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, luiz.dentz
Allow connected Central LE sockets to request advisory connection
event length hints without replacing the live interval, latency or timeout.
Keep the request on the shared connection and preserve it in later updates.
Expose queued or executing work as -EINPROGRESS in an optional extended
getter. Report the final error without clearing a newer pending request.
Four-byte reads return the requested hint prefix. HCI completion confirms
the procedure outcome, not reserved airtime.
AI assistance: Codex (GPT-6).
Signed-off-by: Kyle Pepper <cochcoder@proton.me>
---
Base: bluetooth-next 7a1a7a5baa1e0f84d0568fc999421ee7dcbccaf5.
This is a first public kernel CE RFC; local candidate numbers are not
previous public versions. No kernel CE Message-ID is verified.
BlueZ companion, already archived:
https://lore.kernel.org/linux-bluetooth/20261202160403.226082-1-cochcoder@proton.me/
Offline validation: four W=1 objects; GCC/Clang source-extracted LE dispatch
and CE queue tests; getter lengths 0..16 and baseline/negative controls.
The exact source has no hardware, PTS or running-kernel lockdep result.
Older integrated N8/MT7922 trials do not establish general controller support.
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -358,6 +358,19 @@
#define BT_SCM_PKT_SEQNUM 0x05
+#define BT_LE_CONN_EVENT_LEN 23
+/* Connection-wide advisory hints in 0.625 ms units; zero is unspecified. */
+struct bt_le_conn_event_len {
+ __u16 min;
+ __u16 max;
+};
+
+struct bt_le_conn_event_len_state {
+ struct bt_le_conn_event_len request;
+ /* Zero, -EINPROGRESS, or the last completed request's negative errno. */
+ __s32 status;
+};
+
__printf(1, 2)
void bt_info(const char *fmt, ...);
__printf(1, 2)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -786,6 +786,10 @@
__u16 le_conn_interval;
__u16 le_conn_latency;
__u16 le_supv_timeout;
+ __u16 le_min_ce_len;
+ __u16 le_max_ce_len;
+ unsigned int le_ce_pending;
+ int le_ce_status;
__u16 le_rate_interval;
__u16 le_subrate;
__u16 le_rate_latency;
@@ -2493,6 +2497,7 @@
u32 hci_conn_get_phy(struct hci_conn *conn);
int hci_conn_set_phy(struct hci_conn *conn, u32 phys);
+int hci_conn_set_le_event_len(struct hci_conn *conn, u16 min, u16 max);
/* ----- HCI Sockets ----- */
void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -536,8 +536,8 @@
cp.conn_interval_max = cpu_to_le16(d->max);
cp.conn_latency = cpu_to_le16(d->latency);
cp.supervision_timeout = cpu_to_le16(d->to_multiplier);
- cp.min_ce_len = cpu_to_le16(0x0000);
- cp.max_ce_len = cpu_to_le16(0x0000);
+ cp.min_ce_len = cpu_to_le16(conn->le_min_ce_len);
+ cp.max_ce_len = cpu_to_le16(conn->le_max_ce_len);
timeout = conn->conn_timeout;
hci_dev_unlock(hdev);
@@ -602,6 +602,96 @@
hci_conn_put(conn);
kfree(d);
}
+}
+
+static int le_conn_event_len_sync(struct hci_dev *hdev, void *data)
+{
+ struct hci_conn *conn = data;
+ struct hci_cp_le_conn_update cp = {};
+ u16 timeout;
+
+ hci_dev_lock(hdev);
+
+ if (!hci_conn_valid(hdev, conn) || conn->state != BT_CONNECTED) {
+ hci_dev_unlock(hdev);
+ return -ENOTCONN;
+ }
+
+ /* Change only the local hints, preserving the live link parameters. */
+ cp.handle = cpu_to_le16(conn->handle);
+ cp.conn_interval_min = cpu_to_le16(conn->le_conn_interval);
+ cp.conn_interval_max = cpu_to_le16(conn->le_conn_interval);
+ cp.conn_latency = cpu_to_le16(conn->le_conn_latency);
+ cp.supervision_timeout = cpu_to_le16(conn->le_supv_timeout);
+ cp.min_ce_len = cpu_to_le16(conn->le_min_ce_len);
+ cp.max_ce_len = cpu_to_le16(conn->le_max_ce_len);
+ timeout = conn->conn_timeout;
+
+ hci_dev_unlock(hdev);
+
+ return __hci_cmd_sync_status_sk(hdev, HCI_OP_LE_CONN_UPDATE,
+ sizeof(cp), &cp,
+ HCI_EV_LE_CONN_UPDATE_COMPLETE,
+ timeout, NULL);
+}
+
+static void le_conn_event_len_complete(struct hci_dev *hdev, void *data,
+ int err)
+{
+ struct hci_conn *conn = data;
+
+ hci_dev_lock(hdev);
+ /* An older completion must not mark a newer queued request ready. */
+ if (!--conn->le_ce_pending)
+ conn->le_ce_status = err > 0 ? -bt_to_errno(err) : err;
+ hci_dev_unlock(hdev);
+
+ if (err)
+ bt_dev_dbg(hdev, "LE connection event length request failed (%d)",
+ err);
+
+ hci_conn_put(conn);
+}
+
+/* Device must be locked. The values describe the local request, not airtime. */
+int hci_conn_set_le_event_len(struct hci_conn *conn, u16 min, u16 max)
+{
+ struct hci_dev *hdev = conn->hdev;
+ u16 old_min, old_max;
+ int err;
+
+ if (conn->type != LE_LINK || conn->role != HCI_ROLE_MASTER)
+ return -EOPNOTSUPP;
+
+ if (!hci_conn_valid(hdev, conn) || conn->state != BT_CONNECTED)
+ return -ENOTCONN;
+
+ if (min > max)
+ return -EINVAL;
+
+ old_min = conn->le_min_ce_len;
+ old_max = conn->le_max_ce_len;
+ conn->le_min_ce_len = min;
+ conn->le_max_ce_len = max;
+
+ /* Queued work reads the latest request under the device lock. */
+ if (hci_cmd_sync_lookup_entry(hdev, le_conn_event_len_sync, conn,
+ le_conn_event_len_complete))
+ return 0;
+
+ err = hci_cmd_sync_queue(hdev, le_conn_event_len_sync,
+ hci_conn_get(conn),
+ le_conn_event_len_complete);
+ if (err) {
+ conn->le_min_ce_len = old_min;
+ conn->le_max_ce_len = old_max;
+ hci_conn_put(conn);
+ } else {
+ conn->le_ce_pending++;
+ conn->le_ce_status = -EINPROGRESS;
+ }
+
+ return err;
}
/* Device _must_ be locked */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -7640,8 +7640,8 @@
cp.interval_max = ev->interval_max;
cp.latency = ev->latency;
cp.timeout = ev->timeout;
- cp.min_ce_len = 0;
- cp.max_ce_len = 0;
+ cp.min_ce_len = cpu_to_le16(hcon->le_min_ce_len);
+ cp.max_ce_len = cpu_to_le16(hcon->le_max_ce_len);
hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp);
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -8188,14 +8188,23 @@
{
struct hci_cp_le_conn_update cp;
+ hci_dev_lock(hdev);
+
+ if (!hci_conn_valid(hdev, conn) || conn->state != BT_CONNECTED) {
+ hci_dev_unlock(hdev);
+ return -ENOTCONN;
+ }
+
memset(&cp, 0, sizeof(cp));
cp.handle = cpu_to_le16(conn->handle);
cp.conn_interval_min = cpu_to_le16(params->conn_min_interval);
cp.conn_interval_max = cpu_to_le16(params->conn_max_interval);
cp.conn_latency = cpu_to_le16(params->conn_latency);
cp.supervision_timeout = cpu_to_le16(params->supervision_timeout);
- cp.min_ce_len = cpu_to_le16(0x0000);
- cp.max_ce_len = cpu_to_le16(0x0000);
+ cp.min_ce_len = cpu_to_le16(conn->le_min_ce_len);
+ cp.max_ce_len = cpu_to_le16(conn->le_max_ce_len);
+
+ hci_dev_unlock(hdev);
return __hci_cmd_sync_status(hdev, HCI_OP_LE_CONN_UPDATE,
sizeof(cp), &cp, HCI_CMD_TIMEOUT);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -591,6 +591,50 @@
return err;
}
+static int l2cap_sock_conn_event_len(struct sock *sk,
+ struct bt_le_conn_event_len *len, int *status, bool set)
+{
+ struct l2cap_chan *chan = l2cap_pi(sk)->chan;
+ struct l2cap_conn *conn;
+ bool have_conn;
+ int err = 0;
+
+ l2cap_chan_lock(chan);
+ conn = l2cap_chan_conn(chan);
+ if (!conn) {
+ l2cap_chan_unlock(chan);
+ return -ENOTCONN;
+ }
+ l2cap_conn_get(conn);
+ l2cap_chan_unlock(chan);
+
+ /* Match the device -> connection -> channel -> socket lock order. */
+ hci_dev_lock(conn->hcon->hdev);
+ have_conn = l2cap_chan_lock_conn(chan);
+ lock_sock(sk);
+
+ if (l2cap_chan_conn(chan) != conn || sk->sk_state != BT_CONNECTED ||
+ !hci_conn_valid(conn->hcon->hdev, conn->hcon) ||
+ conn->hcon->state != BT_CONNECTED) {
+ err = -ENOTCONN;
+ } else if (conn->hcon->type != LE_LINK) {
+ err = -EOPNOTSUPP;
+ } else if (set) {
+ err = hci_conn_set_le_event_len(conn->hcon, len->min, len->max);
+ } else {
+ len->min = conn->hcon->le_min_ce_len;
+ len->max = conn->hcon->le_max_ce_len;
+ *status = conn->hcon->le_ce_status;
+ }
+
+ release_sock(sk);
+ l2cap_chan_unlock_conn(chan, have_conn);
+ hci_dev_unlock(conn->hcon->hdev);
+ l2cap_conn_put(conn);
+
+ return err;
+}
+
static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
sockopt_t *sopt)
{
@@ -613,6 +657,21 @@
return -ENOPROTOOPT;
len = sopt->optlen;
+ if (optname == BT_LE_CONN_EVENT_LEN) {
+ struct bt_le_conn_event_len_state event_len;
+
+ err = l2cap_sock_conn_event_len(sk, &event_len.request,
+ &event_len.status, false);
+ if (err)
+ return err;
+
+ len = min_t(size_t, len, sizeof(event_len));
+ if (copy_to_iter(&event_len, len, &sopt->iter_out) != len)
+ return -EFAULT;
+
+ sopt->optlen = len;
+ return 0;
+ }
l2cap_chan_lock(chan);
lock_sock(sk);
@@ -958,6 +1017,20 @@
if (level != SOL_BLUETOOTH)
return -ENOPROTOOPT;
+
+ if (optname == BT_LE_CONN_EVENT_LEN) {
+ struct bt_le_conn_event_len event_len;
+
+ if (optlen != sizeof(event_len))
+ return -EINVAL;
+
+ err = copy_safe_from_sockptr(&event_len, sizeof(event_len),
+ optval, optlen);
+ if (err)
+ return err;
+
+ return l2cap_sock_conn_event_len(sk, &event_len, NULL, true);
+ }
l2cap_chan_lock(chan);
lock_sock(sk);
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Bluetooth: LE connection event length requests
2026-12-02 23:56 ` [RFC PATCH 1/2] Bluetooth: Match LE connection update completions Kyle Pepper
@ 2026-12-03 1:17 ` bluez.test.bot
0 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-12-03 1:17 UTC (permalink / raw)
To: linux-bluetooth, cochcoder
[-- Attachment #1: Type: text/plain, Size: 1908 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/series/1230005/
---Test result---
Test Summary:
CheckPatch PASS 1.99 seconds
VerifyFixes PASS 0.06 seconds
VerifySignedoff PASS 0.06 seconds
GitLint PASS 0.36 seconds
SubjectPrefix PASS 0.10 seconds
BuildKernel PASS 24.27 seconds
CheckAllWarning PASS 27.68 seconds
CheckSparse WARNING 29.23 seconds
BuildKernel32 PASS 24.31 seconds
CheckKernelLLVM PASS 24.53 seconds
TestRunnerSetup PASS 563.71 seconds
TestRunner_l2cap-tester PASS 15.50 seconds
TestRunner_iso-tester PASS 13.63 seconds
TestRunner_bnep-tester PASS 2.84 seconds
TestRunner_mgmt-tester PASS 85.05 seconds
TestRunner_rfcomm-tester PASS 4.15 seconds
TestRunner_sco-tester PASS 5.14 seconds
TestRunner_ioctl-tester PASS 4.30 seconds
TestRunner_mesh-tester PASS 4.12 seconds
TestRunner_smp-tester PASS 4.00 seconds
TestRunner_userchan-tester PASS 2.88 seconds
TestRunner_6lowpan-tester PASS 4.05 seconds
IncrementalBuild PASS 40.25 seconds
Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
https://github.com/bluez/bluetooth-next/pull/1275
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 1:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 23:56 [RFC PATCH 0/2] Bluetooth: LE connection event length requests Kyle Pepper
2026-12-02 23:56 ` [RFC PATCH 1/2] Bluetooth: Match LE connection update completions Kyle Pepper
2026-12-03 1:17 ` Bluetooth: LE connection event length requests bluez.test.bot
2026-12-02 23:56 ` [RFC PATCH 2/2] Bluetooth: Add " Kyle Pepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox