From patchwork Mon Oct 24 11:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp478206wru; Mon, 24 Oct 2022 07:16:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ODBxkk9pNRoiIWeUleQR3qjMAdnBlUHBuya7GHc4I8OKMHpGyKLKUpr5fwSHK2//Z7OYB X-Received: by 2002:a17:907:7e9e:b0:78d:f3b0:fc78 with SMTP id qb30-20020a1709077e9e00b0078df3b0fc78mr28344108ejc.478.1666621019307; Mon, 24 Oct 2022 07:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621019; cv=none; d=google.com; s=arc-20160816; b=rZdY8ZYJufqrNFd9MUU0mEqPVu+wpqIPVYo7JOcWw90pzJ6kcdmyHgCfDzJ21LXtIp D6n+xtcN7SI1dY1vuqy3q0283AnVtt/0mP7VJtD2pW5XnZxWCh8lok7dcMewfyBwJF7S c1lpAfQ7J9A+Od3u3QRd3ghZA88BjPIa/D4uzXcCwOe7gWkeeTazVrvhrXalCX3BHOGN YX46EeiN4O0mmj94FUT26x6kptnb4YCFN/9BvDzYZlkTBTw8fwr/w4PDwTdgD2lLAERu zr3JRyC5kacdsl5V0j7rHqx7ws5UDmgJo5PmpjZJdztm5oTVotFvh9c4DDs52L5OFHYQ a87w== 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=h1XnMdAx0VORU7Hsw2Dyp1hTOX1+Yy1+At1zHrW1Ro0=; b=GWJ2W7bqSJMd8TX0oNTpUwYQzpi3Dw6rMpVDu1tiUY3oDT3xSuMw/rQ8Ea4j/5aERN Xvyl39Co/qOaexojPyyCr0FaYfSYlomLnB5awQNTrtdOy1P0pO5ikkeGCxxVr5URIU4s Ph7BVABfG9nC1gZGyfSNyi3vB/P2Jtrj+33uUO2xeKuVDz4ynDX00tblZ/Ju9o3pc+0r YsSqiI8NJ67g3l+by14d0DxGRQNV1O5ANdlt8s7kmBIwusZoKmpmijUKP6mGkhRZiz7G 4FqhFhHyC4MoXxuLFxHgsRakzYpc+IXezmnlY8RlzRmt75yYUYS2FzEkTVyLeguj7X5Q bU2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j2TVwrFS; 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 em1-20020a056402364100b0046184b7c4besi5671076edb.462.2022.10.24.07.16.35; Mon, 24 Oct 2022 07:16:59 -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=j2TVwrFS; 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 S231921AbiJXOG0 (ORCPT + 99 others); Mon, 24 Oct 2022 10:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235443AbiJXOCu (ORCPT ); Mon, 24 Oct 2022 10:02:50 -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 5005CC06A2; Mon, 24 Oct 2022 05:48:22 -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 5B5F2612E7; Mon, 24 Oct 2022 12:40:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DC6DC433C1; Mon, 24 Oct 2022 12:40:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615253; bh=kOL2fNKhcpIrYPRQ+MlcJv2xdGAiH3dzLt3TQGFnz4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j2TVwrFSTisx93OHuiB3ixPxL6nOf0MEmMVpJ90BnGSziRdQVhsY+NdbgE786K/Ut BOqbUmTWj0bCcdFX6k25qr4S+oE4Eqc71dbX+KoyWiiPBJtmDfFwDAz1/uhO2OYlHE /keJSqjHhv4JIk1pdOz0Y5KaN2hd6OECv61UnmUo= 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.15 163/530] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend Date: Mon, 24 Oct 2022 13:28:27 +0200 Message-Id: <20221024113052.436988326@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747578802190282950?= X-GMAIL-MSGID: =?utf-8?q?1747578802190282950?= 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 627436329b50..64d72ea0c310 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2435,15 +2435,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;