diff mbox series

[v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend

Message ID 6675f56fc8b0910f17ec506d534cf5330ff04733.1660177086.git.objelf@gmail.com (mailing list archive)
State Accepted
Commit 177978b2942624bb1dd826a892ab4a6a400f5715
Headers show
Series [v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/subjectprefix success PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/buildkernel32 success Build Kernel32 PASS
tedd_an/incremental_build success Pass
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 494, Passed: 494 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 10, Passed: 10 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Sean Wang Aug. 11, 2022, 12:49 a.m. UTC
From: Sean Wang <sean.wang@mediatek.com>

WMT cmd/event doesn't follow up the generic HCI cmd/event handling, it
needs constantly polling control pipe until the host received the WMT
event, thus, we should require to specifically acquire PM counter on the
USB to prevent the interface from entering auto suspended while WMT
cmd/event in progress.

Fixes: a1c49c434e15 ("Bluetooth: btusb: Add protocol support for MediaTek
 MT7668U USB devices")
Co-developed-by: Jing Cai <jing.cai@mediatek.com>
Signed-off-by: Jing Cai <jing.cai@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v2:
1. move usb_autopm_[get, put]_interface to btusb_mtk_hci_wmt_sync whenever
wmt cmd is invoked.
2. add the explanation why we needed the specific
usb_autopm_[get, put]_interface there.

v3: correct the version and there is no logic changed
v4: fix GitLint fail due to Title exceeds max length
v5: rebase to fix patches does not apply
---
 drivers/bluetooth/btusb.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

bluez.test.bot@gmail.com Aug. 11, 2022, 2:55 a.m. UTC | #1
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=666728

---Test result---

Test Summary:
CheckPatch                    PASS      1.09 seconds
GitLint                       PASS      0.51 seconds
SubjectPrefix                 PASS      0.40 seconds
BuildKernel                   PASS      32.92 seconds
BuildKernel32                 PASS      28.25 seconds
Incremental Build with patchesPASS      40.43 seconds
TestRunner: Setup             PASS      476.67 seconds
TestRunner: l2cap-tester      PASS      16.82 seconds
TestRunner: bnep-tester       PASS      6.04 seconds
TestRunner: mgmt-tester       PASS      99.54 seconds
TestRunner: rfcomm-tester     PASS      9.47 seconds
TestRunner: sco-tester        PASS      9.19 seconds
TestRunner: smp-tester        PASS      9.17 seconds
TestRunner: userchan-tester   PASS      6.30 seconds



---
Regards,
Linux Bluetooth
Sean Wang Aug. 31, 2022, 11:15 p.m. UTC | #2
Hi Luiz,

If the patch looks good to you, could you help apply the patch to
bluetooth.git? It can fix the issue present in the stable kernel, I
would like to backport it earlier once it appears in the Linus tree.

Sean

On Wed, Aug 10, 2022 at 5:59 PM <sean.wang@mediatek.com> wrote:
>
> From: Sean Wang <sean.wang@mediatek.com>
>
> WMT cmd/event doesn't follow up the generic HCI cmd/event handling, it
> needs constantly polling control pipe until the host received the WMT
> event, thus, we should require to specifically acquire PM counter on the
> USB to prevent the interface from entering auto suspended while WMT
> cmd/event in progress.
>
> Fixes: a1c49c434e15 ("Bluetooth: btusb: Add protocol support for MediaTek
>  MT7668U USB devices")
> Co-developed-by: Jing Cai <jing.cai@mediatek.com>
> Signed-off-by: Jing Cai <jing.cai@mediatek.com>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v2:
> 1. move usb_autopm_[get, put]_interface to btusb_mtk_hci_wmt_sync whenever
> wmt cmd is invoked.
> 2. add the explanation why we needed the specific
> usb_autopm_[get, put]_interface there.
>
> v3: correct the version and there is no logic changed
> v4: fix GitLint fail due to Title exceeds max length
> v5: rebase to fix patches does not apply
> ---
>  drivers/bluetooth/btusb.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 30dd443f395f..70d61bb4a053 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -2480,15 +2480,29 @@ static int btusb_mtk_hci_wmt_sync(struct hci_dev *hdev,
>
>         set_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags);
>
> +       /* WMT cmd/event doesn't follow up the generic HCI cmd/event handling,
> +        * it needs constantly polling control pipe until the host received the
> +        * WMT event, thus, we should require to specifically acquire PM counter
> +        * on the USB to prevent the interface from entering auto suspended
> +        * while WMT cmd/event in progress.
> +        */
> +       err = usb_autopm_get_interface(data->intf);
> +       if (err < 0)
> +               goto err_free_wc;
> +
>         err = __hci_cmd_send(hdev, 0xfc6f, hlen, wc);
>
>         if (err < 0) {
>                 clear_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags);
> +               usb_autopm_put_interface(data->intf);
>                 goto err_free_wc;
>         }
>
>         /* Submit control IN URB on demand to process the WMT event */
>         err = btusb_mtk_submit_wmt_recv_urb(hdev);
> +
> +       usb_autopm_put_interface(data->intf);
> +
>         if (err < 0)
>                 goto err_free_wc;
>
> --
> 2.25.1
>
patchwork-bot+bluetooth@kernel.org Aug. 31, 2022, 11:30 p.m. UTC | #3
Hello:

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

On Thu, 11 Aug 2022 08:49:07 +0800 you wrote:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> WMT cmd/event doesn't follow up the generic HCI cmd/event handling, it
> needs constantly polling control pipe until the host received the WMT
> event, thus, we should require to specifically acquire PM counter on the
> USB to prevent the interface from entering auto suspended while WMT
> cmd/event in progress.
> 
> [...]

Here is the summary with links:
  - [v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend
    https://git.kernel.org/bluetooth/bluetooth-next/c/177978b29426

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 30dd443f395f..70d61bb4a053 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2480,15 +2480,29 @@  static int btusb_mtk_hci_wmt_sync(struct hci_dev *hdev,
 
 	set_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags);
 
+	/* WMT cmd/event doesn't follow up the generic HCI cmd/event handling,
+	 * it needs constantly polling control pipe until the host received the
+	 * WMT event, thus, we should require to specifically acquire PM counter
+	 * on the USB to prevent the interface from entering auto suspended
+	 * while WMT cmd/event in progress.
+	 */
+	err = usb_autopm_get_interface(data->intf);
+	if (err < 0)
+		goto err_free_wc;
+
 	err = __hci_cmd_send(hdev, 0xfc6f, hlen, wc);
 
 	if (err < 0) {
 		clear_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags);
+		usb_autopm_put_interface(data->intf);
 		goto err_free_wc;
 	}
 
 	/* Submit control IN URB on demand to process the WMT event */
 	err = btusb_mtk_submit_wmt_recv_urb(hdev);
+
+	usb_autopm_put_interface(data->intf);
+
 	if (err < 0)
 		goto err_free_wc;