diff mbox series

[v1] Bluetooth: hci_sync: Fix logical error when enter active mode

Message ID 1698917302-28018-1-git-send-email-quic_zijuhu@quicinc.com (mailing list archive)
State New, archived
Headers show
Series [v1] Bluetooth: hci_sync: Fix logical error when enter active mode | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/BuildKernel success BuildKernel PASS
tedd_an/CheckAllWarning success CheckAllWarning PASS
tedd_an/CheckSparse success CheckSparse PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/BuildKernel32 success BuildKernel32 PASS
tedd_an/TestRunnerSetup success TestRunnerSetup PASS
tedd_an/TestRunner_l2cap-tester success TestRunner PASS
tedd_an/TestRunner_iso-tester success TestRunner PASS
tedd_an/TestRunner_bnep-tester success TestRunner PASS
tedd_an/TestRunner_mgmt-tester success TestRunner PASS
tedd_an/TestRunner_rfcomm-tester success TestRunner PASS
tedd_an/TestRunner_sco-tester success TestRunner PASS
tedd_an/TestRunner_ioctl-tester success TestRunner PASS
tedd_an/TestRunner_mesh-tester success TestRunner PASS
tedd_an/TestRunner_smp-tester success TestRunner PASS
tedd_an/TestRunner_userchan-tester success TestRunner PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

quic_zijuhu Nov. 2, 2023, 9:28 a.m. UTC
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 <quic_zijuhu@quicinc.com>
---
 net/bluetooth/hci_conn.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

quic_zijuhu Nov. 2, 2023, 9:50 a.m. UTC | #1
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 <quic_zijuhu@quicinc.com>
> ---
>  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);
                }
bluez.test.bot@gmail.com Nov. 2, 2023, 10:03 a.m. UTC | #2
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
diff mbox series

Patch

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)) {