Skip to content

Commit 5c472a3

Browse files
Vudentzgregkh
authored andcommitted
Bluetooth: hci_core: Fix using {cis,bis}_capable for current settings
[ Upstream commit 709788b ] {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: 26afbd8 ("Bluetooth: Add initial implementation of CIS connections") Fixes: eca0ae4 ("Bluetooth: Add initial implementation of BIS connections") Fixes: ae75336 ("Bluetooth: Check for ISO support in controller") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2b979ef commit 5c472a3

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

include/net/bluetooth/bluetooth.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static inline void sco_exit(void)
638638
#if IS_ENABLED(CONFIG_BT_LE)
639639
int iso_init(void);
640640
int iso_exit(void);
641-
bool iso_enabled(void);
641+
bool iso_inited(void);
642642
#else
643643
static inline int iso_init(void)
644644
{
@@ -650,7 +650,7 @@ static inline int iso_exit(void)
650650
return 0;
651651
}
652652

653-
static inline bool iso_enabled(void)
653+
static inline bool iso_inited(void)
654654
{
655655
return false;
656656
}

include/net/bluetooth/hci_core.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19321932
!hci_dev_test_flag(dev, HCI_RPA_EXPIRED))
19331933
#define adv_rpa_valid(adv) (bacmp(&adv->random_addr, BDADDR_ANY) && \
19341934
!adv->rpa_expired)
1935+
#define le_enabled(dev) (lmp_le_capable(dev) && \
1936+
hci_dev_test_flag(dev, HCI_LE_ENABLED))
19351937

19361938
#define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \
19371939
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M))
@@ -1998,14 +2000,23 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19982000

19992001
/* CIS Master/Slave and BIS support */
20002002
#define iso_capable(dev) (cis_capable(dev) || bis_capable(dev))
2003+
#define iso_enabled(dev) (le_enabled(dev) && iso_capable(dev))
20012004
#define cis_capable(dev) \
20022005
(cis_central_capable(dev) || cis_peripheral_capable(dev))
2006+
#define cis_enabled(dev) (le_enabled(dev) && cis_capable(dev))
20032007
#define cis_central_capable(dev) \
20042008
((dev)->le_features[3] & HCI_LE_CIS_CENTRAL)
2009+
#define cis_central_enabled(dev) \
2010+
(le_enabled(dev) && cis_central_capable(dev))
20052011
#define cis_peripheral_capable(dev) \
20062012
((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL)
2013+
#define cis_peripheral_enabled(dev) \
2014+
(le_enabled(dev) && cis_peripheral_capable(dev))
20072015
#define bis_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_BROADCASTER)
2008-
#define sync_recv_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
2016+
#define bis_enabled(dev) (le_enabled(dev) && bis_capable(dev))
2017+
#define sync_recv_capable(dev) \
2018+
((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
2019+
#define sync_recv_enabled(dev) (le_enabled(dev) && sync_recv_capable(dev))
20092020

20102021
#define mws_transport_config_capable(dev) (((dev)->commands[30] & 0x08) && \
20112022
(!hci_test_quirk((dev), HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG)))

net/bluetooth/hci_sync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4531,14 +4531,14 @@ static int hci_le_set_host_feature_sync(struct hci_dev *hdev)
45314531
{
45324532
struct hci_cp_le_set_host_feature cp;
45334533

4534-
if (!cis_capable(hdev))
4534+
if (!iso_capable(hdev))
45354535
return 0;
45364536

45374537
memset(&cp, 0, sizeof(cp));
45384538

45394539
/* Connected Isochronous Channels (Host Support) */
45404540
cp.bit_number = 32;
4541-
cp.bit_value = 1;
4541+
cp.bit_value = iso_enabled(hdev) ? 0x01 : 0x00;
45424542

45434543
return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_HOST_FEATURE,
45444544
sizeof(cp), &cp, HCI_CMD_TIMEOUT);

net/bluetooth/iso.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,11 +2455,11 @@ static const struct net_proto_family iso_sock_family_ops = {
24552455
.create = iso_sock_create,
24562456
};
24572457

2458-
static bool iso_inited;
2458+
static bool inited;
24592459

2460-
bool iso_enabled(void)
2460+
bool iso_inited(void)
24612461
{
2462-
return iso_inited;
2462+
return inited;
24632463
}
24642464

24652465
int iso_init(void)
@@ -2468,7 +2468,7 @@ int iso_init(void)
24682468

24692469
BUILD_BUG_ON(sizeof(struct sockaddr_iso) > sizeof(struct sockaddr));
24702470

2471-
if (iso_inited)
2471+
if (inited)
24722472
return -EALREADY;
24732473

24742474
err = proto_register(&iso_proto, 0);
@@ -2496,7 +2496,7 @@ int iso_init(void)
24962496
iso_debugfs = debugfs_create_file("iso", 0444, bt_debugfs,
24972497
NULL, &iso_debugfs_fops);
24982498

2499-
iso_inited = true;
2499+
inited = true;
25002500

25012501
return 0;
25022502

@@ -2507,7 +2507,7 @@ int iso_init(void)
25072507

25082508
int iso_exit(void)
25092509
{
2510-
if (!iso_inited)
2510+
if (!inited)
25112511
return -EALREADY;
25122512

25132513
bt_procfs_cleanup(&init_net, "iso");
@@ -2521,7 +2521,7 @@ int iso_exit(void)
25212521

25222522
proto_unregister(&iso_proto);
25232523

2524-
iso_inited = false;
2524+
inited = false;
25252525

25262526
return 0;
25272527
}

net/bluetooth/mgmt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -922,16 +922,16 @@ static u32 get_current_settings(struct hci_dev *hdev)
922922
if (hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED))
923923
settings |= MGMT_SETTING_WIDEBAND_SPEECH;
924924

925-
if (cis_central_capable(hdev))
925+
if (cis_central_enabled(hdev))
926926
settings |= MGMT_SETTING_CIS_CENTRAL;
927927

928-
if (cis_peripheral_capable(hdev))
928+
if (cis_peripheral_enabled(hdev))
929929
settings |= MGMT_SETTING_CIS_PERIPHERAL;
930930

931-
if (bis_capable(hdev))
931+
if (bis_enabled(hdev))
932932
settings |= MGMT_SETTING_ISO_BROADCASTER;
933933

934-
if (sync_recv_capable(hdev))
934+
if (sync_recv_enabled(hdev))
935935
settings |= MGMT_SETTING_ISO_SYNC_RECEIVER;
936936

937937
if (ll_privacy_capable(hdev))
@@ -4512,7 +4512,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
45124512
}
45134513

45144514
if (IS_ENABLED(CONFIG_BT_LE)) {
4515-
flags = iso_enabled() ? BIT(0) : 0;
4515+
flags = iso_inited() ? BIT(0) : 0;
45164516
memcpy(rp->features[idx].uuid, iso_socket_uuid, 16);
45174517
rp->features[idx].flags = cpu_to_le32(flags);
45184518
idx++;

0 commit comments

Comments
 (0)