linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend
@ 2022-08-11  0:49 sean.wang
  2022-08-31 23:15 ` Sean Wang
  2022-08-31 23:30 ` patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: sean.wang @ 2022-08-11  0:49 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz
  Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
	Deren.Wu, km.lin, robin.chiu, Eddie.Chen, ch.yeh, posh.sun,
	ted.huang, Stella.Chang, Tom.Chou, steve.lee, jsiuda, frankgor,
	abhishekpandit, michaelfsun, mcchou, shawnku, linux-bluetooth,
	linux-mediatek, linux-kernel, Jing Cai

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



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

* Re: [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend
  2022-08-11  0:49 [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend sean.wang
@ 2022-08-31 23:15 ` Sean Wang
  2022-08-31 23:30 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Wang @ 2022-08-31 23:15 UTC (permalink / raw)
  To: luiz.dentz
  Cc: marcel, johan.hedberg, Sean Wang (王志亘),
	Soul Huang, YN Chen, Leon Yen, Eric-SY Chang, Deren Wu, KM Lin,
	Robin Chiu, Eddie.Chen, CH Yeh, Posh Sun, ted.huang,
	Stella Chang, Tom.Chou, steve.lee, jsiuda, frankgor,
	abhishekpandit, michaelfsun, mcchou, shawnku, linux-bluetooth,
	moderated list:ARM/Mediatek SoC support, lkml, Jing Cai

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
>


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

* Re: [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend
  2022-08-11  0:49 [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend sean.wang
  2022-08-31 23:15 ` Sean Wang
@ 2022-08-31 23:30 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2022-08-31 23:30 UTC (permalink / raw)
  To: Sean Wang
  Cc: marcel, johan.hedberg, luiz.dentz, Soul.Huang, YN.Chen, Leon.Yen,
	Eric-SY.Chang, Deren.Wu, km.lin, robin.chiu, Eddie.Chen, ch.yeh,
	posh.sun, ted.huang, Stella.Chang, Tom.Chou, steve.lee, jsiuda,
	frankgor, abhishekpandit, michaelfsun, mcchou, shawnku,
	linux-bluetooth, linux-mediatek, linux-kernel, jing.cai

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!
-- 
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-08-31 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11  0:49 [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend sean.wang
2022-08-31 23:15 ` Sean Wang
2022-08-31 23:30 ` 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).