Skip to contentSkip to conversation

Bluetooth: hci_sync: Don't filter duplicates while a PA sync is pending

PATCH In review Simon Mikuda 3 participants 4 messages Nov 22 – Nov 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_sync: Don't filter duplicates while a PA sync is pending

To sync to a broadcast, the controller needs an extended advertisement of the source after LE Periodic Advertising Create Sync, because that carries the SyncInfo. Some controllers, for example an NXP one and an Intel BE200, only use the SyncInfo of an advertisement they report to the host. With the duplicates filter on, they report a source once per scan. Passive scanning starts right before Create Sync, so when the source is reported in between, its later advertisements are filtered out and the sync waits until the host cancels it after 20 seconds:

    21:59:14.147 > LE Extended Advertising Report  50:1E:2D:9F:95:23
    21:59:14.149 < LE Periodic Advertising Create Sync
    21:59:35.131 < LE Periodic Advertising Create Sync Cancel
    21:59:35.132 > LE Periodic Advertising Sync Established
                     Status: Operation Cancelled by Host (0x44)

Turn the filter off while a PA sync is pending. The accept list limits the reports to the source being synced.

Steps to reproduce:
1. Start a broadcast on another device.
2. Join it, leave and join again, repeatedly. Rarely the sync takes more than 10 seconds, and until then there is no sound.

Fixes eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
---
 net/bluetooth/hci_sync.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/bluetooth/hci_sync.c +6 -0
index 638589f77081..88ce0ceef394 100644
@@ -3645,6 +3645,12 @@ static int hci_passive_scan_sync(struct hci_dev *hdev)
 		filter_dups = LE_SCAN_FILTER_DUP_DISABLE;
 	}
 
+	/* The controller only syncs on a report it doesn't filter as a duplicate,
+	 * and that report can come before the sync is created.
+	 */
+	if (hci_dev_test_flag(hdev, HCI_PA_SYNC))
+		filter_dups = LE_SCAN_FILTER_DUP_DISABLE;
+
 	bt_dev_dbg(hdev, "LE passive scan with acceptlist = %d", filter_policy);
 
 	return hci_start_scan_sync(hdev, LE_SCAN_PASSIVE, interval, window,

base-commit: 4fe38719e6738feaa90486e36b0790dd5d960a96

Signature · 1 line
2.43.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1218948/

---Test result---

Test Summary:

CheckPatch                    PASS      0.58 seconds
VerifyFixes                   PASS      0.11 seconds
VerifySignedoff               PASS      0.11 seconds
GitLint                       PASS      0.29 seconds
SubjectPrefix                 PASS      0.11 seconds
BuildKernel                   PASS      21.45 seconds
CheckAllWarning               PASS      24.62 seconds
CheckSparse                   PASS      26.05 seconds
BuildKernel32                 PASS      21.38 seconds
CheckKernelLLVM               PASS      22.03 seconds
TestRunnerSetup               PASS      497.75 seconds
TestRunner_l2cap-tester       PASS      14.24 seconds
TestRunner_iso-tester         PASS      11.88 seconds
TestRunner_bnep-tester        PASS      3.20 seconds
TestRunner_mgmt-tester        PASS      85.27 seconds
TestRunner_rfcomm-tester      PASS      4.44 seconds
TestRunner_sco-tester         PASS      5.49 seconds
TestRunner_ioctl-tester       PASS      4.54 seconds
TestRunner_mesh-tester        FAIL      3.45 seconds
TestRunner_smp-tester         PASS      4.37 seconds
TestRunner_userchan-tester    PASS      3.23 seconds
TestRunner_6lowpan-tester     PASS      4.40 seconds
IncrementalBuild              PASS      19.38 seconds

Details
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 2 Failed 0.023 seconds

https://github.com/bluez/bluetooth-next/pull/1193

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Simon Mikuda

Hi Simon,

Quoted 35 lines · Simon Mikuda

To sync to a broadcast, the controller needs an extended advertisement of the source after LE Periodic Advertising Create Sync, because that carries the SyncInfo. Some controllers, for example an NXP one and an Intel BE200, only use the SyncInfo of an advertisement they report to the host. With the duplicates filter on, they report a source once per scan. Passive scanning starts right before Create Sync, so when the source is reported in between, its later advertisements are filtered out and the sync waits until the host cancels it after 20 seconds:

    21:59:14.147 > LE Extended Advertising Report  50:1E:2D:9F:95:23
    21:59:14.149 < LE Periodic Advertising Create Sync
    21:59:35.131 < LE Periodic Advertising Create Sync Cancel
    21:59:35.132 > LE Periodic Advertising Sync Established
                     Status: Operation Cancelled by Host (0x44)

Turn the filter off while a PA sync is pending. The accept list limits the reports to the source being synced.

Steps to reproduce:
1. Start a broadcast on another device.
2. Join it, leave and join again, repeatedly. Rarely the sync takes more than 10 seconds, and until then there is no sound.

Fixes eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
---
 net/bluetooth/hci_sync.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/bluetooth/hci_sync.c +0 -0
index 638589f77081..88ce0ceef394 100644

net/bluetooth/hci_sync.c static int hci_passive_scan_sync(struct hci_dev *hdev) · line 3652

Quoted 8 lines
net/bluetooth/hci_sync.c +5 -0
@@ -3645,6 +3645,12 @@ static int hci_passive_scan_sync(struct hci_dev *hdev)
                filter_dups = LE_SCAN_FILTER_DUP_DISABLE;
        }
 
+       /* The controller only syncs on a report it doesn't filter as a duplicate,
+        * and that report can come before the sync is created.
+        */
+       if (hci_dev_test_flag(hdev, HCI_PA_SYNC))
+               filter_dups = LE_SCAN_FILTER_DUP_DISABLE;

We should probably check if the HCI_QUIRK_STRICT_DUPLICATE_FILTER is set though, that said hci_le_past_params_sync may have a similar problem wrt to mode but I wonder if we should really work around this or inform the hardware/firmware does have a bug, because filtering duplicates shouldn't mean treat as they never happened just don't send them to host otherwise while attempting to synchronize a BIG we maybe flooded with PA reports that have no use for the host.

Quoted 8 lines
net/bluetooth/hci_sync.c +0 -0
        bt_dev_dbg(hdev, "LE passive scan with acceptlist = %d", filter_policy);
 
        return hci_start_scan_sync(hdev, LE_SCAN_PASSIVE, interval, window,

base-commit: 4fe38719e6738feaa90486e36b0790dd5d960a96 --
2.43.0

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

Hi Luiz.

You are right this is controller bug. We will try to report it to chip vendors and see what they will reply. From now we will keep this as a HACK for broken chips.

We do not set HCI_QUIRK_STRICT_DUPLICATE_FILTER on our hw that we use.

Thanks for your support and pointers!

BR,
Simon

Quoted 63 lines · Luiz Augusto von Dentz

Hi Simon,

Quoted 34 lines · Simon Mikuda

To sync to a broadcast, the controller needs an extended advertisement of the source after LE Periodic Advertising Create Sync, because that carries the SyncInfo. Some controllers, for example an NXP one and an Intel BE200, only use the SyncInfo of an advertisement they report to the host. With the duplicates filter on, they report a source once per scan. Passive scanning starts right before Create Sync, so when the source is reported in between, its later advertisements are filtered out and the sync waits until the host cancels it after 20 seconds:

     21:59:14.147 > LE Extended Advertising Report  50:1E:2D:9F:95:23
     21:59:14.149 < LE Periodic Advertising Create Sync
     21:59:35.131 < LE Periodic Advertising Create Sync Cancel
     21:59:35.132 > LE Periodic Advertising Sync Established
                      Status: Operation Cancelled by Host (0x44)

Turn the filter off while a PA sync is pending. The accept list limits the reports to the source being synced.

Steps to reproduce:
1. Start a broadcast on another device.
2. Join it, leave and join again, repeatedly. Rarely the sync takes more than 10 seconds, and until then there is no sound.

Fixes eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
---
  net/bluetooth/hci_sync.c | 6 ++++++
  1 file changed, 6 insertions(+)
net/bluetooth/hci_sync.c +0 -0
index 638589f77081..88ce0ceef394 100644

net/bluetooth/hci_sync.c static int hci_passive_scan_sync(struct hci_dev *hdev) · line 3652

Quoted 8 lines
net/bluetooth/hci_sync.c +5 -0
@@ -3645,6 +3645,12 @@ static int hci_passive_scan_sync(struct hci_dev *hdev)
                 filter_dups = LE_SCAN_FILTER_DUP_DISABLE;
         }
 
+       /* The controller only syncs on a report it doesn't filter as a duplicate,
+        * and that report can come before the sync is created.
+        */
+       if (hci_dev_test_flag(hdev, HCI_PA_SYNC))
+               filter_dups = LE_SCAN_FILTER_DUP_DISABLE;

We should probably check if the HCI_QUIRK_STRICT_DUPLICATE_FILTER is set though, that said hci_le_past_params_sync may have a similar problem wrt to mode but I wonder if we should really work around this or inform the hardware/firmware does have a bug, because filtering duplicates shouldn't mean treat as they never happened just don't send them to host otherwise while attempting to synchronize a BIG we maybe flooded with PA reports that have no use for the host.

Quoted 8 lines
net/bluetooth/hci_sync.c +0 -0
         bt_dev_dbg(hdev, "LE passive scan with acceptlist = %d", filter_policy);
 
         return hci_start_scan_sync(hdev, LE_SCAN_PASSIVE, interval, window,

base-commit: 4fe38719e6738feaa90486e36b0790dd5d960a96 --
2.43.0