Bluetooth: hci_conn: Fix using conn->le_{tx,rx}_phy as supported PHYs
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 Bluetooth: hci_conn: Fix using conn->le_{tx,rx}_phy as supported PHYs
From: Luiz Augusto von Dentz <[email protected]>
conn->le_{tx,rx}_phy is not actually a bitfield as it set by HCI_EV_LE_PHY_UPDATE_COMPLETE it is actually correspond to the current PHY in use not what is supported by the controller, so this introduces different fields (conn->le_{tx,rx}_def_phys) to track what PHYs are supported by the connection.
--- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_conn.c | 17 +++++++++++------ net/bluetooth/hci_event.c | 26 +++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 9 deletions(-)
include/net/bluetooth/hci_core.h +2 -0
@@ -730,6 +730,8 @@ struct hci_conn {__u16 le_per_adv_data_offset;__u8 le_adv_phy;__u8 le_adv_sec_phy; +__u8 le_tx_def_phys; +__u8 le_rx_def_phys;__u8 le_tx_phy;__u8 le_rx_phy;__s8 rssi;
net/bluetooth/hci_conn.c +11 -6
@@ -1008,6 +1008,11 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type,/* conn->src should reflect the local identity address */ hci_copy_identity_address (hdev, &conn->src, &conn->src_type); conn->mtu = hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu; +/* Use the controller supported PHYS as default until the +* remote features are resolved. +*/ + conn->le_tx_def_phys = hdev->le_tx_def_phys; + conn->le_rx_def_phys = hdev->le_tx_def_phys;break ;case CIS_LINK :/* conn->src should reflect the local identity address */
@@ -2928,22 +2933,22 @@ u32 hci_conn_get_phy(struct hci_conn *conn)break ;case LE_LINK : -if (conn->le_tx_phy &HCI_LE_SET_PHY_1M ) +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_1M ) phys |=BT_PHY_LE_1M_TX ; -if (conn->le_rx_phy &HCI_LE_SET_PHY_1M ) +if (conn->le_rx_def_phys &HCI_LE_SET_PHY_1M ) phys |=BT_PHY_LE_1M_RX ; -if (conn->le_tx_phy &HCI_LE_SET_PHY_2M ) +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_2M ) phys |=BT_PHY_LE_2M_TX ; -if (conn->le_rx_phy &HCI_LE_SET_PHY_2M ) +if (conn->le_rx_def_phys &HCI_LE_SET_PHY_2M ) phys |=BT_PHY_LE_2M_RX ; -if (conn->le_tx_phy &HCI_LE_SET_PHY_CODED ) +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_CODED ) phys |=BT_PHY_LE_CODED_TX ; -if (conn->le_rx_phy &HCI_LE_SET_PHY_CODED ) +if (conn->le_rx_def_phys &HCI_LE_SET_PHY_CODED ) phys |=BT_PHY_LE_CODED_RX ;break ;
net/bluetooth/hci_event.c +23 -3
@@ -6607,8 +6607,18 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data, conn =hci_conn_hash_lookup_handle (hdev,__le16_to_cpu (ev->handle));if (conn) { -if (!ev->status) -memcpy (conn->features[0 ], ev->features,8 ); +if (!ev->status) { +memcpy (conn->le_features, ev->features,8 ); + +/* Update supported PHYs */ +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_2M && + !(conn->le_features[1 ] &HCI_LE_PHY_2M )) + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_2M ; + +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_CODED && + !(conn->le_features[1 ] &HCI_LE_PHY_CODED )) + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_CODED ; + }if (conn->state ==BT_CONFIG ) {__u8 status;
@@ -7221,9 +7231,19 @@ static void hci_le_read_all_remote_features_evt(struct hci_dev *hdev,if (!conn) goto unlock; -if (!ev->status) +if (!ev->status) {memcpy (conn->le_features, ev->features,248 ); +/* Update supported PHYs */ +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_2M && + !(conn->le_features[1 ] &HCI_LE_PHY_2M )) + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_2M ; + +if (conn->le_tx_def_phys &HCI_LE_SET_PHY_CODED && + !(conn->le_features[1 ] &HCI_LE_PHY_CODED )) + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_CODED ; + } +if (conn->state ==BT_CONFIG ) {__u8 status;
Signature · 1 line
2.52.0
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=1032101
---Test result---
Test Summary:
CheckPatch PENDING 0.47 seconds GitLint PENDING 0.31 seconds SubjectPrefix PASS 0.10 seconds BuildKernel PASS 25.13 seconds CheckAllWarning PASS 27.29 seconds CheckSparse WARNING 30.65 seconds BuildKernel32 PASS 24.83 seconds TestRunnerSetup PASS 552.20 seconds TestRunner_l2cap-tester PASS 24.00 seconds TestRunner_iso-tester PASS 85.38 seconds TestRunner_bnep-tester PASS 6.22 seconds TestRunner_mgmt-tester FAIL 126.02 seconds TestRunner_rfcomm-tester PASS 9.44 seconds TestRunner_sco-tester FAIL 14.66 seconds TestRunner_ioctl-tester PASS 10.16 seconds TestRunner_mesh-tester FAIL 11.49 seconds TestRunner_smp-tester PASS 8.61 seconds TestRunner_userchan-tester PASS 6.55 seconds IncrementalBuild PENDING 0.64 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
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):
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 488 (98.8%), Failed: 2, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.106 seconds LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.180 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
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 1.858 seconds Mesh - Send cancel - 2 Timed out 1.997 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Wed, 10 Dec 2025 15:50:12 -0500 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
conn->le_{tx,rx}_phy is not actually a bitfield as it set by
HCI_EV_LE_PHY_UPDATE_COMPLETEit is actually correspond to the current PHY in use not what is supported by the controller, so this introduces different fields (conn->le_{tx,rx}_def_phys) to track what PHYs are supported by the connection.[...]
Here is the summary with links:
- [v1] Bluetooth: hci_conn: Fix using conn->le_{tx,rx}_phy as supported PHYs
https://git.kernel.org/bluetooth/bluetooth-next/c/305c1c5dd5f4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html