From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB7D2C4338F for ; Mon, 16 Aug 2021 15:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C870060F4B for ; Mon, 16 Aug 2021 15:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237062AbhHPPuK convert rfc822-to-8bit (ORCPT ); Mon, 16 Aug 2021 11:50:10 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53563 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235241AbhHPPuC (ORCPT ); Mon, 16 Aug 2021 11:50:02 -0400 Received: from smtpclient.apple (p5b3d23f8.dip0.t-ipconnect.de [91.61.35.248]) by mail.holtmann.org (Postfix) with ESMTPSA id D0005CECC8; Mon, 16 Aug 2021 17:49:25 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [PATCH v2] Bluetooth: Move shutdown callback before flushing tx and rx queue From: Marcel Holtmann In-Reply-To: <20210810045315.184383-1-kai.heng.feng@canonical.com> Date: Mon, 16 Aug 2021 17:49:25 +0200 Cc: Johan Hedberg , Luiz Augusto von Dentz , Mattijs Korpershoek , Hsin-Yi Wang , Guenter Roeck , "David S. Miller" , Jakub Kicinski , "open list:BLUETOOTH SUBSYSTEM" , "open list:NETWORKING [GENERAL]" , open list Content-Transfer-Encoding: 8BIT Message-Id: <453AB6D8-9CA8-42B8-9807-5AC249E8618B@holtmann.org> References: <20210810045315.184383-1-kai.heng.feng@canonical.com> To: Kai-Heng Feng X-Mailer: Apple Mail (2.3654.120.0.1.13) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Kai-Heng, > Commit 0ea9fd001a14 ("Bluetooth: Shutdown controller after workqueues > are flushed or cancelled") introduced a regression that makes mtkbtsdio > driver stops working: > [ 36.593956] Bluetooth: hci0: Firmware already downloaded > [ 46.814613] Bluetooth: hci0: Execution of wmt command timed out > [ 46.814619] Bluetooth: hci0: Failed to send wmt func ctrl (-110) > > The shutdown callback depends on the result of hdev->rx_work, so we > should call it before flushing rx_work: > -> btmtksdio_shutdown() > -> mtk_hci_wmt_sync() > -> __hci_cmd_send() > -> wait for BTMTKSDIO_TX_WAIT_VND_EVT gets cleared > > -> btmtksdio_recv_event() > -> hci_recv_frame() > -> queue_work(hdev->workqueue, &hdev->rx_work) > -> clears BTMTKSDIO_TX_WAIT_VND_EVT > > So move the shutdown callback before flushing TX/RX queue to resolve the > issue. > > Reported-and-tested-by: Mattijs Korpershoek > Tested-by: Hsin-Yi Wang > Cc: Guenter Roeck > Fixes: 0ea9fd001a14 ("Bluetooth: Shutdown controller after workqueues are flushed or cancelled") > Signed-off-by: Kai-Heng Feng > --- > v2: > Move the shutdown callback before clearing HCI_UP, otherwise 1) > shutdown callback won't be called and 2) other routines that depend on > HCI_UP won't work. > > net/bluetooth/hci_core.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel