From patchwork Wed Oct 18 14:55:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Ziswiler X-Patchwork-Id: 13427214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88D63CDB484 for ; Wed, 18 Oct 2023 14:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235238AbjJRO4E (ORCPT ); Wed, 18 Oct 2023 10:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235219AbjJRO4C (ORCPT ); Wed, 18 Oct 2023 10:56:02 -0400 Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5EE8EA; Wed, 18 Oct 2023 07:56:00 -0700 (PDT) Received: from toolbox.int.toradex.com ([213.66.31.70]) by mrelay.perfora.net (mreueus004 [74.208.5.2]) with ESMTPSA (Nemesis) id 1MI55X-1qmkxj1GCN-00F8Gg; Wed, 18 Oct 2023 16:55:52 +0200 From: Marcel Ziswiler To: linux-bluetooth@vger.kernel.org Cc: Sherry Sun , Johan Hedberg , Luiz Augusto von Dentz , Neeraj Sanjay Kale , linux-kernel@vger.kernel.org, Marcel Holtmann , Marcel Ziswiler , Amitkumar Karwar , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v1 2/2] Bluetooth: btnxpuart: Fix nxp_setup Date: Wed, 18 Oct 2023 16:55:40 +0200 Message-Id: <20231018145540.34014-3-marcel@ziswiler.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20231018145540.34014-1-marcel@ziswiler.com> References: <20231018145540.34014-1-marcel@zisw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REVnwepIBK4SbLx4z3My1eYvzIks/XaHsNx5zduVyWG2yyjjpLh2 PxoIpd40vm3nlqcB8N7i/vpYX/GADMmxx7gCtMqwulJelhSjU1NnT2qGwdKjNkJbc+qaVw0DG i8NWHqFFcM+ZPHg== Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Marcel Ziswiler Unfortunately, nxp_setup() may inadvertently assume that the firmware is already running while the module is not even powered yet. Fix this by waiting up to 10 seconds for the CTS to go up as the combo firmware might be loaded by the Wi-Fi driver over SDIO (mwifiex_sdio). Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP Bluetooth chipsets") Signed-off-by: Marcel Ziswiler Reviewed-by: Neeraj Sanjay Kale --- This is what may happen without this fix: [ 284.588177] Bluetooth: hci0: Opcode 0x0c03 failed: -110 [ 286.636167] Bluetooth: hci0: Setting wake-up method failed (-110) Unfortunately, even re-loading the btnxpuart kernel module would not recover from this condition. drivers/bluetooth/btnxpuart.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c index 9cb7529eef09..4b83a0aa3459 100644 --- a/drivers/bluetooth/btnxpuart.c +++ b/drivers/bluetooth/btnxpuart.c @@ -1021,6 +1021,16 @@ static int nxp_setup(struct hci_dev *hdev) if (err < 0) return err; } else { + /* The combo firmware might be loaded by the Wi-Fi driver over SDIO (mwifiex_sdio). + * We wait up to 10s for the CTS to go up. Afterwards, we know that the firmware is + * really ready. + */ + err = serdev_device_wait_for_cts(nxpdev->serdev, true, 10000); + if (err) { + bt_dev_err(nxpdev->hdev, "Wait for CTS failed with %d", err); + return err; + } + bt_dev_dbg(hdev, "FW already running."); clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); }