From patchwork Sat Oct 22 07:21:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7586 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1106325wrr; Sat, 22 Oct 2022 01:37:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6c96X0kxpvHmoopFZ2y6goaxHR60S5UKfUD5aKmRvN79rOUHk7xPwctC76x+W9xPhiCCVW X-Received: by 2002:aa7:810a:0:b0:55b:674d:d123 with SMTP id b10-20020aa7810a000000b0055b674dd123mr24014545pfi.52.1666427851302; Sat, 22 Oct 2022 01:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427851; cv=none; d=google.com; s=arc-20160816; b=IUEypcmxzJ+SzM/658wVtvgD4zolHS0biwnpX8v5WDv0wQndFj5ZVYcnxLc4o7oFON JCVyR7dnQ9Ikxhu0TNvKgiWhRM7/NygM2uCeh5dnZnxCXPuWno90q0JSBsceU0ksxlH4 Tz+V1dQ4SD1Mut10vafrKfauVm767w3iimFO5qwFsbTx6+lPS8jYuKU897jHkRCH7v+i 09WWP8jR9xqyHftzEBwryFixRdl7fVu5xvoSlPEnTdgilRFJcnu/AxDKPVeasLEzpHi+ XNGHp83WzBXxMXvJtcNzn9Kys4AOuqYqgsHbcmZSa4s/6+qii69z1ITlvhy8coJ14NWN EY+Q== 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=WNy0nPlFRZHmyMlcEQ3i6SsH/psOvkNF4ZRngkZbBgE=; b=MpyFOt/PevacjaAMkTz9kzgaZcfYRSw5UuesihPuTGp0CjmV4V7qP1/rrm6pya5gVh JP+6c+IUOXhJpUtroVGpcre55wxkwVpimk/fg9RPe6SNz+kXkDBk4MLyAooQI4vw0pBj yGvmHXs/xYFL7+QBgBMgWQIhEiO9jyJDk1/xq4TH4q+W0xwtVHQViJrwFaGnJO0CSGon 9XLc2dSzRvz0Tp49o43E5Asb/J4bkfRPFHnV+PlNPUuy1EvvDQndPcjIg456io65fhJO bx5E8gnvGoMzdxwXPASNlFI7h2Q/QMpv26T8sCFzzWPQy+UUnBQuotD8exQ/6pgIO9pU IKEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y4z6GNUV; 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 e12-20020a170902cf4c00b001865b86ad09si10256465plg.419.2022.10.22.01.37.17; Sat, 22 Oct 2022 01:37:31 -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=Y4z6GNUV; 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 S234072AbiJVIdC (ORCPT + 99 others); Sat, 22 Oct 2022 04:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234122AbiJVI3k (ORCPT ); Sat, 22 Oct 2022 04:29:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDB72E38E2; Sat, 22 Oct 2022 01:02:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 067BFB82E15; Sat, 22 Oct 2022 07:44:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55312C433C1; Sat, 22 Oct 2022 07:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424646; bh=jUXwn7KHB5zBLuslpmUGxlvhoJHk8Cr4CZPjaxdURag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4z6GNUVffkOsELd6eGUWNy4c8m4md/IcYS0FiyzfkQootkNGBT2OhXDHgG3rsIA8 zA+WMM795Umssa41orYmOlmKIl/0LY44PqWAxARUe/roQXoqI84MSAVdZyLxgsAqdc xa+FvBKShqZ+/bhculEXkRa9cS6R47f05Yd888SI= 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.19 223/717] Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend Date: Sat, 22 Oct 2022 09:21:42 +0200 Message-Id: <20221022072454.584448188@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376251044657025?= X-GMAIL-MSGID: =?utf-8?q?1747376251044657025?= 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 aaba2d737178..6a320ece3276 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2451,15 +2451,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;