diff mbox series

[v1] Bluetooth: btmtk: Fix failed to send func ctrl for MediaTek devices.

Message ID 20241223085818.722707-1-chris.lu@mediatek.com (mailing list archive)
State Superseded
Headers show
Series [v1] Bluetooth: btmtk: Fix failed to send func ctrl for MediaTek devices. | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/BuildKernel success BuildKernel PASS
tedd_an/CheckAllWarning success CheckAllWarning PASS
tedd_an/CheckSparse success CheckSparse PASS
tedd_an/BuildKernel32 success BuildKernel32 PASS
tedd_an/TestRunnerSetup success TestRunnerSetup PASS
tedd_an/TestRunner_l2cap-tester success TestRunner PASS
tedd_an/TestRunner_iso-tester success TestRunner PASS
tedd_an/TestRunner_bnep-tester success TestRunner PASS
tedd_an/TestRunner_mgmt-tester fail TestRunner_mgmt-tester: Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
tedd_an/TestRunner_rfcomm-tester success TestRunner PASS
tedd_an/TestRunner_sco-tester success TestRunner PASS
tedd_an/TestRunner_ioctl-tester success TestRunner PASS
tedd_an/TestRunner_mesh-tester success TestRunner PASS
tedd_an/TestRunner_smp-tester success TestRunner PASS
tedd_an/TestRunner_userchan-tester success TestRunner PASS

Commit Message

Chris Lu Dec. 23, 2024, 8:58 a.m. UTC
Use usb_autopm_get_interface() and usb_autopm_put_interface()
in btmtk_usb_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: Chris Lu <chris.lu@mediatek.com>
---
 drivers/bluetooth/btmtk.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

bluez.test.bot@gmail.com Dec. 23, 2024, 9:33 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=920358

---Test result---

Test Summary:
CheckPatch                    PENDING   0.34 seconds
GitLint                       PENDING   0.27 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      24.87 seconds
CheckAllWarning               PASS      27.26 seconds
CheckSparse                   PASS      30.92 seconds
BuildKernel32                 PASS      24.68 seconds
TestRunnerSetup               PASS      442.25 seconds
TestRunner_l2cap-tester       PASS      20.60 seconds
TestRunner_iso-tester         PASS      32.16 seconds
TestRunner_bnep-tester        PASS      4.89 seconds
TestRunner_mgmt-tester        FAIL      128.16 seconds
TestRunner_rfcomm-tester      PASS      12.71 seconds
TestRunner_sco-tester         PASS      9.49 seconds
TestRunner_ioctl-tester       PASS      8.35 seconds
TestRunner_mesh-tester        PASS      5.92 seconds
TestRunner_smp-tester         PASS      6.90 seconds
TestRunner_userchan-tester    PASS      4.97 seconds
IncrementalBuild              PENDING   0.86 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: 485 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
LL Privacy - Add Device 3 (AL is full)               Failed       0.199 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Jan. 6, 2025, 8:44 p.m. UTC | #2
Hi Chris,

On Mon, Dec 23, 2024 at 3:58 AM Chris Lu <chris.lu@mediatek.com> wrote:
>
> Use usb_autopm_get_interface() and usb_autopm_put_interface()
> in btmtk_usb_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: Chris Lu <chris.lu@mediatek.com>

Missing Fixes tag, Ive been adding it myself for some time now but you
better create the practice to include it so I don't have to go find
what commit introduced btmtk_usb_shutdown to then do git log -1
--pretty=fixes and git commit --amend.

> ---
>  drivers/bluetooth/btmtk.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> index 7fd9d5ddce02..224eafc27dbe 100644
> --- a/drivers/bluetooth/btmtk.c
> +++ b/drivers/bluetooth/btmtk.c
> @@ -1472,10 +1472,15 @@ EXPORT_SYMBOL_GPL(btmtk_usb_setup);
>
>  int btmtk_usb_shutdown(struct hci_dev *hdev)
>  {
> +       struct btmtk_data *data = hci_get_priv(hdev);
>         struct btmtk_hci_wmt_params wmt_params;
>         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;
> @@ -1486,9 +1491,11 @@ int btmtk_usb_shutdown(struct hci_dev *hdev)
>         err = btmtk_usb_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;
>  }
>  EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
> --
> 2.45.2
>
Chris Lu Jan. 7, 2025, 2:47 a.m. UTC | #3
Hi Luiz,

Thanks for your reply.

On Mon, 2025-01-06 at 15:44 -0500, Luiz Augusto von Dentz wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Hi Chris,
> 
> On Mon, Dec 23, 2024 at 3:58 AM Chris Lu <chris.lu@mediatek.com>
> wrote:
> > 
> > Use usb_autopm_get_interface() and usb_autopm_put_interface()
> > in btmtk_usb_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: Chris Lu <chris.lu@mediatek.com>
> 
> Missing Fixes tag, Ive been adding it myself for some time now but
> you
> better create the practice to include it so I don't have to go find
> what commit introduced btmtk_usb_shutdown to then do git log -1
> --pretty=fixes and git commit --amend.
> 
This change was submitted by another MediaTek member around two years
ago (but it was ignored and wasn't merged at that time). We recently
found it was missed when reviewing our btusb changes and trying to
submit it again.

Anyway, I'll do another submit to add fixes tag. Thank you for the
reminder.
> > ---
> >  drivers/bluetooth/btmtk.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> > index 7fd9d5ddce02..224eafc27dbe 100644
> > --- a/drivers/bluetooth/btmtk.c
> > +++ b/drivers/bluetooth/btmtk.c
> > @@ -1472,10 +1472,15 @@ EXPORT_SYMBOL_GPL(btmtk_usb_setup);
> > 
> >  int btmtk_usb_shutdown(struct hci_dev *hdev)
> >  {
> > +       struct btmtk_data *data = hci_get_priv(hdev);
> >         struct btmtk_hci_wmt_params wmt_params;
> >         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;
> > @@ -1486,9 +1491,11 @@ int btmtk_usb_shutdown(struct hci_dev *hdev)
> >         err = btmtk_usb_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;
> >  }
> >  EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);
> > --
> > 2.45.2
> > 
> 
> 
> --
> Luiz Augusto von Dentz

Thanks,
Chris Lu
diff mbox series

Patch

diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 7fd9d5ddce02..224eafc27dbe 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -1472,10 +1472,15 @@  EXPORT_SYMBOL_GPL(btmtk_usb_setup);
 
 int btmtk_usb_shutdown(struct hci_dev *hdev)
 {
+	struct btmtk_data *data = hci_get_priv(hdev);
 	struct btmtk_hci_wmt_params wmt_params;
 	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;
@@ -1486,9 +1491,11 @@  int btmtk_usb_shutdown(struct hci_dev *hdev)
 	err = btmtk_usb_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;
 }
 EXPORT_SYMBOL_GPL(btmtk_usb_shutdown);