[PATCH AUTOSEL 6.19-6.6] Bluetooth: hci_conn: Set link_policy on incoming ACL connections

Sasha Levin
2026-02-14T21:26:56Z

From: Stefan Sørensen <ssorensen@roku.com>

[ Upstream commit 4bb091013ab0f2edfed3f58bebe658a798cbcc4d ]

The connection link policy is only set when establishing an outgoing
ACL connection causing connection idle modes not to be available on
incoming connections. Move the setting of the link policy to the
creation of the connection so all ACL connection will use the link
policy set on the HCI device.

Signed-off-by: Stefan Sørensen <ssorensen@roku.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Analysis of Bluetooth: hci_conn: Set link_policy on incoming ACL
connections

### 1. COMMIT MESSAGE ANALYSIS

The commit message clearly describes a functional bug: the connection
link policy is **only** set when establishing an **outgoing** ACL
connection, which means **incoming** ACL connections don't get the link
policy configured on the HCI device. This causes "connection idle modes
not to be available on incoming connections."

The fix moves the `link_policy` assignment from the outgoing-connection-
specific path (`hci_acl_create_conn_sync`) to the generic connection
creation path (`__hci_conn_add`), so all ACL connections (both incoming
and outgoing) inherit the device's link policy.

### 2. CODE CHANGE ANALYSIS

The change is extremely small and surgical:

**In `net/bluetooth/hci_conn.c` (`__hci_conn_add`):**
- Adds one line: `conn->link_policy = hdev->link_policy;` in the
`ACL_LINK` case of the switch statement during connection
initialization.

**In `net/bluetooth/hci_sync.c` (`hci_acl_create_conn_sync`):**
- Removes the line `conn->link_policy = hdev->link_policy;` from the
outgoing connection creation path (since it's now handled in the
common path).

This is a pure **move** of a single assignment from a specific path to a
common path. The net effect:
- Outgoing connections: behavior is unchanged (link_policy was set
before, still set now, just earlier in the flow)
- Incoming connections: link_policy is now properly set (was previously
missing)

### 3. CLASSIFICATION

This is a **bug fix**. Incoming Bluetooth ACL connections were not
getting the correct link policy, which means features like sniff mode
(power saving) and role switching wouldn't work properly on incoming
connections. This is a real functional issue affecting Bluetooth power
management and connection behavior.

### 4. SCOPE AND RISK ASSESSMENT

- **Lines changed:** 2 (1 added, 1 removed - it's a move)
- **Files changed:** 2
- **Complexity:** Extremely low - moving an assignment to a more
appropriate location
- **Risk of regression:** Minimal. The assignment already existed for
outgoing connections; this just ensures incoming connections get the
same treatment. The value being assigned (`hdev->link_policy`) is the
same in both cases.

### 5. USER IMPACT

Bluetooth is widely used on laptops, desktops, and embedded systems. The
link policy controls important features like:
- **Sniff mode**: Power-saving mode that reduces radio duty cycle
- **Role switching**: Ability to switch between master and slave roles
- **Hold mode**: Another power management feature

Without the correct link policy on incoming connections, Bluetooth
devices connecting to the affected system would not benefit from power-
saving modes, potentially leading to increased battery drain and missing
expected Bluetooth behavior.

### 6. STABILITY INDICATORS

- The author (Stefan Sørensen) submitted the fix and it was signed off
by Luiz Augusto von Dentz, the Bluetooth subsystem maintainer. This
indicates it was reviewed and approved by the person most
knowledgeable about the code.
- The change is trivially correct - it's moving an existing assignment
to a more general location.

### 7. DEPENDENCY CHECK

This commit is completely self-contained. It doesn't depend on any other
changes - it simply moves an existing line of code. The `link_policy`
field, `hdev->link_policy`, and `__hci_conn_add` function have been in
the kernel for a long time, so this should apply cleanly to stable
trees.

### 8. STABLE KERNEL CRITERIA

- **Obviously correct:** Yes - it's a one-line move that ensures all ACL
connections get the device's link policy
- **Fixes a real bug:** Yes - incoming connections missing link policy
settings
- **Small and contained:** Yes - 2 lines across 2 files
- **No new features:** Correct - this enables existing functionality
that was incorrectly not applied
- **Risk vs benefit:** Very low risk (trivially correct code move) vs
meaningful benefit (proper Bluetooth power management on incoming
connections)

**YES**

net/bluetooth/hci_conn.c | 1 +
net/bluetooth/hci_sync.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index c3f7828bf9d54..b5e345fa6c344 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1002,6 +1002,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type,
switch (type) {
case ACL_LINK:
conn->pkt_type = hdev->pkt_type & ACL_PTYPE_MASK;
+ conn->link_policy = hdev->link_policy;
conn->mtu = hdev->acl_mtu;
break;
case LE_LINK:
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index cbc3a75d73262..334eb4376a266 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6897,8 +6897,6 @@ static int hci_acl_create_conn_sync(struct hci_dev *hdev, void *data)

conn->attempt++;

- conn->link_policy = hdev->link_policy;
-
memset(&cp, 0, sizeof(cp));
bacpy(&cp.bdaddr, &conn->dst);
cp.pscan_rep_mode = 0x02;
--
2.51.0