From patchwork Wed Oct 19 08:25:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp214682wrs; Wed, 19 Oct 2022 02:13:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4sKJMjlYN7o1vWecyw95msjfYl23uRTk+tyG0ZtYYEMBi5X0POI2YaMYobXpL+xAJXWyFf X-Received: by 2002:a17:907:728c:b0:78e:2856:7fed with SMTP id dt12-20020a170907728c00b0078e28567fedmr5927950ejc.2.1666170810643; Wed, 19 Oct 2022 02:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170810; cv=none; d=google.com; s=arc-20160816; b=Nn9A5CGELVdnutVrL33dFsirod6mi+KJ7FfRvqynpQcwzZuz38JXf8UPu1/hePv+Vr P8i8wnzNJkvijXXitRI+A3QxcEitjLg3PnSbEHNpfM0Q7fOiIiveo9HVvFcGafaeDLzP MhJ7GNQmrzvWZQxgfKYLvM5NyXtYnJNoAyd/yUf9UlKdNLgCHhoSq5Td95Egz5cnzugQ n0LRodELniByBD6XWOhw7DqoPrI553IMkGvvbvVGkvr18IWZmSXcdwd89rdca1/mLgY9 UyCjPAGpATz+MPCUFhN2h7fyOfhRKYeivqdUAhr1I+1idBukW6p33SmhdwwdlkyWhsRc /Igg== 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=Pj1Lho5NIF0e2ry22f0mwYwi4/33CqvzJ3CbZx6e22c=; b=F9/8KQdro0xOJJf9S53Cz1hk/GVvQeyalf6jWRvgGCZN7dXGFpMAhNO9B8I2Bm1E7F TylLTyB0CZGbt5YOiw/FBiRYqjf3Xah8TeUO00ABpb+yDtBIoTpVTDTHjOOFxX5slNuT 8Min9IJbKuC0qCIS1YJMzpbkYcysqhR2ZXgTZr6I+e+pu+nL0iUt8U3luH+ad+e71XkO VCedHKAQvSfQGXQ9GSMeYkmP/Q+KDcwcijAYIX32v+3AF3DbAjl+tStkUr54ffVU9HKv ldUenVPzlfswKuKkRHNPlbkFRd/LLhe2frYcL99PcYpXYEX2tFiGxCIN+6zhnurPovlm 3udA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DRMo3F2R; 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 sg20-20020a170907a41400b007918f4994f4si9092277ejc.15.2022.10.19.02.13.05; Wed, 19 Oct 2022 02:13:30 -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=DRMo3F2R; 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 S232761AbiJSJJN (ORCPT + 99 others); Wed, 19 Oct 2022 05:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbiJSJGX (ORCPT ); Wed, 19 Oct 2022 05:06:23 -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 C14EAB1C6; Wed, 19 Oct 2022 01:59:28 -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 0A9086170D; Wed, 19 Oct 2022 08:49:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22837C433D6; Wed, 19 Oct 2022 08:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169389; bh=/qX+V962Z8ffZqgBaFS68MdpEU2Mzq0Z63D7zxH9BVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DRMo3F2RQQtHwRJJmohBHWV8/e/J8QowBrjcsCDFla/HyKoSTlDjZhy+QH6SMfpIN Wpki8o6lpDUrBz+gmO3F6b1kxZusPIUkvxFpqzV6bSHWfRLjKpeBwna6UKNd+dD0zw fOzeem+wKa/uAAH1UiudK5d98L42UHplr9BHIfw8= 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 6.0 258/862] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend Date: Wed, 19 Oct 2022 10:25:45 +0200 Message-Id: <20221019083301.453642654@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106723838924094?= X-GMAIL-MSGID: =?utf-8?q?1747106723838924094?= 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 15caa6469538..1bb46cbff0fa 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2477,15 +2477,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;