From patchwork Mon Oct 24 11:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp442698wru; Mon, 24 Oct 2022 06:07:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53AkTx2tyIuU3flwrNKddIdt64pB6/zp9TcA8DEcqDDyDQ4TSaesNBbNfHoqnFnr5F6NKi X-Received: by 2002:a17:90a:520c:b0:212:d135:4471 with SMTP id v12-20020a17090a520c00b00212d1354471mr19888611pjh.71.1666616878483; Mon, 24 Oct 2022 06:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616878; cv=none; d=google.com; s=arc-20160816; b=P8KjmPjXPtfPDTET67pYlBFETiaSV8lC3ft7quMm26F0xV0fQsWNRKfjKPv97WoH5Q V7hwiMef5YxHoEUflPlTtzLuu4ePeRncgfafeCBS9CmTlgpGKRcHkp3q9lwvCAX/hdPM add8o7xVXVSo1DWqsyi/n+pJUF13Rd9tDX7djmqFfwG4dQ7w6HxdLd7JE7kFp3uKFC0x /8c/gmviX0bKv0Y/Uhpqolmp01SPkF1d7dJcf0iFtpgzraxk7qnGTh6OoBt636tnmZZa lEL332A+UD4V7Ug7pNfqw7gFkphWCfeuMeDlAETxJZjdiVzTXGHB3+cocu45j41/Hizb QktQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SceBGJr8NSwb80aF3r8bzIX8KWUVX9g+VgdVCDFkalM=; b=c2pCY/UCvjSb0ymFK9DxwehGEQKJwhxfcmX8lfs3huwW3bh8EQdk6OzFw3T0tSDJwc HGa8F75o7Ijwzz3w4D7u8n4THuB80sgiy4Au9hfHEqQcMRaaECnIXlU226jRI8/sLU0A ZhzKvlMCPh0qaJ8XHxlFaOs98DeI7+P/nFauy7hPOr1d+LdsoDJxbE+lOmtwL6dB2c4a 9eR5f4US46woCBW+VJz7I6gHlsWKhe+Jmsv2pCoAgmr8ZtS1v398Eh7I/SaJuE1MdD+z fm4jjCiWUCFBz0lKqaRk7P/S+sHVW4AZk9Cdo6OqM0nAgRVQmqDMH0fGQSO82L5Alu/1 rFig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hsuIQNO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020aa788c8000000b005251a2f06bbsi2263816pff.59.2022.10.24.06.07.37; Mon, 24 Oct 2022 06:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=hsuIQNO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235438AbiJXNGf (ORCPT + 99 others); Mon, 24 Oct 2022 09:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235422AbiJXNEp (ORCPT ); Mon, 24 Oct 2022 09:04:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409DC82D32; Mon, 24 Oct 2022 05:20:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0338061017; Mon, 24 Oct 2022 12:20:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10CD1C433C1; Mon, 24 Oct 2022 12:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614037; bh=OV4m7KUP2Ogn00c80OLzn4F/OXzDpQCCIO99uKCA0Fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hsuIQNO5X6/j0c4sZeLI3TWMumJixrB1g6MGEFu3vRkr3XQvNSMbswFSvYiAG4P2N TJSxzLmzActcnNaUhS+M5hwe5Wd7UxEJ8cwczmGUnO3repqXYDkFXq0mkfqsp1DQdx g/RxUha8uTVk5w+/ZWeXtKDXq+LOXgJe7zUKyESM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jing Cai , Sean Wang , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.10 108/390] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend Date: Mon, 24 Oct 2022 13:28:25 +0200 Message-Id: <20221024113027.300885336@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747574459967688327?= X-GMAIL-MSGID: =?utf-8?q?1747574459967688327?= From: Sean Wang [ Upstream commit fd3f106677bac70437dc12e76c827294ed495a44 ] 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 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/btusb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 80a3d5019950..6efd981979bd 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3033,15 +3033,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) return err;