Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: hci_conn: Fix using conn->le_{tx,rx}_phy as supported PHYs

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.

Fixes: eab2404ba798 ("Bluetooth: Add BT_PHY socket option")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+40 -9
+2
include/net/bluetooth/hci_core.h
··· 730 730 __u16 le_per_adv_data_offset; 731 731 __u8 le_adv_phy; 732 732 __u8 le_adv_sec_phy; 733 + __u8 le_tx_def_phys; 734 + __u8 le_rx_def_phys; 733 735 __u8 le_tx_phy; 734 736 __u8 le_rx_phy; 735 737 __s8 rssi;
+11 -6
net/bluetooth/hci_conn.c
··· 1008 1008 /* conn->src should reflect the local identity address */ 1009 1009 hci_copy_identity_address(hdev, &conn->src, &conn->src_type); 1010 1010 conn->mtu = hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu; 1011 + /* Use the controller supported PHYS as default until the 1012 + * remote features are resolved. 1013 + */ 1014 + conn->le_tx_def_phys = hdev->le_tx_def_phys; 1015 + conn->le_rx_def_phys = hdev->le_tx_def_phys; 1011 1016 break; 1012 1017 case CIS_LINK: 1013 1018 /* conn->src should reflect the local identity address */ ··· 2933 2928 break; 2934 2929 2935 2930 case LE_LINK: 2936 - if (conn->le_tx_phy & HCI_LE_SET_PHY_1M) 2931 + if (conn->le_tx_def_phys & HCI_LE_SET_PHY_1M) 2937 2932 phys |= BT_PHY_LE_1M_TX; 2938 2933 2939 - if (conn->le_rx_phy & HCI_LE_SET_PHY_1M) 2934 + if (conn->le_rx_def_phys & HCI_LE_SET_PHY_1M) 2940 2935 phys |= BT_PHY_LE_1M_RX; 2941 2936 2942 - if (conn->le_tx_phy & HCI_LE_SET_PHY_2M) 2937 + if (conn->le_tx_def_phys & HCI_LE_SET_PHY_2M) 2943 2938 phys |= BT_PHY_LE_2M_TX; 2944 2939 2945 - if (conn->le_rx_phy & HCI_LE_SET_PHY_2M) 2940 + if (conn->le_rx_def_phys & HCI_LE_SET_PHY_2M) 2946 2941 phys |= BT_PHY_LE_2M_RX; 2947 2942 2948 - if (conn->le_tx_phy & HCI_LE_SET_PHY_CODED) 2943 + if (conn->le_tx_def_phys & HCI_LE_SET_PHY_CODED) 2949 2944 phys |= BT_PHY_LE_CODED_TX; 2950 2945 2951 - if (conn->le_rx_phy & HCI_LE_SET_PHY_CODED) 2946 + if (conn->le_rx_def_phys & HCI_LE_SET_PHY_CODED) 2952 2947 phys |= BT_PHY_LE_CODED_RX; 2953 2948 2954 2949 break;
+27 -3
net/bluetooth/hci_event.c
··· 6607 6607 6608 6608 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 6609 6609 if (conn) { 6610 - if (!ev->status) 6611 - memcpy(conn->features[0], ev->features, 8); 6610 + if (!ev->status) { 6611 + memcpy(conn->le_features, ev->features, 8); 6612 + 6613 + /* Update supported PHYs */ 6614 + if (!(conn->le_features[1] & HCI_LE_PHY_2M)) { 6615 + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_2M; 6616 + conn->le_rx_def_phys &= ~HCI_LE_SET_PHY_2M; 6617 + } 6618 + 6619 + if (!(conn->le_features[1] & HCI_LE_PHY_CODED)) { 6620 + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_CODED; 6621 + conn->le_rx_def_phys &= ~HCI_LE_SET_PHY_CODED; 6622 + } 6623 + } 6612 6624 6613 6625 if (conn->state == BT_CONFIG) { 6614 6626 __u8 status; ··· 7233 7221 if (!conn) 7234 7222 goto unlock; 7235 7223 7236 - if (!ev->status) 7224 + if (!ev->status) { 7237 7225 memcpy(conn->le_features, ev->features, 248); 7226 + 7227 + /* Update supported PHYs */ 7228 + if (!(conn->le_features[1] & HCI_LE_PHY_2M)) { 7229 + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_2M; 7230 + conn->le_rx_def_phys &= ~HCI_LE_SET_PHY_2M; 7231 + } 7232 + 7233 + if (!(conn->le_features[1] & HCI_LE_PHY_CODED)) { 7234 + conn->le_tx_def_phys &= ~HCI_LE_SET_PHY_CODED; 7235 + conn->le_rx_def_phys &= ~HCI_LE_SET_PHY_CODED; 7236 + } 7237 + } 7238 7238 7239 7239 if (conn->state == BT_CONFIG) { 7240 7240 __u8 status;