2023-11-02 09:28:52

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v1] Bluetooth: hci_sync: Fix logical error when enter active mode

it seems HCI_CONN_POWER_SAVE stands for active mode based on
hci_mode_change_evt(), but hci_conn_enter_active_mode() does not take
this flag rightly and failed to exit sniff mode potentially, it is
fixed by this change.

Signed-off-by: Zijun Hu <[email protected]>
---
net/bluetooth/hci_conn.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 929d0e313db2..302fb5eaca55 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -2582,7 +2582,12 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
if (conn->mode != HCI_CM_SNIFF)
goto timer;

- if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active)
+ if (test_bit(HCI_CONN_POWER_SAVE, &conn->flags)) {
+ BT_DBG("%s: hcon %p is already active mode", __func__, conn);
+ goto timer;
+ }
+
+ if (!force_active)
goto timer;

if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
--
The Qualcomm Innovation Center


2023-11-02 09:51:13

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1] Bluetooth: hci_sync: Fix logical error when enter active mode

On 11/2/2023 5:28 PM, Zijun Hu wrote:
> it seems HCI_CONN_POWER_SAVE stands for active mode based on
> hci_mode_change_evt(), but hci_conn_enter_active_mode() does not take
> this flag rightly and failed to exit sniff mode potentially, it is
> fixed by this change.
>
> Signed-off-by: Zijun Hu <[email protected]>
> ---
> net/bluetooth/hci_conn.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 929d0e313db2..302fb5eaca55 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -2582,7 +2582,12 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
> if (conn->mode != HCI_CM_SNIFF)
> goto timer;
>
> - if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active)
> + if (test_bit(HCI_CONN_POWER_SAVE, &conn->flags)) {
> + BT_DBG("%s: hcon %p is already active mode", __func__, conn);
> + goto timer;
> + }
> +
> + if (!force_active)
> goto timer;
>
> if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {

not sure what HCI_CONN_POWER_SAVE stands for. or change as below ?

@@ -4596,9 +4596,9 @@ static void hci_mode_change_evt(struct hci_dev *hdev, void *data,
if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND,
&conn->flags)) {
if (conn->mode == HCI_CM_ACTIVE)
- set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
- else
clear_bit(HCI_CONN_POWER_SAVE, &conn->flags);
+ else
+ set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
}

2023-11-02 10:03:47

by bluez.test.bot

[permalink] [raw]
Subject: RE: [v1] Bluetooth: hci_sync: Fix logical error when enter active mode

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=798359

---Test result---

Test Summary:
CheckPatch PASS 0.74 seconds
GitLint PASS 0.37 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 35.71 seconds
CheckAllWarning PASS 38.60 seconds
CheckSparse PASS 44.43 seconds
CheckSmatch PASS 117.98 seconds
BuildKernel32 PASS 34.32 seconds
TestRunnerSetup PASS 534.12 seconds
TestRunner_l2cap-tester PASS 31.30 seconds
TestRunner_iso-tester PASS 54.92 seconds
TestRunner_bnep-tester PASS 10.59 seconds
TestRunner_mgmt-tester PASS 219.08 seconds
TestRunner_rfcomm-tester PASS 16.41 seconds
TestRunner_sco-tester PASS 19.58 seconds
TestRunner_ioctl-tester PASS 18.43 seconds
TestRunner_mesh-tester PASS 14.08 seconds
TestRunner_smp-tester PASS 14.42 seconds
TestRunner_userchan-tester PASS 11.14 seconds
IncrementalBuild PASS 33.39 seconds



---
Regards,
Linux Bluetooth

2023-11-03 07:05:40

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v2 1/1] Bluetooth: hci_event: Correct power save marking logic

HCI_CONN_POWER_SAVE should stand for non active mode, but
hci_mode_change_evt() wrongly set this flag, it is corrected
by this change.

Signed-off-by: Zijun Hu <[email protected]>
---
net/bluetooth/hci_event.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 5b6fd625fc09..95a582bffc32 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -4590,9 +4590,9 @@ static void hci_mode_change_evt(struct hci_dev *hdev, void *data,
if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND,
&conn->flags)) {
if (conn->mode == HCI_CM_ACTIVE)
- set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
- else
clear_bit(HCI_CONN_POWER_SAVE, &conn->flags);
+ else
+ set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
}

if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
--
The Qualcomm Innovation Center

2023-11-03 07:36:53

by bluez.test.bot

[permalink] [raw]
Subject: RE: [v2,1/1] Bluetooth: hci_event: Correct power save marking logic

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=798561

---Test result---

Test Summary:
CheckPatch PASS 0.54 seconds
GitLint PASS 0.24 seconds
SubjectPrefix PASS 0.07 seconds
BuildKernel PASS 33.40 seconds
CheckAllWarning PASS 36.70 seconds
CheckSparse WARNING 42.29 seconds
CheckSmatch WARNING 117.28 seconds
BuildKernel32 PASS 33.35 seconds
TestRunnerSetup PASS 511.11 seconds
TestRunner_l2cap-tester PASS 29.59 seconds
TestRunner_iso-tester PASS 51.61 seconds
TestRunner_bnep-tester PASS 10.03 seconds
TestRunner_mgmt-tester PASS 211.20 seconds
TestRunner_rfcomm-tester PASS 15.13 seconds
TestRunner_sco-tester PASS 18.46 seconds
TestRunner_ioctl-tester PASS 17.30 seconds
TestRunner_mesh-tester PASS 12.58 seconds
TestRunner_smp-tester PASS 13.43 seconds
TestRunner_userchan-tester PASS 10.34 seconds
IncrementalBuild PASS 31.13 seconds

Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):


---
Regards,
Linux Bluetooth