public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Stefan Sørensen" <ssorensen@roku.com>,
	"Luiz Augusto von Dentz" <luiz.von.dentz@intel.com>,
	"Sasha Levin" <sashal@kernel.org>,
	marcel@holtmann.org, johan.hedberg@gmail.com,
	luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.6] Bluetooth: hci_conn: Set link_policy on incoming ACL connections
Date: Sat, 14 Feb 2026 16:23:38 -0500	[thread overview]
Message-ID: <20260214212452.782265-73-sashal@kernel.org> (raw)
In-Reply-To: <20260214212452.782265-1-sashal@kernel.org>

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


  parent reply	other threads:[~2026-02-14 21:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260214212452.782265-1-sashal@kernel.org>
2026-02-14 21:22 ` [PATCH AUTOSEL 6.19-6.18] Bluetooth: hci_qca: Fix SSR (SubSystem Restart) fail when BT_EN is pulled up by hw Sasha Levin
2026-02-14 21:23 ` [PATCH AUTOSEL 6.19-6.18] Bluetooth: btusb: Add USB ID 0489:e112 for Realtek 8851BE Sasha Levin
2026-02-14 21:23 ` [PATCH AUTOSEL 6.19-6.12] Bluetooth: btusb: Add support for MediaTek7920 0489:e158 Sasha Levin
2026-02-14 21:23 ` [PATCH AUTOSEL 6.19-6.1] Bluetooth: btusb: Add new VID/PID for RTL8852CE Sasha Levin
2026-02-14 21:23 ` Sasha Levin [this message]
2026-02-14 21:23 ` [PATCH AUTOSEL 6.19-5.10] Bluetooth: btusb: Add device ID for Realtek RTL8761BU Sasha Levin
2026-02-14 21:24 ` [PATCH AUTOSEL 6.19-5.10] Bluetooth: hci_conn: use mod_delayed_work for active mode timeout Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260214212452.782265-73-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=luiz.von.dentz@intel.com \
    --cc=marcel@holtmann.org \
    --cc=patches@lists.linux.dev \
    --cc=ssorensen@roku.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox