From patchwork Mon Apr 24 12:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13222099 X-Patchwork-Delegate: kuba@kernel.org 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 95EF3C77B78 for ; Mon, 24 Apr 2023 12:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbjDXMu1 (ORCPT ); Mon, 24 Apr 2023 08:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231818AbjDXMuY (ORCPT ); Mon, 24 Apr 2023 08:50:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C184C0E; Mon, 24 Apr 2023 05:50:03 -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 6D25E61F2D; Mon, 24 Apr 2023 12:50:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B67E2C433EF; Mon, 24 Apr 2023 12:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682340602; bh=doty7Nzt+HL2eXizgefudpBTTJskbLd1/KbCneDfvBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B3E+bHqoklmEQDfyF6vGU4XrflewNvEr9ugq5EkTvqYq3TkA3rdNPFnPVzpLpayR2 aC3CRIGGm2dcI9JX6c4CwWlQswX5IK1JlTdAVWnmsaTZYIxgZ54/aZTpMP+2mMxVa+ OyJRsQPIiKlmPESbtEYJB1uihIgBkfWITm5Lv4kGrhgcoQn0SCjd1UpP7CEaVzqjh0 TosHtmvyg6tk02NV7ZOzk83U3D6Upz6tJ3Pq803oSo5TEsNuObxbsRd3i8e49Dygzp Im7YTrRwN01AC1vo2VvgrO5exFWwRwi563bvuN6YVqUqLbGkBcJATcKISR8B09jE5e qlxFb5cmRj8CQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pqve7-0003IX-6f; Mon, 24 Apr 2023 14:50:19 +0200 From: Johan Hovold To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: fix debugfs registration Date: Mon, 24 Apr 2023 14:48:51 +0200 Message-Id: <20230424124852.12625-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230424124852.12625-1-johan+linaro@kernel.org> References: <20230424124852.12625-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since commit ec6cef9cd98d ("Bluetooth: Fix SMP channel registration for unconfigured controllers") the debugfs interface for unconfigured controllers will be created when the controller is configured. There is however currently nothing preventing a controller from being configured multiple time (e.g. setting the device address using btmgmt) which results in failed attempts to register the already registered debugfs entries: debugfs: File 'features' in directory 'hci0' already present! debugfs: File 'manufacturer' in directory 'hci0' already present! debugfs: File 'hci_version' in directory 'hci0' already present! ... debugfs: File 'quirk_simultaneous_discovery' in directory 'hci0' already present! Add a controller flag to avoid trying to register the debugfs interface more than once. Fixes: ec6cef9cd98d ("Bluetooth: Fix SMP channel registration for unconfigured controllers") Cc: stable@vger.kernel.org # 4.0 Signed-off-by: Johan Hovold --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_sync.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 400f8a7d0c3f..b8bca65bcd79 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -335,6 +335,7 @@ enum { enum { HCI_SETUP, HCI_CONFIG, + HCI_DEBUGFS_CREATED, HCI_AUTO_OFF, HCI_RFKILLED, HCI_MGMT, diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 632be1267288..a8785126df75 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -4501,6 +4501,9 @@ static int hci_init_sync(struct hci_dev *hdev) !hci_dev_test_flag(hdev, HCI_CONFIG)) return 0; + if (hci_dev_test_and_set_flag(hdev, HCI_DEBUGFS_CREATED)) + return 0; + hci_debugfs_create_common(hdev); if (lmp_bredr_capable(hdev)) From patchwork Mon Apr 24 12:48:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13222100 X-Patchwork-Delegate: kuba@kernel.org 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 50FCDC7618E for ; Mon, 24 Apr 2023 12:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbjDXMu3 (ORCPT ); Mon, 24 Apr 2023 08:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231823AbjDXMuY (ORCPT ); Mon, 24 Apr 2023 08:50:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21BBA4C10; Mon, 24 Apr 2023 05:50:04 -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 71FE161F32; Mon, 24 Apr 2023 12:50:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8882C4339B; Mon, 24 Apr 2023 12:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682340602; bh=Kp6sLYqmpkY6hExl+WRL9PGf/2mCUC4b+03Evy/ZlDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGTbaFPpS88HlIx4V3SL3glUuDcDtTMpORjUTvqreo9LpPCMxst6lPABFFUCRBc+F gXHv5YzeJyUCd2bS8mFX6UMJ3d/kRxYGPpIOkXvzFL9tgXdSNyl9/K5HSqB+k51MgS hSJ+Lu+QZQysC+fX2BDwVv1VS/0xSHD7G8/ECgL3NU3pP2nUaoB1H9mHa6YK29BVbq z8kEzq2Ft85mnNR2GtanDzesV27goQHXkhBNl2XgT5drBK0hsh12951vfd9ePl4KEf zGbWgRJ6COPmrM6C7qoPeZw0ArUOMEt6pRLu8g7TxHQDcz4r7yyiutO/nNoHIDtU/i tm540grJRDTeg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pqve7-0003IZ-9n; Mon, 24 Apr 2023 14:50:19 +0200 From: Johan Hovold To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: hci_qca: fix debugfs registration Date: Mon, 24 Apr 2023 14:48:52 +0200 Message-Id: <20230424124852.12625-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230424124852.12625-1-johan+linaro@kernel.org> References: <20230424124852.12625-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since commit 3e4be65eb82c ("Bluetooth: hci_qca: Add poweroff support during hci down for wcn3990"), the setup callback which registers the debugfs interface can be called multiple times. This specifically leads to the following error when powering on the controller: debugfs: Directory 'ibs' with parent 'hci0' already present! Add a driver flag to avoid trying to register the debugfs interface more than once. Fixes: 3e4be65eb82c ("Bluetooth: hci_qca: Add poweroff support during hci down for wcn3990") Cc: stable@vger.kernel.org # 4.20 Signed-off-by: Johan Hovold --- drivers/bluetooth/hci_qca.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 38ff962662ff..db020c04b3e8 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -78,7 +78,8 @@ enum qca_flags { QCA_HW_ERROR_EVENT, QCA_SSR_TRIGGERED, QCA_BT_OFF, - QCA_ROM_FW + QCA_ROM_FW, + QCA_DEBUGFS_CREATED, }; enum qca_capabilities { @@ -635,6 +636,9 @@ static void qca_debugfs_init(struct hci_dev *hdev) if (!hdev->debugfs) return; + if (test_and_set_bit(QCA_DEBUGFS_CREATED, &qca->flags)) + return; + ibs_dir = debugfs_create_dir("ibs", hdev->debugfs); /* read only */