All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address
@ 2023-03-08 13:31 Stephan Gerhold
  2023-03-08 15:02 ` [v2,RESEND] " bluez.test.bot
  2023-03-10  0:20 ` [PATCH v2 RESEND] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Stephan Gerhold @ 2023-03-08 13:31 UTC (permalink / raw
  To: Luiz Augusto von Dentz, Marcel Holtmann, Johan Hedberg
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-arm-msm,
	linux-bluetooth, Stephan Gerhold, Paul Menzel, Stephan Gerhold

On most devices using the btqcomsmd driver (e.g. the DragonBoard 410c
and other devices based on the Qualcomm MSM8916/MSM8909/... SoCs)
the Bluetooth firmware seems to become unresponsive for a while after
setting the BD address. On recent kernel versions (at least 5.17+)
this often causes timeouts for subsequent commands, e.g. the HCI reset
sent by the Bluetooth core during initialization:

    Bluetooth: hci0: Opcode 0x c03 failed: -110

Unfortunately this behavior does not seem to be documented anywhere.
Experimentation suggests that the minimum necessary delay to avoid
the problem is ~150us. However, to be sure add a sleep for > 1ms
in case it is a bit longer on other firmware versions.

Older kernel versions are likely also affected, although perhaps with
slightly different errors or less probability. Side effects can easily
hide the issue in most cases, e.g. unrelated incoming interrupts that
cause the necessary delay.

Fixes: 1511cc750c3d ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver")
Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
---
Unmodified third(!) resend of the v2 I sent back in June last year, and
again in October and January. Any kind of feedback would be much
appreciated. This is an important bug fix! Please do let me know if I'm
sending this patch incorrectly or am doing something else wrong. :)

I originally tested this using a script that reboots repeatedly and
checks for the error. With this patch, BT shows up successfully for 100+
consecutive boots. Without this patch it usually fails after 1-5 boots
(or even always on some boards).

Changes in v2:
  - Clarify commit message: Add affected devices and kernel versions
---
 drivers/bluetooth/btqcomsmd.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
index 2acb719e596f..11c7e04bf394 100644
--- a/drivers/bluetooth/btqcomsmd.c
+++ b/drivers/bluetooth/btqcomsmd.c
@@ -122,6 +122,21 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
 	return 0;
 }
 
+static int btqcomsmd_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
+{
+	int ret;
+
+	ret = qca_set_bdaddr_rome(hdev, bdaddr);
+	if (ret)
+		return ret;
+
+	/* The firmware stops responding for a while after setting the bdaddr,
+	 * causing timeouts for subsequent commands. Sleep a bit to avoid this.
+	 */
+	usleep_range(1000, 10000);
+	return 0;
+}
+
 static int btqcomsmd_probe(struct platform_device *pdev)
 {
 	struct btqcomsmd *btq;
@@ -162,7 +177,7 @@ static int btqcomsmd_probe(struct platform_device *pdev)
 	hdev->close = btqcomsmd_close;
 	hdev->send = btqcomsmd_send;
 	hdev->setup = btqcomsmd_setup;
-	hdev->set_bdaddr = qca_set_bdaddr_rome;
+	hdev->set_bdaddr = btqcomsmd_set_bdaddr;
 
 	ret = hci_register_dev(hdev);
 	if (ret < 0)
-- 
2.30.2


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

* RE: [v2,RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address
  2023-03-08 13:31 [PATCH v2 RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address Stephan Gerhold
@ 2023-03-08 15:02 ` bluez.test.bot
  2023-03-10  0:20 ` [PATCH v2 RESEND] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-03-08 15:02 UTC (permalink / raw
  To: linux-bluetooth, stephan.gerhold

[-- Attachment #1: Type: text/plain, Size: 1420 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=727907

---Test result---

Test Summary:
CheckPatch                    PASS      0.61 seconds
GitLint                       PASS      0.28 seconds
SubjectPrefix                 PASS      0.10 seconds
BuildKernel                   PASS      30.89 seconds
CheckAllWarning               PASS      34.05 seconds
CheckSparse                   PASS      38.32 seconds
CheckSmatch                   PASS      107.32 seconds
BuildKernel32                 PASS      29.96 seconds
TestRunnerSetup               PASS      433.21 seconds
TestRunner_l2cap-tester       PASS      16.12 seconds
TestRunner_iso-tester         PASS      16.61 seconds
TestRunner_bnep-tester        PASS      5.40 seconds
TestRunner_mgmt-tester        PASS      107.58 seconds
TestRunner_rfcomm-tester      PASS      8.64 seconds
TestRunner_sco-tester         PASS      7.98 seconds
TestRunner_ioctl-tester       PASS      9.34 seconds
TestRunner_mesh-tester        PASS      6.86 seconds
TestRunner_smp-tester         PASS      7.87 seconds
TestRunner_userchan-tester    PASS      5.68 seconds
IncrementalBuild              PASS      27.86 seconds



---
Regards,
Linux Bluetooth


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

* Re: [PATCH v2 RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address
  2023-03-08 13:31 [PATCH v2 RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address Stephan Gerhold
  2023-03-08 15:02 ` [v2,RESEND] " bluez.test.bot
@ 2023-03-10  0:20 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2023-03-10  0:20 UTC (permalink / raw
  To: Stephan Gerhold
  Cc: luiz.dentz, marcel, johan.hedberg, agross, andersson,
	konrad.dybcio, linux-arm-msm, linux-bluetooth, stephan, pmenzel

Hello:

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

On Wed,  8 Mar 2023 14:31:55 +0100 you wrote:
> On most devices using the btqcomsmd driver (e.g. the DragonBoard 410c
> and other devices based on the Qualcomm MSM8916/MSM8909/... SoCs)
> the Bluetooth firmware seems to become unresponsive for a while after
> setting the BD address. On recent kernel versions (at least 5.17+)
> this often causes timeouts for subsequent commands, e.g. the HCI reset
> sent by the Bluetooth core during initialization:
> 
> [...]

Here is the summary with links:
  - [v2,RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address
    https://git.kernel.org/bluetooth/bluetooth-next/c/048379740637

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] 3+ messages in thread

end of thread, other threads:[~2023-03-10  0:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-08 13:31 [PATCH v2 RESEND] Bluetooth: btqcomsmd: Fix command timeout after setting BD address Stephan Gerhold
2023-03-08 15:02 ` [v2,RESEND] " bluez.test.bot
2023-03-10  0:20 ` [PATCH v2 RESEND] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.