Skip to contentSkip to conversation

Bluetooth: hci_sync: Fix suspending with wrong filter policy

PATCH Applied Luiz Augusto von Dentz 4 participants 4 messages Jul 16, 2024 – Jul 17, 2024

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 Bluetooth: hci_sync: Fix suspending with wrong filter policy

From: Luiz Augusto von Dentz <[email protected]>

When suspending the scan filter policy cannot be 0x00 (no acceptlist) since that means the host has to process every advertisement report waking up the system, so this attempts to check if hdev is marked as suspended and if the resulting filter policy would be 0x00 (no acceptlist) then skip passive scanning if thre no devices in the acceptlist otherwise reset the filter policy to 0x01 so the acceptlist is used since the devices programmed there can still wakeup be system.

Fixes 182ee45da083 ("Bluetooth: hci_sync: Rework hci_suspend_notifier")
---
 net/bluetooth/hci_sync.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
net/bluetooth/hci_sync.c +21 -0
index cd2ed16da8a4..a31d39a821f4 100644
@@ -2976,6 +2976,27 @@ static int hci_passive_scan_sync(struct hci_dev *hdev)
 	 */
 	filter_policy = hci_update_accept_list_sync(hdev);
 
+	/* If suspended and filter_policy set to 0x00 (no acceptlist) then
+	 * passive scanning cannot be started since that would require the host
+	 * to be woken up to process the reports.
+	 */
+	if (hdev->suspended && !filter_policy) {
+		/* Check if accept list is empty then there is no need to scan
+		 * while suspended.
+		 */
+		if (list_empty(&hdev->le_accept_list))
+			return 0;
+
+		/* If there are devices is the accept_list that means some
+		 * devices could not be programmed which in non-suspended case
+		 * means filter_policy needs to be set to 0x00 so the host needs
+		 * to filter, but since this is treating suspended case we
+		 * can ignore device needing host to filter to allow devices in
+		 * the acceptlist to be able to wakeup the system.
+		 */
+		filter_policy = 0x01;
+	}
+
 	/* When the controller is using random resolvable addresses and
 	 * with that having LE privacy enabled, then controllers with
 	 * Extended Scanner Filter Policies support can now enable support
Signature · 1 line
2.45.2
#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/project/bluetooth/list/?series=871711

---Test result---

Test Summary:

CheckPatch                    PASS      0.51 seconds
GitLint                       PASS      0.21 seconds
SubjectPrefix                 PASS      0.07 seconds
BuildKernel                   PASS      29.74 seconds
CheckAllWarning               PASS      32.75 seconds
CheckSparse                   PASS      38.10 seconds
CheckSmatch                   PASS      102.56 seconds
BuildKernel32                 PASS      28.75 seconds
TestRunnerSetup               PASS      528.01 seconds
TestRunner_l2cap-tester       PASS      22.05 seconds
TestRunner_iso-tester         PASS      35.14 seconds
TestRunner_bnep-tester        PASS      4.83 seconds
TestRunner_mgmt-tester        FAIL      112.32 seconds
TestRunner_rfcomm-tester      PASS      7.47 seconds
TestRunner_sco-tester         PASS      15.07 seconds
TestRunner_ioctl-tester       PASS      7.93 seconds
TestRunner_mesh-tester        PASS      6.00 seconds
TestRunner_smp-tester         PASS      11.27 seconds
TestRunner_userchan-tester    PASS      5.00 seconds
IncrementalBuild              PASS      28.15 seconds

Details
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 492, Passed: 489 (99.4%), Failed: 1, Not Run: 2

Failed Test Cases
LL Privacy - Add Device 7 (AL is full) Failed 0.192 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz

Dear Luiz,

Thank you for the patch. Four minor comments.

Am 16.07.24 um 17:01 schrieb Luiz Augusto von Dentz:

Quoted 7 lines

From: Luiz Augusto von Dentz <[email protected]>

When suspending the scan filter policy cannot be 0x00 (no acceptlist) since that means the host has to process every advertisement report waking up the system, so this attempts to check if hdev is marked as suspended and if the resulting filter policy would be 0x00 (no acceptlist) then skip passive scanning if thre no devices in the

there are

Quoted 2 lines

acceptlist otherwise reset the filter policy to 0x01 so the acceptlist is used since the devices programmed there can still wakeup be system.

wake the system up?

Quoted 16 lines
Fixes 182ee45da083 ("Bluetooth: hci_sync: Rework hci_suspend_notifier")
---
  net/bluetooth/hci_sync.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
net/bluetooth/hci_sync.c +2 -0
index cd2ed16da8a4..a31d39a821f4 100644
@@ -2976,6 +2976,27 @@ static int hci_passive_scan_sync(struct hci_dev *hdev)
  	 */
  	filter_policy = hci_update_accept_list_sync(hdev);
 
+	/* If suspended and filter_policy set to 0x00 (no acceptlist) then
+	 * passive scanning cannot be started since that would require the host

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

Quoted 10 lines
net/bluetooth/hci_sync.c +10 -0
+	 * to be woken up to process the reports.
+	 */
+	if (hdev->suspended && !filter_policy) {
+		/* Check if accept list is empty then there is no need to scan
+		 * while suspended.
+		 */
+		if (list_empty(&hdev->le_accept_list))
+			return 0;
+
+		/* If there are devices is the accept_list that means some

i*n* the

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

Quoted 5 lines
net/bluetooth/hci_sync.c +5 -0
+		 * devices could not be programmed which in non-suspended case
+		 * means filter_policy needs to be set to 0x00 so the host needs
+		 * to filter, but since this is treating suspended case we
+		 * can ignore device needing host to filter to allow devices in
+		 * the acceptlist to be able to wakeup the system.

to wake up

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

Quoted 7 lines
net/bluetooth/hci_sync.c +4 -0
+		 */
+		filter_policy = 0x01;
+	}
+
  	/* When the controller is using random resolvable addresses and
  	 * with that having LE privacy enabled, then controllers with
  	 * Extended Scanner Filter Policies support can now enable support

Kind regards,

Paul

#3 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 11 lines · On Tue, 16 Jul 2024 11:01:26 -0400 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

When suspending the scan filter policy cannot be 0x00 (no acceptlist) since that means the host has to process every advertisement report waking up the system, so this attempts to check if hdev is marked as suspended and if the resulting filter policy would be 0x00 (no acceptlist) then skip passive scanning if thre no devices in the acceptlist otherwise reset the filter policy to 0x01 so the acceptlist is used since the devices programmed there can still wakeup be system.

[...]

Here is the summary with links:
- [v2] Bluetooth: hci_sync: Fix suspending with wrong filter policy

    https://git.kernel.org/bluetooth/bluetooth-next/c/54dd4796336d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html