From: Yang Li <yang.li@amlogic.com>
To: Pauli Virtanen <pav@iki.fi>,
Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Bluetooth: hci_event: Add support for handling LE BIG Sync Lost event
Date: Thu, 26 Jun 2025 13:53:53 +0800 [thread overview]
Message-ID: <1842c694-045e-4014-9521-e95718f32037@amlogic.com> (raw)
In-Reply-To: <1306a61f39fd92565d1e292517154aa3009dbd11.camel@iki.fi>
Hi Pauli,
> [ EXTERNAL EMAIL ]
>
> Hi,
>
> ke, 2025-06-25 kello 16:42 +0800, Yang Li via B4 Relay kirjoitti:
>> From: Yang Li <yang.li@amlogic.com>
>>
>> When the BIS source stops, the controller sends an LE BIG Sync Lost
>> event (subevent 0x1E). Currently, this event is not handled, causing
>> the BIS stream to remain active in BlueZ and preventing recovery.
>>
>> Signed-off-by: Yang Li <yang.li@amlogic.com>
>> ---
>> Changes in v2:
>> - Matching the BIG handle is required when looking up a BIG connection.
>> - Use ev->reason to determine the cause of disconnection.
>> - Call hci_conn_del after hci_disconnect_cfm to remove the connection entry
>> - Delete the big connection
>> - Link to v1: https://lore.kernel.org/r/20250624-handle_big_sync_lost_event-v1-1-c32ce37dd6a5@amlogic.com
>> ---
>> include/net/bluetooth/hci.h | 6 ++++++
>> net/bluetooth/hci_event.c | 31 +++++++++++++++++++++++++++++++
>> 2 files changed, 37 insertions(+)
>>
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index 82cbd54443ac..48389a64accb 100644
>> --- a/include/net/bluetooth/hci.h
>> +++ b/include/net/bluetooth/hci.h
>> @@ -2849,6 +2849,12 @@ struct hci_evt_le_big_sync_estabilished {
>> __le16 bis[];
>> } __packed;
>>
>> +#define HCI_EVT_LE_BIG_SYNC_LOST 0x1e
>> +struct hci_evt_le_big_sync_lost {
>> + __u8 handle;
>> + __u8 reason;
>> +} __packed;
>> +
>> #define HCI_EVT_LE_BIG_INFO_ADV_REPORT 0x22
>> struct hci_evt_le_big_info_adv_report {
>> __le16 sync_handle;
>> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
>> index 66052d6aaa1d..d0b9c8dca891 100644
>> --- a/net/bluetooth/hci_event.c
>> +++ b/net/bluetooth/hci_event.c
>> @@ -7026,6 +7026,32 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,
>> hci_dev_unlock(hdev);
>> }
>>
>> +static void hci_le_big_sync_lost_evt(struct hci_dev *hdev, void *data,
>> + struct sk_buff *skb)
>> +{
>> + struct hci_evt_le_big_sync_lost *ev = data;
>> + struct hci_conn *bis, *conn;
>> +
>> + bt_dev_dbg(hdev, "big handle 0x%2.2x", ev->handle);
>> +
>> + hci_dev_lock(hdev);
>> +
>> + list_for_each_entry(bis, &hdev->conn_hash.list, list) {
> This should check bis->type == BIS_LINK too.
Will do.
>
>> + if (test_and_clear_bit(HCI_CONN_BIG_SYNC, &bis->flags) &&
>> + (bis->iso_qos.bcast.big == ev->handle)) {
>> + hci_disconn_cfm(bis, ev->reason);
>> + hci_conn_del(bis);
>> +
>> + /* Delete the big connection */
>> + conn = hci_conn_hash_lookup_pa_sync_handle(hdev, bis->sync_handle);
>> + if (conn)
>> + hci_conn_del(conn);
> Problems:
>
> - use after free
>
> - hci_conn_del() cannot be used inside list_for_each_entry()
> of the connection list
>
> - also list_for_each_entry_safe() allows deleting only the iteration
> cursor, so some restructuring above is needed
Following your suggestion, I updated the hci_le_big_sync_lost_evt function.
+static void hci_le_big_sync_lost_evt(struct hci_dev *hdev, void *data,
+ struct sk_buff *skb)
+{
+ struct hci_evt_le_big_sync_lost *ev = data;
+ struct hci_conn *bis, *conn, *n;
+
+ bt_dev_dbg(hdev, "big handle 0x%2.2x", ev->handle);
+
+ hci_dev_lock(hdev);
+
+ /* Delete the pa sync connection */
+ bis = hci_conn_hash_lookup_pa_sync_big_handle(hdev, ev->handle);
+ if (bis) {
+ conn = hci_conn_hash_lookup_pa_sync_handle(hdev,
bis->sync_handle);
+ if (conn)
+ hci_conn_del(conn);
+ }
+
+ /* Delete each bis connection */
+ list_for_each_entry_safe(bis, n, &hdev->conn_hash.list, list) {
+ if (bis->type == BIS_LINK &&
+ bis->iso_qos.bcast.big == ev->handle &&
+ test_and_clear_bit(HCI_CONN_BIG_SYNC, &bis->flags)) {
+ hci_disconn_cfm(bis, ev->reason);
+ hci_conn_del(bis);
+ }
+ }
+
+ hci_dev_unlock(hdev);
+}
>
>> + }
>> + }
>> +
>> + hci_dev_unlock(hdev);
>> +}
>> +
>> static void hci_le_big_info_adv_report_evt(struct hci_dev *hdev, void *data,
>> struct sk_buff *skb)
>> {
>> @@ -7149,6 +7175,11 @@ static const struct hci_le_ev {
>> hci_le_big_sync_established_evt,
>> sizeof(struct hci_evt_le_big_sync_estabilished),
>> HCI_MAX_EVENT_SIZE),
>> + /* [0x1e = HCI_EVT_LE_BIG_SYNC_LOST] */
>> + HCI_LE_EV_VL(HCI_EVT_LE_BIG_SYNC_LOST,
>> + hci_le_big_sync_lost_evt,
>> + sizeof(struct hci_evt_le_big_sync_lost),
>> + HCI_MAX_EVENT_SIZE),
>> /* [0x22 = HCI_EVT_LE_BIG_INFO_ADV_REPORT] */
>> HCI_LE_EV_VL(HCI_EVT_LE_BIG_INFO_ADV_REPORT,
>> hci_le_big_info_adv_report_evt,
>>
>> ---
>> base-commit: bd35cd12d915bc410c721ba28afcada16f0ebd16
>> change-id: 20250612-handle_big_sync_lost_event-4c7dc64390a2
>>
>> Best regards,
> --
> Pauli Virtanen
next prev parent reply other threads:[~2025-06-26 5:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 8:42 Yang Li via B4 Relay
2025-06-25 15:23 ` Pauli Virtanen
2025-06-26 5:53 ` Yang Li [this message]
2025-06-26 13:14 ` Luiz Augusto von Dentz
2025-06-27 11:31 ` Yang Li
2025-06-27 15:03 ` Luiz Augusto von Dentz
2025-06-30 6:14 ` Yang Li
2025-06-30 13:16 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1842c694-045e-4014-9521-e95718f32037@amlogic.com \
--to=yang.li@amlogic.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pav@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®