From patchwork Thu Aug 11 00:49:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 12941059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04A43C00140 for ; Thu, 11 Aug 2022 01:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=J02Otlqm9jVMozONgqtzLnRRp+2ot0UG4yvdPeLI0N4=; b=RcWzvk3RUDEY08YqZhS9dcdyzq Jk310Whk8uWQhBrCrzG/MJFT+BZxdUx54417lk+Rf8mwWDrESNM45EVGC2OD9dNK7dB9wC3HUbp2m BVGdJcEONeANQ4sUT0dQfeWyK2dOWVPE0CEst8D9s18XNBxTG8KDpMUFl6gUoCCo7/HZ9tsZx/lEm dMbq9BGUYHXx1AEcSL6QpCWj9u0g9+z4vS2Ysmi5Z5lOtF/z48IerJkimZFNEHXjK8oj+Do5ubcuR wsOwPlY+fQnvpGQReJGkeLutukunw2zLjopnoqdTjdfVO6zg+UVTIuJdhRtK4/HWcoCrP8ILPoEMp tAzMRtyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLwr5-001hN8-P5; Thu, 11 Aug 2022 01:19:23 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLwr3-001h78-AC for linux-mediatek@lists.infradead.org; Thu, 11 Aug 2022 01:19:23 +0000 X-UUID: 31999ae7474c4494a987ce2c4d303049-20220810 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.9,REQID:113348cf-0eed-4e78-a9d3-1c900311b9d2,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_H am,ACTION:release,TS:5 X-CID-META: VersionHash:3d8acc9,CLOUDID:bd0879ae-9535-44a6-aa9b-7f62b79b6ff6,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 31999ae7474c4494a987ce2c4d303049-20220810 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1156536974; Wed, 10 Aug 2022 18:19:12 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Thu, 11 Aug 2022 08:49:08 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 11 Aug 2022 08:49:08 +0800 From: To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Jing Cai Subject: [PATCH v5] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend Date: Thu, 11 Aug 2022 08:49:07 +0800 Message-ID: <6675f56fc8b0910f17ec506d534cf5330ff04733.1660177086.git.objelf@gmail.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220810_181921_431945_2428A352 X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Sean Wang 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 Signed-off-by: Jing Cai Signed-off-by: Sean Wang --- 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;