Skip to content

Commit 79116ac

Browse files
committed
Merge tag 'for-net-2025-08-15' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - hci_conn: Fix running bis_cleanup for hci_conn->type PA_LINK - hci_conn: Fix not cleaning up Broadcaster/Broadcast Source - hci_core: Fix using {cis,bis}_capable for current settings - hci_core: Fix using ll_privacy_capable for current settings - hci_core: Fix not accounting for BIS/CIS/PA links separately - hci_conn: do return error from hci_enhanced_setup_sync() - hci_event: fix MTU for BN == 0 in CIS Established - hci_sync: Fix scan state after PA Sync has been established - hci_sync: Avoid adding default advertising on startup - hci_sync: Prevent unintended PA sync when SID is 0xFF - ISO: Fix getname not returning broadcast fields - btmtk: Fix wait_on_bit_timeout interruption during shutdown - btnxpuart: Uses threaded IRQ for host wakeup handling * tag 'for-net-2025-08-15' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: hci_core: Fix not accounting for BIS/CIS/PA links separately Bluetooth: btnxpuart: Uses threaded IRQ for host wakeup handling Bluetooth: hci_conn: do return error from hci_enhanced_setup_sync() Bluetooth: hci_event: fix MTU for BN == 0 in CIS Established Bluetooth: hci_sync: Prevent unintended PA sync when SID is 0xFF Bluetooth: hci_core: Fix using ll_privacy_capable for current settings Bluetooth: hci_core: Fix using {cis,bis}_capable for current settings Bluetooth: btmtk: Fix wait_on_bit_timeout interruption during shutdown Bluetooth: hci_conn: Fix not cleaning up Broadcaster/Broadcast Source Bluetooth: hci_conn: Fix running bis_cleanup for hci_conn->type PA_LINK Bluetooth: ISO: Fix getname not returning broadcast fields Bluetooth: hci_sync: Fix scan state after PA Sync has been established Bluetooth: hci_sync: Avoid adding default advertising on startup ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 0894731 + 9d4b01a commit 79116ac

File tree

9 files changed

+99
-49
lines changed

9 files changed

+99
-49
lines changed

drivers/bluetooth/btmtk.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,7 @@ static int btmtk_usb_hci_wmt_sync(struct hci_dev *hdev,
642642
* WMT command.
643643
*/
644644
err = wait_on_bit_timeout(&data->flags, BTMTK_TX_WAIT_VND_EVT,
645-
TASK_INTERRUPTIBLE, HCI_INIT_TIMEOUT);
646-
if (err == -EINTR) {
647-
bt_dev_err(hdev, "Execution of wmt command interrupted");
648-
clear_bit(BTMTK_TX_WAIT_VND_EVT, &data->flags);
649-
goto err_free_wc;
650-
}
645+
TASK_UNINTERRUPTIBLE, HCI_INIT_TIMEOUT);
651646

652647
if (err) {
653648
bt_dev_err(hdev, "Execution of wmt command timed out");

drivers/bluetooth/btnxpuart.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,10 @@ static int ps_setup(struct hci_dev *hdev)
543543
}
544544

545545
if (psdata->wakeup_source) {
546-
ret = devm_request_irq(&serdev->dev, psdata->irq_handler,
547-
ps_host_wakeup_irq_handler,
548-
IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
549-
dev_name(&serdev->dev), nxpdev);
546+
ret = devm_request_threaded_irq(&serdev->dev, psdata->irq_handler,
547+
NULL, ps_host_wakeup_irq_handler,
548+
IRQF_ONESHOT,
549+
dev_name(&serdev->dev), nxpdev);
550550
if (ret)
551551
bt_dev_info(hdev, "error setting wakeup IRQ handler, ignoring\n");
552552
disable_irq(psdata->irq_handler);

include/net/bluetooth/bluetooth.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static inline void sco_exit(void)
647647
#if IS_ENABLED(CONFIG_BT_LE)
648648
int iso_init(void);
649649
int iso_exit(void);
650-
bool iso_enabled(void);
650+
bool iso_inited(void);
651651
#else
652652
static inline int iso_init(void)
653653
{
@@ -659,7 +659,7 @@ static inline int iso_exit(void)
659659
return 0;
660660
}
661661

662-
static inline bool iso_enabled(void)
662+
static inline bool iso_inited(void)
663663
{
664664
return false;
665665
}

include/net/bluetooth/hci_core.h

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ struct hci_conn_hash {
129129
struct list_head list;
130130
unsigned int acl_num;
131131
unsigned int sco_num;
132-
unsigned int iso_num;
132+
unsigned int cis_num;
133+
unsigned int bis_num;
134+
unsigned int pa_num;
133135
unsigned int le_num;
134136
unsigned int le_num_peripheral;
135137
};
@@ -1014,9 +1016,13 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
10141016
h->sco_num++;
10151017
break;
10161018
case CIS_LINK:
1019+
h->cis_num++;
1020+
break;
10171021
case BIS_LINK:
1022+
h->bis_num++;
1023+
break;
10181024
case PA_LINK:
1019-
h->iso_num++;
1025+
h->pa_num++;
10201026
break;
10211027
}
10221028
}
@@ -1042,9 +1048,13 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
10421048
h->sco_num--;
10431049
break;
10441050
case CIS_LINK:
1051+
h->cis_num--;
1052+
break;
10451053
case BIS_LINK:
1054+
h->bis_num--;
1055+
break;
10461056
case PA_LINK:
1047-
h->iso_num--;
1057+
h->pa_num--;
10481058
break;
10491059
}
10501060
}
@@ -1061,9 +1071,11 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
10611071
case ESCO_LINK:
10621072
return h->sco_num;
10631073
case CIS_LINK:
1074+
return h->cis_num;
10641075
case BIS_LINK:
1076+
return h->bis_num;
10651077
case PA_LINK:
1066-
return h->iso_num;
1078+
return h->pa_num;
10671079
default:
10681080
return 0;
10691081
}
@@ -1073,7 +1085,15 @@ static inline unsigned int hci_conn_count(struct hci_dev *hdev)
10731085
{
10741086
struct hci_conn_hash *c = &hdev->conn_hash;
10751087

1076-
return c->acl_num + c->sco_num + c->le_num + c->iso_num;
1088+
return c->acl_num + c->sco_num + c->le_num + c->cis_num + c->bis_num +
1089+
c->pa_num;
1090+
}
1091+
1092+
static inline unsigned int hci_iso_count(struct hci_dev *hdev)
1093+
{
1094+
struct hci_conn_hash *c = &hdev->conn_hash;
1095+
1096+
return c->cis_num + c->bis_num;
10771097
}
10781098

10791099
static inline bool hci_conn_valid(struct hci_dev *hdev, struct hci_conn *conn)
@@ -1915,6 +1935,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19151935
!hci_dev_test_flag(dev, HCI_RPA_EXPIRED))
19161936
#define adv_rpa_valid(adv) (bacmp(&adv->random_addr, BDADDR_ANY) && \
19171937
!adv->rpa_expired)
1938+
#define le_enabled(dev) (lmp_le_capable(dev) && \
1939+
hci_dev_test_flag(dev, HCI_LE_ENABLED))
19181940

19191941
#define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \
19201942
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M))
@@ -1932,6 +1954,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19321954
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
19331955

19341956
#define ll_privacy_capable(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY)
1957+
#define ll_privacy_enabled(dev) (le_enabled(dev) && ll_privacy_capable(dev))
19351958

19361959
#define privacy_mode_capable(dev) (ll_privacy_capable(dev) && \
19371960
((dev)->commands[39] & 0x04))
@@ -1981,14 +2004,23 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19812004

19822005
/* CIS Master/Slave and BIS support */
19832006
#define iso_capable(dev) (cis_capable(dev) || bis_capable(dev))
2007+
#define iso_enabled(dev) (le_enabled(dev) && iso_capable(dev))
19842008
#define cis_capable(dev) \
19852009
(cis_central_capable(dev) || cis_peripheral_capable(dev))
2010+
#define cis_enabled(dev) (le_enabled(dev) && cis_capable(dev))
19862011
#define cis_central_capable(dev) \
19872012
((dev)->le_features[3] & HCI_LE_CIS_CENTRAL)
2013+
#define cis_central_enabled(dev) \
2014+
(le_enabled(dev) && cis_central_capable(dev))
19882015
#define cis_peripheral_capable(dev) \
19892016
((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL)
2017+
#define cis_peripheral_enabled(dev) \
2018+
(le_enabled(dev) && cis_peripheral_capable(dev))
19902019
#define bis_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_BROADCASTER)
1991-
#define sync_recv_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
2020+
#define bis_enabled(dev) (le_enabled(dev) && bis_capable(dev))
2021+
#define sync_recv_capable(dev) \
2022+
((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
2023+
#define sync_recv_enabled(dev) (le_enabled(dev) && sync_recv_capable(dev))
19922024

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

net/bluetooth/hci_conn.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)
339339
case BT_CODEC_TRANSPARENT:
340340
if (!find_next_esco_param(conn, esco_param_msbc,
341341
ARRAY_SIZE(esco_param_msbc)))
342-
return false;
342+
return -EINVAL;
343+
343344
param = &esco_param_msbc[conn->attempt - 1];
344345
cp.tx_coding_format.id = 0x03;
345346
cp.rx_coding_format.id = 0x03;
@@ -830,7 +831,17 @@ static void bis_cleanup(struct hci_conn *conn)
830831
/* Check if ISO connection is a BIS and terminate advertising
831832
* set and BIG if there are no other connections using it.
832833
*/
833-
bis = hci_conn_hash_lookup_big(hdev, conn->iso_qos.bcast.big);
834+
bis = hci_conn_hash_lookup_big_state(hdev,
835+
conn->iso_qos.bcast.big,
836+
BT_CONNECTED,
837+
HCI_ROLE_MASTER);
838+
if (bis)
839+
return;
840+
841+
bis = hci_conn_hash_lookup_big_state(hdev,
842+
conn->iso_qos.bcast.big,
843+
BT_CONNECT,
844+
HCI_ROLE_MASTER);
834845
if (bis)
835846
return;
836847

@@ -2249,7 +2260,7 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
22492260
* the start periodic advertising and create BIG commands have
22502261
* been queued
22512262
*/
2252-
hci_conn_hash_list_state(hdev, bis_mark_per_adv, PA_LINK,
2263+
hci_conn_hash_list_state(hdev, bis_mark_per_adv, BIS_LINK,
22532264
BT_BOUND, &data);
22542265

22552266
/* Queue start periodic advertising and create BIG */

net/bluetooth/hci_event.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6745,8 +6745,8 @@ static void hci_le_cis_established_evt(struct hci_dev *hdev, void *data,
67456745
qos->ucast.out.latency =
67466746
DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency),
67476747
1000);
6748-
qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu);
6749-
qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu);
6748+
qos->ucast.in.sdu = ev->c_bn ? le16_to_cpu(ev->c_mtu) : 0;
6749+
qos->ucast.out.sdu = ev->p_bn ? le16_to_cpu(ev->p_mtu) : 0;
67506750
qos->ucast.in.phy = ev->c_phy;
67516751
qos->ucast.out.phy = ev->p_phy;
67526752
break;
@@ -6760,8 +6760,8 @@ static void hci_le_cis_established_evt(struct hci_dev *hdev, void *data,
67606760
qos->ucast.in.latency =
67616761
DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency),
67626762
1000);
6763-
qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu);
6764-
qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu);
6763+
qos->ucast.out.sdu = ev->c_bn ? le16_to_cpu(ev->c_mtu) : 0;
6764+
qos->ucast.in.sdu = ev->p_bn ? le16_to_cpu(ev->p_mtu) : 0;
67656765
qos->ucast.out.phy = ev->c_phy;
67666766
qos->ucast.in.phy = ev->p_phy;
67676767
break;
@@ -6957,9 +6957,14 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,
69576957
continue;
69586958
}
69596959

6960-
if (ev->status != 0x42)
6960+
if (ev->status != 0x42) {
69616961
/* Mark PA sync as established */
69626962
set_bit(HCI_CONN_PA_SYNC, &bis->flags);
6963+
/* Reset cleanup callback of PA Sync so it doesn't
6964+
* terminate the sync when deleting the connection.
6965+
*/
6966+
conn->cleanup = NULL;
6967+
}
69636968

69646969
bis->sync_handle = conn->sync_handle;
69656970
bis->iso_qos.bcast.big = ev->handle;

net/bluetooth/hci_sync.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,7 +3344,7 @@ static int hci_powered_update_adv_sync(struct hci_dev *hdev)
33443344
* advertising data. This also applies to the case
33453345
* where BR/EDR was toggled during the AUTO_OFF phase.
33463346
*/
3347-
if (hci_dev_test_flag(hdev, HCI_ADVERTISING) ||
3347+
if (hci_dev_test_flag(hdev, HCI_ADVERTISING) &&
33483348
list_empty(&hdev->adv_instances)) {
33493349
if (ext_adv_capable(hdev)) {
33503350
err = hci_setup_ext_adv_instance_sync(hdev, 0x00);
@@ -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);
@@ -6985,8 +6985,6 @@ static void create_pa_complete(struct hci_dev *hdev, void *data, int err)
69856985

69866986
hci_dev_lock(hdev);
69876987

6988-
hci_dev_clear_flag(hdev, HCI_PA_SYNC);
6989-
69906988
if (!hci_conn_valid(hdev, conn))
69916989
clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags);
69926990

@@ -7047,10 +7045,13 @@ static int hci_le_pa_create_sync(struct hci_dev *hdev, void *data)
70477045
/* SID has not been set listen for HCI_EV_LE_EXT_ADV_REPORT to update
70487046
* it.
70497047
*/
7050-
if (conn->sid == HCI_SID_INVALID)
7051-
__hci_cmd_sync_status_sk(hdev, HCI_OP_NOP, 0, NULL,
7052-
HCI_EV_LE_EXT_ADV_REPORT,
7053-
conn->conn_timeout, NULL);
7048+
if (conn->sid == HCI_SID_INVALID) {
7049+
err = __hci_cmd_sync_status_sk(hdev, HCI_OP_NOP, 0, NULL,
7050+
HCI_EV_LE_EXT_ADV_REPORT,
7051+
conn->conn_timeout, NULL);
7052+
if (err == -ETIMEDOUT)
7053+
goto done;
7054+
}
70547055

70557056
memset(&cp, 0, sizeof(cp));
70567057
cp.options = qos->bcast.options;
@@ -7080,6 +7081,12 @@ static int hci_le_pa_create_sync(struct hci_dev *hdev, void *data)
70807081
__hci_cmd_sync_status(hdev, HCI_OP_LE_PA_CREATE_SYNC_CANCEL,
70817082
0, NULL, HCI_CMD_TIMEOUT);
70827083

7084+
done:
7085+
hci_dev_clear_flag(hdev, HCI_PA_SYNC);
7086+
7087+
/* Update passive scan since HCI_PA_SYNC flag has been cleared */
7088+
hci_update_passive_scan_sync(hdev);
7089+
70837090
return err;
70847091
}
70857092

net/bluetooth/iso.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ static int iso_sock_getname(struct socket *sock, struct sockaddr *addr,
13471347
bacpy(&sa->iso_bdaddr, &iso_pi(sk)->dst);
13481348
sa->iso_bdaddr_type = iso_pi(sk)->dst_type;
13491349

1350-
if (hcon && hcon->type == BIS_LINK) {
1350+
if (hcon && (hcon->type == BIS_LINK || hcon->type == PA_LINK)) {
13511351
sa->iso_bc->bc_sid = iso_pi(sk)->bc_sid;
13521352
sa->iso_bc->bc_num_bis = iso_pi(sk)->bc_num_bis;
13531353
memcpy(sa->iso_bc->bc_bis, iso_pi(sk)->bc_bis,
@@ -2483,11 +2483,11 @@ static const struct net_proto_family iso_sock_family_ops = {
24832483
.create = iso_sock_create,
24842484
};
24852485

2486-
static bool iso_inited;
2486+
static bool inited;
24872487

2488-
bool iso_enabled(void)
2488+
bool iso_inited(void)
24892489
{
2490-
return iso_inited;
2490+
return inited;
24912491
}
24922492

24932493
int iso_init(void)
@@ -2496,7 +2496,7 @@ int iso_init(void)
24962496

24972497
BUILD_BUG_ON(sizeof(struct sockaddr_iso) > sizeof(struct sockaddr));
24982498

2499-
if (iso_inited)
2499+
if (inited)
25002500
return -EALREADY;
25012501

25022502
err = proto_register(&iso_proto, 0);
@@ -2524,7 +2524,7 @@ int iso_init(void)
25242524
iso_debugfs = debugfs_create_file("iso", 0444, bt_debugfs,
25252525
NULL, &iso_debugfs_fops);
25262526

2527-
iso_inited = true;
2527+
inited = true;
25282528

25292529
return 0;
25302530

@@ -2535,7 +2535,7 @@ int iso_init(void)
25352535

25362536
int iso_exit(void)
25372537
{
2538-
if (!iso_inited)
2538+
if (!inited)
25392539
return -EALREADY;
25402540

25412541
bt_procfs_cleanup(&init_net, "iso");
@@ -2549,7 +2549,7 @@ int iso_exit(void)
25492549

25502550
proto_unregister(&iso_proto);
25512551

2552-
iso_inited = false;
2552+
inited = false;
25532553

25542554
return 0;
25552555
}

net/bluetooth/mgmt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -922,19 +922,19 @@ 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

937-
if (ll_privacy_capable(hdev))
937+
if (ll_privacy_enabled(hdev))
938938
settings |= MGMT_SETTING_LL_PRIVACY;
939939

940940
return settings;
@@ -4513,7 +4513,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
45134513
}
45144514

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

0 commit comments

Comments
 (0)