linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Bluetooth: btusb: Introduce generic USB reset
@ 2022-10-06  9:09 Archie Pusaka
  2022-10-06 10:25 ` [v3] " bluez.test.bot
  2022-10-07 19:40 ` [PATCH v3] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Archie Pusaka @ 2022-10-06  9:09 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz, Marcel Holtmann
  Cc: CrosBT Upstreaming, Archie Pusaka, Abhishek Pandit-Subedi,
	Ying Hsu, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Johan Hedberg, Paolo Abeni, linux-kernel, netdev

From: Archie Pusaka <apusaka@chromium.org>

On cmd_timeout with no reset_gpio, reset the USB port as a last
resort.

This patch changes the behavior of btusb_intel_cmd_timeout and
btusb_rtl_cmd_timeout.

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@google.com>
Reviewed-by: Ying Hsu <yinghsu@chromium.org>

---
Tested by not cancelling cmd_timer when handing hci event.
Before the patch:
ERR kernel: [  716.929206] Bluetooth: hci_cmd_timeout() hci0: command 0x0000 tx timeout
ERR kernel: [  716.929218] Bluetooth: btusb_rtl_cmd_timeout() hci0: No gpio to reset Realtek device, ignoring

After the patch:
ERR kernel: [  225.270048] Bluetooth: hci_cmd_timeout() hci0: command 0x0000 tx timeout
ERR kernel: [  225.270060] Bluetooth: btusb_rtl_cmd_timeout() hci0: Resetting usb device.
INFO kernel: [  225.386613] usb 3-3: reset full-speed USB device number 3 using xhci_hcd

Changes in v3:
* introduce hdev->reset to override the generic reset function

Changes in v2:
* Update commit message

 drivers/bluetooth/btusb.c        | 35 +++++++++++++++++++++++---------
 include/net/bluetooth/hci_core.h |  1 +
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 271963805a38..e6add3604214 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -696,6 +696,28 @@ struct btusb_data {
 	unsigned cmd_timeout_cnt;
 };
 
+static void btusb_reset(struct hci_dev *hdev)
+{
+	struct btusb_data *data;
+	int err;
+
+	if (hdev->reset) {
+		hdev->reset(hdev);
+		return;
+	}
+
+	data = hci_get_drvdata(hdev);
+	/* This is not an unbalanced PM reference since the device will reset */
+	err = usb_autopm_get_interface(data->intf);
+	if (err) {
+		bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err);
+		return;
+	}
+
+	bt_dev_err(hdev, "Resetting usb device.");
+	usb_queue_reset_device(data->intf);
+}
+
 static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
 {
 	struct btusb_data *data = hci_get_drvdata(hdev);
@@ -705,7 +727,7 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
 		return;
 
 	if (!reset_gpio) {
-		bt_dev_err(hdev, "No way to reset. Ignoring and continuing");
+		btusb_reset(hdev);
 		return;
 	}
 
@@ -736,7 +758,7 @@ static void btusb_rtl_cmd_timeout(struct hci_dev *hdev)
 		return;
 
 	if (!reset_gpio) {
-		bt_dev_err(hdev, "No gpio to reset Realtek device, ignoring");
+		btusb_reset(hdev);
 		return;
 	}
 
@@ -761,7 +783,6 @@ static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
 {
 	struct btusb_data *data = hci_get_drvdata(hdev);
 	struct gpio_desc *reset_gpio = data->reset_gpio;
-	int err;
 
 	if (++data->cmd_timeout_cnt < 5)
 		return;
@@ -787,13 +808,7 @@ static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
 		return;
 	}
 
-	bt_dev_err(hdev, "Multiple cmd timeouts seen. Resetting usb device.");
-	/* This is not an unbalanced PM reference since the device will reset */
-	err = usb_autopm_get_interface(data->intf);
-	if (!err)
-		usb_queue_reset_device(data->intf);
-	else
-		bt_dev_err(hdev, "Failed usb_autopm_get_interface with %d", err);
+	btusb_reset(hdev);
 }
 
 static inline void btusb_free_frags(struct btusb_data *data)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c54bc71254af..55a40f5606c3 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -659,6 +659,7 @@ struct hci_dev {
 	int (*set_diag)(struct hci_dev *hdev, bool enable);
 	int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr);
 	void (*cmd_timeout)(struct hci_dev *hdev);
+	void (*reset)(struct hci_dev *hdev);
 	bool (*wakeup)(struct hci_dev *hdev);
 	int (*set_quality_report)(struct hci_dev *hdev, bool enable);
 	int (*get_data_path_id)(struct hci_dev *hdev, __u8 *data_path);
-- 
2.38.0.rc1.362.ged0d419d3c-goog


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

* RE: [v3] Bluetooth: btusb: Introduce generic USB reset
  2022-10-06  9:09 [PATCH v3] Bluetooth: btusb: Introduce generic USB reset Archie Pusaka
@ 2022-10-06 10:25 ` bluez.test.bot
  2022-10-07 19:40 ` [PATCH v3] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2022-10-06 10:25 UTC (permalink / raw)
  To: linux-bluetooth, apusaka

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

---Test result---

Test Summary:
CheckPatch                    PASS      1.60 seconds
GitLint                       FAIL      0.75 seconds
SubjectPrefix                 PASS      0.60 seconds
BuildKernel                   PASS      46.72 seconds
BuildKernel32                 PASS      42.25 seconds
Incremental Build with patchesPASS      60.62 seconds
TestRunner: Setup             PASS      680.50 seconds
TestRunner: l2cap-tester      PASS      21.32 seconds
TestRunner: iso-tester        PASS      22.32 seconds
TestRunner: bnep-tester       PASS      8.30 seconds
TestRunner: mgmt-tester       PASS      133.38 seconds
TestRunner: rfcomm-tester     PASS      13.11 seconds
TestRunner: sco-tester        PASS      12.01 seconds
TestRunner: ioctl-tester      PASS      14.13 seconds
TestRunner: mesh-tester       PASS      10.04 seconds
TestRunner: smp-tester        PASS      12.03 seconds
TestRunner: userchan-tester   PASS      8.82 seconds

Details
##############################
Test: GitLint - FAIL - 0.75 seconds
Run gitlint with rule in .gitlint
[v3] Bluetooth: btusb: Introduce generic USB reset
18: B1 Line exceeds max length (87>80): "ERR kernel: [  716.929206] Bluetooth: hci_cmd_timeout() hci0: command 0x0000 tx timeout"
19: B1 Line exceeds max length (109>80): "ERR kernel: [  716.929218] Bluetooth: btusb_rtl_cmd_timeout() hci0: No gpio to reset Realtek device, ignoring"
22: B1 Line exceeds max length (87>80): "ERR kernel: [  225.270048] Bluetooth: hci_cmd_timeout() hci0: command 0x0000 tx timeout"
23: B1 Line exceeds max length (89>80): "ERR kernel: [  225.270060] Bluetooth: btusb_rtl_cmd_timeout() hci0: Resetting usb device."
24: B1 Line exceeds max length (88>80): "INFO kernel: [  225.386613] usb 3-3: reset full-speed USB device number 3 using xhci_hcd"




---
Regards,
Linux Bluetooth


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

* Re: [PATCH v3] Bluetooth: btusb: Introduce generic USB reset
  2022-10-06  9:09 [PATCH v3] Bluetooth: btusb: Introduce generic USB reset Archie Pusaka
  2022-10-06 10:25 ` [v3] " bluez.test.bot
@ 2022-10-07 19:40 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2022-10-07 19:40 UTC (permalink / raw)
  To: Archie Pusaka
  Cc: linux-bluetooth, luiz.dentz, marcel,
	chromeos-bluetooth-upstreaming, apusaka, abhishekpandit, yinghsu,
	davem, edumazet, kuba, johan.hedberg, pabeni, linux-kernel,
	netdev

Hello:

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

On Thu,  6 Oct 2022 17:09:31 +0800 you wrote:
> From: Archie Pusaka <apusaka@chromium.org>
> 
> On cmd_timeout with no reset_gpio, reset the USB port as a last
> resort.
> 
> This patch changes the behavior of btusb_intel_cmd_timeout and
> btusb_rtl_cmd_timeout.
> 
> [...]

Here is the summary with links:
  - [v3] Bluetooth: btusb: Introduce generic USB reset
    https://git.kernel.org/bluetooth/bluetooth-next/c/b9c747ff82b4

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:[~2022-10-07 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06  9:09 [PATCH v3] Bluetooth: btusb: Introduce generic USB reset Archie Pusaka
2022-10-06 10:25 ` [v3] " bluez.test.bot
2022-10-07 19:40 ` [PATCH v3] " 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;
as well as URLs for NNTP newsgroup(s).