public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync
@ 2026-03-05 13:50 Michael Grzeschik
  2026-03-05 14:20 ` Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Grzeschik @ 2026-03-05 13:50 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, kernel, Michael Grzeschik

While introducing hci_le_create_conn_sync the functionality
of hci_connect_le was ported to hci_le_create_conn_sync including
the disable of the scan before starting the connection.

When this code was run non synchronously the immediate call that was
setting the flag HCI_LE_SCAN_INTERRUPTED had an impact. Since the
completion handler for the LE_SCAN_DISABLE was not immediately called.
In the completion handler of the LE_SCAN_DISABLE event, this flag is
checked to set the state of the hdev to DISCOVERY_STOPPED.

With the synchronised approach the later setting of the
HCI_LE_SCAN_INTERRUPTED flag has not the same effect. The completion
handler would immediately fire in the LE_SCAN_DISABLE call, check for
the flag, which is then not yet set and do nothing.

To fix this issue and make the function call work as before, we move the
setting of the flag HCI_LE_SCAN_INTERRUPTED before disabling the scan.

Fixes: Bluetooth: hci_sync: Add hci_le_create_conn_sync ('8e8b92ee60de5341e9db83c11f75a525e555e2b3')
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 net/bluetooth/hci_sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 121dbc8208ec231210505135187e769028c17483..3166914b0d6ce3e56ced2f9a7914427296d38c48 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6627,8 +6627,8 @@ static int hci_le_create_conn_sync(struct hci_dev *hdev, void *data)
 	 * state.
 	 */
 	if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
-		hci_scan_disable_sync(hdev);
 		hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
+		hci_scan_disable_sync(hdev);
 	}
 
 	/* Update random address, but set require_privacy to false so

---
base-commit: c107785c7e8dbabd1c18301a1c362544b5786282
change-id: 20260305-bluetooth-fixes-b2c85a0aeb2a

Best regards,
-- 
Michael Grzeschik <m.grzeschik@pengutronix.de>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync
  2026-03-05 13:50 [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync Michael Grzeschik
@ 2026-03-05 14:20 ` Luiz Augusto von Dentz
  2026-03-05 14:21 ` bluez.test.bot
  2026-03-05 15:50 ` [PATCH] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2026-03-05 14:20 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel,
	kernel

Hi Michael,

On Thu, Mar 5, 2026 at 8:51 AM Michael Grzeschik
<m.grzeschik@pengutronix.de> wrote:
>
> While introducing hci_le_create_conn_sync the functionality
> of hci_connect_le was ported to hci_le_create_conn_sync including
> the disable of the scan before starting the connection.
>
> When this code was run non synchronously the immediate call that was
> setting the flag HCI_LE_SCAN_INTERRUPTED had an impact. Since the
> completion handler for the LE_SCAN_DISABLE was not immediately called.
> In the completion handler of the LE_SCAN_DISABLE event, this flag is
> checked to set the state of the hdev to DISCOVERY_STOPPED.
>
> With the synchronised approach the later setting of the
> HCI_LE_SCAN_INTERRUPTED flag has not the same effect. The completion
> handler would immediately fire in the LE_SCAN_DISABLE call, check for
> the flag, which is then not yet set and do nothing.
>
> To fix this issue and make the function call work as before, we move the
> setting of the flag HCI_LE_SCAN_INTERRUPTED before disabling the scan.
>
> Fixes: Bluetooth: hci_sync: Add hci_le_create_conn_sync ('8e8b92ee60de5341e9db83c11f75a525e555e2b3')
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  net/bluetooth/hci_sync.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index 121dbc8208ec231210505135187e769028c17483..3166914b0d6ce3e56ced2f9a7914427296d38c48 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -6627,8 +6627,8 @@ static int hci_le_create_conn_sync(struct hci_dev *hdev, void *data)
>          * state.
>          */
>         if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
> -               hci_scan_disable_sync(hdev);
>                 hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
> +               hci_scan_disable_sync(hdev);
>         }

The change is probably correct but now I wonder if we should even keep
the HCI_LE_SCAN_INTERRUPTED because with the cmd sync we could
actually do wait for the scan to be disabled so we might as well do
hci_discovery_set_state(hdev, DISCOVERY_STOPPED) after
hci_scan_disable_sync completes, anyway I can make the change on top
of yours since I don't think we want to backport such a change since
it won't be a one liner like the above.

>         /* Update random address, but set require_privacy to false so
>
> ---
> base-commit: c107785c7e8dbabd1c18301a1c362544b5786282
> change-id: 20260305-bluetooth-fixes-b2c85a0aeb2a
>
> Best regards,
> --
> Michael Grzeschik <m.grzeschik@pengutronix.de>
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: net: bluetooth: hci_sync: fix hci_le_create_conn_sync
  2026-03-05 13:50 [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync Michael Grzeschik
  2026-03-05 14:20 ` Luiz Augusto von Dentz
@ 2026-03-05 14:21 ` bluez.test.bot
  2026-03-05 15:50 ` [PATCH] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-03-05 14:21 UTC (permalink / raw)
  To: linux-bluetooth, m.grzeschik

[-- Attachment #1: Type: text/plain, Size: 2760 bytes --]

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

---Test result---

Test Summary:
CheckPatch                    PENDING   0.41 seconds
GitLint                       PENDING   0.31 seconds
SubjectPrefix                 FAIL      0.41 seconds
BuildKernel                   PASS      26.64 seconds
CheckAllWarning               PASS      29.31 seconds
CheckSparse                   PASS      33.22 seconds
BuildKernel32                 PASS      25.95 seconds
TestRunnerSetup               PASS      565.68 seconds
TestRunner_l2cap-tester       PASS      29.13 seconds
TestRunner_iso-tester         PASS      80.05 seconds
TestRunner_bnep-tester        PASS      6.92 seconds
TestRunner_mgmt-tester        FAIL      117.73 seconds
TestRunner_rfcomm-tester      PASS      9.52 seconds
TestRunner_sco-tester         FAIL      14.71 seconds
TestRunner_ioctl-tester       PASS      10.29 seconds
TestRunner_mesh-tester        FAIL      12.46 seconds
TestRunner_smp-tester         PASS      8.86 seconds
TestRunner_userchan-tester    PASS      6.72 seconds
IncrementalBuild              PENDING   0.85 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: SubjectPrefix - FAIL
Desc: Check subject contains "Bluetooth" prefix
Output:
"Bluetooth: " prefix is not specified in the subject
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.116 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    2.763 seconds
Mesh - Send cancel - 2                               Timed out    1.993 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync
  2026-03-05 13:50 [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync Michael Grzeschik
  2026-03-05 14:20 ` Luiz Augusto von Dentz
  2026-03-05 14:21 ` bluez.test.bot
@ 2026-03-05 15:50 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2026-03-05 15:50 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: marcel, johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
	kernel

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 05 Mar 2026 14:50:52 +0100 you wrote:
> While introducing hci_le_create_conn_sync the functionality
> of hci_connect_le was ported to hci_le_create_conn_sync including
> the disable of the scan before starting the connection.
> 
> When this code was run non synchronously the immediate call that was
> setting the flag HCI_LE_SCAN_INTERRUPTED had an impact. Since the
> completion handler for the LE_SCAN_DISABLE was not immediately called.
> In the completion handler of the LE_SCAN_DISABLE event, this flag is
> checked to set the state of the hdev to DISCOVERY_STOPPED.
> 
> [...]

Here is the summary with links:
  - net: bluetooth: hci_sync: fix hci_le_create_conn_sync
    https://git.kernel.org/bluetooth/bluetooth-next/c/ae93951e4081

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-05 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 13:50 [PATCH] net: bluetooth: hci_sync: fix hci_le_create_conn_sync Michael Grzeschik
2026-03-05 14:20 ` Luiz Augusto von Dentz
2026-03-05 14:21 ` bluez.test.bot
2026-03-05 15:50 ` [PATCH] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox