public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btnxpuart: Fix baudrate reset on remove
@ 2025-02-26 15:13 Loic Poulain
  2025-02-26 15:33 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Loic Poulain @ 2025-02-26 15:13 UTC (permalink / raw)
  To: neeraj.sanjaykale, marcel; +Cc: amitkumar.karwar, linux-bluetooth, Loic Poulain

Trying to reset the baudrate from device remove callback does not
work if HCI dev is down and not running, causing the next device
probing to fail, as host/controller baudrates are then out-of-sync.

To prevent this issue, we ensure the controller's baudrate is always
reset to its initial value in the shutdown callback, during the hdev
close procedure. That guarantees subsequent open procedure to succeed,
regardless of any device removal/binding in between. This also means
we want to reconfigure the baudrate in the next hdev open procedure
via the setup() callback (HCI_QUIRK_NON_PERSISTENT_SETUP required).

In case of removal when the hdev is up and running, we have to call
the shutdown procedure explicitly before unregistering the hdev.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/bluetooth/btnxpuart.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index fc313559c2aa..b1344a9a8925 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1274,6 +1274,9 @@ static int nxp_shutdown(struct hci_dev *hdev)
 			set_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state);
 		}
 		kfree_skb(skb);
+	} else if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) {
+		nxpdev->new_baudrate = nxpdev->fw_init_baudrate;
+		nxp_set_baudrate_cmd(hdev, NULL);
 	}
 
 	return 0;
@@ -1578,6 +1581,8 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 	hdev->wakeup = nxp_wakeup;
 	SET_HCIDEV_DEV(hdev, &serdev->dev);
 
+	set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+
 	if (hci_register_dev(hdev) < 0) {
 		dev_err(&serdev->dev, "Can't register HCI device\n");
 		goto probe_fail;
@@ -1603,16 +1608,15 @@ static void nxp_serdev_remove(struct serdev_device *serdev)
 		clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state);
 		wake_up_interruptible(&nxpdev->check_boot_sign_wait_q);
 		wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q);
-	} else {
-		/* Restore FW baudrate to fw_init_baudrate if changed.
-		 * This will ensure FW baudrate is in sync with
-		 * driver baudrate in case this driver is re-inserted.
+	}
+
+	if (test_bit(HCI_RUNNING, &hdev->flags)) {
+		/* Ensure shutdown callback is executed before unregistering, so
+		 * that baudrate is reset to initial value.
 		 */
-		if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) {
-			nxpdev->new_baudrate = nxpdev->fw_init_baudrate;
-			nxp_set_baudrate_cmd(hdev, NULL);
-		}
+		nxp_shutdown(hdev);
 	}
+
 	ps_cleanup(nxpdev);
 	hci_unregister_dev(hdev);
 	hci_free_dev(hdev);
-- 
2.34.1


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

* RE: Bluetooth: btnxpuart: Fix baudrate reset on remove
  2025-02-26 15:13 [PATCH] Bluetooth: btnxpuart: Fix baudrate reset on remove Loic Poulain
@ 2025-02-26 15:33 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2025-02-26 15:33 UTC (permalink / raw)
  To: linux-bluetooth, loic.poulain

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

---Test result---

Test Summary:
CheckPatch                    PENDING   0.27 seconds
GitLint                       PENDING   0.20 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      24.33 seconds
CheckAllWarning               PASS      26.82 seconds
CheckSparse                   PASS      30.28 seconds
BuildKernel32                 PASS      24.12 seconds
TestRunnerSetup               PASS      430.20 seconds
TestRunner_l2cap-tester       PASS      21.45 seconds
TestRunner_iso-tester         PASS      30.40 seconds
TestRunner_bnep-tester        PASS      4.82 seconds
TestRunner_mgmt-tester        FAIL      123.70 seconds
TestRunner_rfcomm-tester      PASS      7.96 seconds
TestRunner_sco-tester         PASS      9.64 seconds
TestRunner_ioctl-tester       PASS      8.34 seconds
TestRunner_mesh-tester        FAIL      6.37 seconds
TestRunner_smp-tester         PASS      7.23 seconds
TestRunner_userchan-tester    PASS      5.03 seconds
IncrementalBuild              PENDING   0.85 seconds

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

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

##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 482 (98.4%), Failed: 4, Not Run: 4

Failed Test Cases
LL Privacy - Add Device 3 (AL is full)               Failed       0.214 seconds
LL Privacy - Set Flags 3 (2 Devices to RL)           Failed       0.198 seconds
LL Privacy - Start Discovery 1 (Disable RL)          Failed       0.183 seconds
LL Privacy - Set Device Flag 1 (Device Privacy)      Failed       0.162 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 2                               Failed       0.115 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2025-02-26 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 15:13 [PATCH] Bluetooth: btnxpuart: Fix baudrate reset on remove Loic Poulain
2025-02-26 15:33 ` bluez.test.bot

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