Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2433rwb; Wed, 10 Aug 2022 17:59:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ktaDDaxfy314k6C7ExXeF/r0CxOF7Y1XTXNfulLdirn5Vt0IGVcUEWdbCBSpbvc+vC6Jb X-Received: by 2002:a05:6402:500d:b0:440:9bc5:d0c1 with SMTP id p13-20020a056402500d00b004409bc5d0c1mr16637825eda.202.1660179566977; Wed, 10 Aug 2022 17:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660179566; cv=none; d=google.com; s=arc-20160816; b=l5jDETIZC0Auj3643JB+aTFrl7JDrGB0keereNiFsa5/H17CYbj7VYUxTf6FszdJIj t7fbxLYiQv/38NbgMSLnUCsFPsmUUuS8q5QGjtzLEWqbk4W/d6dPm+d2EDZ8NDAFiRcE PwnYITXUjWmOFab6n+d0p1shCjtCIGAZIuib95668Pb+oj6uUr/ddWiTSCK3I6P439IY 4CYrSV1l880V1/vpa3Gd9IJ0jASraj8e4TelNEtSIk9ZtAJVCt2CwFk+/uC1++FB+2Jy Y7u9CaZSQlmo/W11iFDym9JyFsE1dwj4CnU+Z4ooGuZTC0STBgHQ2xDBfFmVrRlQx3Op VIVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=J02Otlqm9jVMozONgqtzLnRRp+2ot0UG4yvdPeLI0N4=; b=h/RrED4a14oSn6byyh5DikXByAjsQt/j3oeGpY5IymZREKU+Mpr6NUrLod0IKC95Qk MY2ik1aX3DT2kltnN0dZu6QRxmDc+fs9M2A/9nnmFEFoIZ4uPKkA4h+QfN1lZ3ktSUzw LNI2LljPmSdYr3/2yQEJ8JgBq0VcnY/+jZpGLGafxHhi7NsoN4McvwURMa2hMv+fL0Ni Skg20XRfifE6EqOQu542JJfS166+QUG2wisUFCjUF+yFuuWPccsDx0XYG1gskdVWOhaZ peGnmcP3QVv47fcXiVJ+GqV8QhRIBqk3qe0ox6TPdKm1ce8P/iYvIKJGSo3plc6lnjin YfgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=IP6G91uz; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz24-20020a0564021cb800b0043cc3506c6esi11567463edb.217.2022.08.10.17.59.00; Wed, 10 Aug 2022 17:59:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=IP6G91uz; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbiHKAtX (ORCPT + 99 others); Wed, 10 Aug 2022 20:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbiHKAtW (ORCPT ); Wed, 10 Aug 2022 20:49:22 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 055D4844DD; Wed, 10 Aug 2022 17:49:14 -0700 (PDT) X-UUID: e7f7311ac8394fe8b8034fa10d0a6d13-20220811 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=J02Otlqm9jVMozONgqtzLnRRp+2ot0UG4yvdPeLI0N4=; b=IP6G91uzxN+WNAGA60ai7YDH1rL6k3a1zKloseVNhmyHYVXdYqSeMSflVw2j528KZ2d6SswRWdRukAAPRRhjL7OPx0YEXCKvxEqE51n4zpFCSJrtC4+2P0qCYOuAKSvrryYIIVqQI5tBHmJbp1g74v7/02q8FYUWVG1aGxAGHXk=; X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.9,REQID:df0c4343-2110-4181-a37a-1fd0a846f845,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release _Ham,ACTION:release,TS:105 X-CID-INFO: VERSION:1.1.9,REQID:df0c4343-2110-4181-a37a-1fd0a846f845,OB:0,LOB: 0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS98 1B3D,ACTION:quarantine,TS:105 X-CID-META: VersionHash:3d8acc9,CLOUDID:1fcd519c-da39-4e3b-a854-56c7d2111b46,C OID:510a9701587b,Recheck:0,SF:28|16|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: e7f7311ac8394fe8b8034fa10d0a6d13-20220811 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1779104499; Thu, 11 Aug 2022 08:49:10 +0800 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 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY,URIBL_CSS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.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; -- 2.25.1