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

Bluetooth: hci_core: Fix using {cis,bis}_capable for current settings

{cis,bis}_capable only indicates the controller supports the feature
since it doesn't check that LE is enabled so it shall not be used for
current setting, instead this introduces {cis,bis}_enabled macros that
can be used to indicate that these features are currently enabled.

Fixes: 26afbd826ee3 ("Bluetooth: Add initial implementation of CIS connections")
Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Fixes: ae7533613133 ("Bluetooth: Check for ISO support in controller")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+28 -17
+2 -2
include/net/bluetooth/bluetooth.h
··· 647 647 #if IS_ENABLED(CONFIG_BT_LE) 648 648 int iso_init(void); 649 649 int iso_exit(void); 650 - bool iso_enabled(void); 650 + bool iso_inited(void); 651 651 #else 652 652 static inline int iso_init(void) 653 653 { ··· 659 659 return 0; 660 660 } 661 661 662 - static inline bool iso_enabled(void) 662 + static inline bool iso_inited(void) 663 663 { 664 664 return false; 665 665 }
+12 -1
include/net/bluetooth/hci_core.h
··· 1915 1915 !hci_dev_test_flag(dev, HCI_RPA_EXPIRED)) 1916 1916 #define adv_rpa_valid(adv) (bacmp(&adv->random_addr, BDADDR_ANY) && \ 1917 1917 !adv->rpa_expired) 1918 + #define le_enabled(dev) (lmp_le_capable(dev) && \ 1919 + hci_dev_test_flag(dev, HCI_LE_ENABLED)) 1918 1920 1919 1921 #define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \ 1920 1922 ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M)) ··· 1983 1981 1984 1982 /* CIS Master/Slave and BIS support */ 1985 1983 #define iso_capable(dev) (cis_capable(dev) || bis_capable(dev)) 1984 + #define iso_enabled(dev) (le_enabled(dev) && iso_capable(dev)) 1986 1985 #define cis_capable(dev) \ 1987 1986 (cis_central_capable(dev) || cis_peripheral_capable(dev)) 1987 + #define cis_enabled(dev) (le_enabled(dev) && cis_capable(dev)) 1988 1988 #define cis_central_capable(dev) \ 1989 1989 ((dev)->le_features[3] & HCI_LE_CIS_CENTRAL) 1990 + #define cis_central_enabled(dev) \ 1991 + (le_enabled(dev) && cis_central_capable(dev)) 1990 1992 #define cis_peripheral_capable(dev) \ 1991 1993 ((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL) 1994 + #define cis_peripheral_enabled(dev) \ 1995 + (le_enabled(dev) && cis_peripheral_capable(dev)) 1992 1996 #define bis_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_BROADCASTER) 1993 - #define sync_recv_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER) 1997 + #define bis_enabled(dev) (le_enabled(dev) && bis_capable(dev)) 1998 + #define sync_recv_capable(dev) \ 1999 + ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER) 2000 + #define sync_recv_enabled(dev) (le_enabled(dev) && sync_recv_capable(dev)) 1994 2001 1995 2002 #define mws_transport_config_capable(dev) (((dev)->commands[30] & 0x08) && \ 1996 2003 (!hci_test_quirk((dev), HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG)))
+2 -2
net/bluetooth/hci_sync.c
··· 4531 4531 { 4532 4532 struct hci_cp_le_set_host_feature cp; 4533 4533 4534 - if (!cis_capable(hdev)) 4534 + if (!iso_capable(hdev)) 4535 4535 return 0; 4536 4536 4537 4537 memset(&cp, 0, sizeof(cp)); 4538 4538 4539 4539 /* Connected Isochronous Channels (Host Support) */ 4540 4540 cp.bit_number = 32; 4541 - cp.bit_value = 1; 4541 + cp.bit_value = iso_enabled(hdev) ? 0x01 : 0x00; 4542 4542 4543 4543 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_HOST_FEATURE, 4544 4544 sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+7 -7
net/bluetooth/iso.c
··· 2483 2483 .create = iso_sock_create, 2484 2484 }; 2485 2485 2486 - static bool iso_inited; 2486 + static bool inited; 2487 2487 2488 - bool iso_enabled(void) 2488 + bool iso_inited(void) 2489 2489 { 2490 - return iso_inited; 2490 + return inited; 2491 2491 } 2492 2492 2493 2493 int iso_init(void) ··· 2496 2496 2497 2497 BUILD_BUG_ON(sizeof(struct sockaddr_iso) > sizeof(struct sockaddr)); 2498 2498 2499 - if (iso_inited) 2499 + if (inited) 2500 2500 return -EALREADY; 2501 2501 2502 2502 err = proto_register(&iso_proto, 0); ··· 2524 2524 iso_debugfs = debugfs_create_file("iso", 0444, bt_debugfs, 2525 2525 NULL, &iso_debugfs_fops); 2526 2526 2527 - iso_inited = true; 2527 + inited = true; 2528 2528 2529 2529 return 0; 2530 2530 ··· 2535 2535 2536 2536 int iso_exit(void) 2537 2537 { 2538 - if (!iso_inited) 2538 + if (!inited) 2539 2539 return -EALREADY; 2540 2540 2541 2541 bt_procfs_cleanup(&init_net, "iso"); ··· 2549 2549 2550 2550 proto_unregister(&iso_proto); 2551 2551 2552 - iso_inited = false; 2552 + inited = false; 2553 2553 2554 2554 return 0; 2555 2555 }
+5 -5
net/bluetooth/mgmt.c
··· 922 922 if (hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED)) 923 923 settings |= MGMT_SETTING_WIDEBAND_SPEECH; 924 924 925 - if (cis_central_capable(hdev)) 925 + if (cis_central_enabled(hdev)) 926 926 settings |= MGMT_SETTING_CIS_CENTRAL; 927 927 928 - if (cis_peripheral_capable(hdev)) 928 + if (cis_peripheral_enabled(hdev)) 929 929 settings |= MGMT_SETTING_CIS_PERIPHERAL; 930 930 931 - if (bis_capable(hdev)) 931 + if (bis_enabled(hdev)) 932 932 settings |= MGMT_SETTING_ISO_BROADCASTER; 933 933 934 - if (sync_recv_capable(hdev)) 934 + if (sync_recv_enabled(hdev)) 935 935 settings |= MGMT_SETTING_ISO_SYNC_RECEIVER; 936 936 937 937 if (ll_privacy_capable(hdev)) ··· 4513 4513 } 4514 4514 4515 4515 if (IS_ENABLED(CONFIG_BT_LE)) { 4516 - flags = iso_enabled() ? BIT(0) : 0; 4516 + flags = iso_inited() ? BIT(0) : 0; 4517 4517 memcpy(rp->features[idx].uuid, iso_socket_uuid, 16); 4518 4518 rp->features[idx].flags = cpu_to_le32(flags); 4519 4519 idx++;