All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Fix failed to send func ctrl for MediaTek devices.
@ 2021-10-25 15:03 ` mark-yw.chen
  0 siblings, 0 replies; 2+ messages in thread
From: mark-yw.chen @ 2021-10-25 15:03 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mark-yw.chen, will-cy.lee, linux-bluetooth, linux-mediatek, linux-kernel

From: "mark-yw.chen" <mark-yw.chen@mediatek.com>

* Use usb_autopm_get_interface() and usb_autopm_put_interface()
  in btusb_mtk_shutdown(), it could send func ctrl after enabling
  autosuspend.

Bluetooth: btusb_mtk_hci_wmt_sync() hci0: Execution of wmt command timed
out
Bluetooth: btusb_mtk_shutdown() hci0: Failed to send wmt func ctrl
(-110)

Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
---
 drivers/bluetooth/btusb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 87b71740fad8..9e61395d1ff2 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2973,9 +2973,14 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
 static int btusb_mtk_shutdown(struct hci_dev *hdev)
 {
 	struct btmtk_hci_wmt_params wmt_params;
+	struct btusb_data *data = hci_get_drvdata(hdev);
 	u8 param = 0;
 	int err;
 
+	err = usb_autopm_get_interface(data->intf);
+	if (err < 0)
+		return err;
+
 	/* Disable the device */
 	wmt_params.op = BTMTK_WMT_FUNC_CTRL;
 	wmt_params.flag = 0;
@@ -2986,9 +2991,11 @@ static int btusb_mtk_shutdown(struct hci_dev *hdev)
 	err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params);
 	if (err < 0) {
 		bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err);
+		usb_autopm_put_interface(data->intf);
 		return err;
 	}
 
+	usb_autopm_put_interface(data->intf);
 	return 0;
 }
 
-- 
2.18.0


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

* [PATCH] Bluetooth: btusb: Fix failed to send func ctrl for MediaTek devices.
@ 2021-10-25 15:03 ` mark-yw.chen
  0 siblings, 0 replies; 2+ messages in thread
From: mark-yw.chen @ 2021-10-25 15:03 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mark-yw.chen, will-cy.lee, linux-bluetooth, linux-mediatek, linux-kernel

From: "mark-yw.chen" <mark-yw.chen@mediatek.com>

* Use usb_autopm_get_interface() and usb_autopm_put_interface()
  in btusb_mtk_shutdown(), it could send func ctrl after enabling
  autosuspend.

Bluetooth: btusb_mtk_hci_wmt_sync() hci0: Execution of wmt command timed
out
Bluetooth: btusb_mtk_shutdown() hci0: Failed to send wmt func ctrl
(-110)

Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
---
 drivers/bluetooth/btusb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 87b71740fad8..9e61395d1ff2 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2973,9 +2973,14 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
 static int btusb_mtk_shutdown(struct hci_dev *hdev)
 {
 	struct btmtk_hci_wmt_params wmt_params;
+	struct btusb_data *data = hci_get_drvdata(hdev);
 	u8 param = 0;
 	int err;
 
+	err = usb_autopm_get_interface(data->intf);
+	if (err < 0)
+		return err;
+
 	/* Disable the device */
 	wmt_params.op = BTMTK_WMT_FUNC_CTRL;
 	wmt_params.flag = 0;
@@ -2986,9 +2991,11 @@ static int btusb_mtk_shutdown(struct hci_dev *hdev)
 	err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params);
 	if (err < 0) {
 		bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err);
+		usb_autopm_put_interface(data->intf);
 		return err;
 	}
 
+	usb_autopm_put_interface(data->intf);
 	return 0;
 }
 
-- 
2.18.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

end of thread, other threads:[~2021-10-25 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 15:03 [PATCH] Bluetooth: btusb: Fix failed to send func ctrl for MediaTek devices mark-yw.chen
2021-10-25 15:03 ` mark-yw.chen

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.