From patchwork Wed May 31 08:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 101294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2740259vqr; Wed, 31 May 2023 02:18:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+qSo467Also5qXO7hgIF9EfYYdGtULM3olhQEON0Q3W+hils12xo5OBMltaFq9jRV+3r0 X-Received: by 2002:a17:902:dac2:b0:1b0:5304:5b48 with SMTP id q2-20020a170902dac200b001b053045b48mr5489390plx.0.1685524698723; Wed, 31 May 2023 02:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685524698; cv=none; d=google.com; s=arc-20160816; b=GeeXoF1+Kx31utBikuH2sptp82zFhW/KrAmVfcdH/GHRWCnXIvJfjQ1cpObzvCcvH8 HeN8dbdstxx+FZRActadpZ1PNhxrO4aP9N3kLcdw6Y+kqRn3Gm4p9KLKy5CxjBvnlw9c 3wSeSk0fEYZBkY77CJ77W/xBOFoSKWHQZcmpN4ySHl+49aC/GW5bbCSFNH1YpReUvfjt AoS3Zov1FLugCcJl3FmD0i1Mt7AHjZGWKQLP4jhogMUtNNr7GqaXNvseaWJTYcBBgqxh z/oyixQk+SMN3E40pST0iWGMjPUcXtlZ47L7yLNvKVzpNmXjS2YPILN2vbzN9eNNwqVW JFPw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l1uN9F5U9kC9Ej7yB2oUZRC33lmLz1FzOhgm64ANh7E=; b=M0otYM/ptwLz5V95dL7uPfPlkWnnhZum5vXNmDpRhZ9SpiuRBLMFyqVFkSSj51exHz TmCwvnbWCp/0gPxtJaaxKskWWr5s7e0YO6P69eW0iYWudaZA7FQAdlT1z26zLz7/Kt1+ 8YgCBGnWYpYeW38B7l2AxB8le7LkqudifoH0ZZF2EELslOcZZmr0yb/6pSl8XL1HBo8N 875fLNC0fI6g9Oz3A5i0LcD1VHgNWtqpfu4HbWikZiu6BqlzYxNenHWvnj4Qmhk5TApp 9RelI18jgMsrVZ50zx05o+EkyNS1rP3fhqpIeTFvJ8sDGHIi3Dl3nooyTkWC/UHSoBFe sGfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M+G5QG4E; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a170902708600b001ab20d029e0si519008plk.582.2023.05.31.02.18.06; Wed, 31 May 2023 02:18:18 -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=@kernel.org header.s=k20201202 header.b=M+G5QG4E; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231397AbjEaI6o (ORCPT + 99 others); Wed, 31 May 2023 04:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbjEaI6k (ORCPT ); Wed, 31 May 2023 04:58:40 -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 2FEFDE6; Wed, 31 May 2023 01:58:39 -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 B4A5263494; Wed, 31 May 2023 08:58:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B31EC433EF; Wed, 31 May 2023 08:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685523518; bh=5iPlGxWeg1puDstJF/Uf9U+q7gbki1LPKTuxWP0fpy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+G5QG4Ewb9mHrkc46gjlJhtJa/w1G/Pc4kDxiv/43CB5dmGDEyIfvdfWgigSrNbO N/P/n3JP8tmQwfDVaEWuINBWDoVn6G8W1hOZHGAvaWFQvCNzejsg0yZWXeVAvCcEO2 zqwo+lK7l/caqELIRHKPPL8qPaNsXO5yRjAdoMe91CsvqQx7rkqxTFrb4EkU07FvVG DuEUWfYP1QT+mrVYGS6kA3JskT2PD1R8EWe1vyId0kg4paJd54Q/jx9a87XK+E9xHO 3jPdf6yLr2h+mmuXoiQCVKRUudqSFH/ikT32IQRQYATy+VRF4dSNdLlMDlWNnxqm8v /8/LpjfB/aerA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1q4HfF-0000jl-M5; Wed, 31 May 2023 10:58:41 +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 RESEND 1/2] Bluetooth: fix debugfs registration Date: Wed, 31 May 2023 10:57:58 +0200 Message-Id: <20230531085759.2803-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230531085759.2803-1-johan+linaro@kernel.org> References: <20230531085759.2803-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1767400731399505716?= X-GMAIL-MSGID: =?utf-8?q?1767400746847728498?= 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 07df96c47ef4..872dcb91a540 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -350,6 +350,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 647a8ce54062..0efc2253265e 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -4543,6 +4543,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 Wed May 31 08:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 101293 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2739821vqr; Wed, 31 May 2023 02:17:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wJE3pj6nNsFoZWXbukFBl0vBg4l+vtqFKEoV/rfnU4GZhkZIb45R8ipCY73d+TEiOg2su X-Received: by 2002:a05:6830:114c:b0:6ac:87ec:cc2c with SMTP id x12-20020a056830114c00b006ac87eccc2cmr1789051otq.2.1685524640980; Wed, 31 May 2023 02:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685524640; cv=none; d=google.com; s=arc-20160816; b=A4Gs9hk+RUX5+hrzv/hnxN5rcqXgUcolr2jf0/zNCQrCQj0+VpjEL71qqp6RMABXcb gHXv08HZ3W221ZSNZ1U/phLkHWEg4UFb+GXok4m4GRP0ChdW3MGmDGblWeQZbIYqJ2XA ttxoZmqOp0B5aovuJrNBuebXTqFggQPRZKbAUi5VTdvdQhLkyIv9VDibtiLQESkwddKo fEkftJDMgWZTFnGwSVhoq69Nrgm7DWXUa5J/hESGDk+elWcvdYnSgE4ofljyya4OkGYs aXlGklApbZABvNwlmvjZmRHVLzps+P6EWhxtglj1y6i8HQS7felgMmK/bzArQ8wM4Xcz k4EA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pa0lgaa4IpSV0eLUPbHL35tPmuSLyiL7N/oqVQtx9ag=; b=FTKJldohc7Cemv/xPsiU3pi45i3RorHwU/G9YjHEQ53TCcyLectA/a1v8Xryth010x SW2BEs3uRbXIZ7SvYYJ+7U31vXpKVCzlPQ7NUnEVkd7SGo2JDjyQQxPQEBUOyfGX/jEu jve6pmUA1nM/jwDBjc/nhaAuJvNwwDCtTDYr34zb4gJvELgaJ/R7e2bE1D08u4MonkaG NRfpZGaeBI6P9lik8gnHHFSkstINYJHLtnHQvozZ53dUjFCpVaR18oCoXZZjFg7J3IqK cqJRIhaEhV550taXyMEneaYsWSvF3zk5hm22RAC5EPPpND5rHCHaqwbgFT9SC+ic2Hum kBUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sKwl+ueY; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k28-20020aa79d1c000000b00643aa8d8cb7si3318469pfp.185.2023.05.31.02.17.08; Wed, 31 May 2023 02:17:20 -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=@kernel.org header.s=k20201202 header.b=sKwl+ueY; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235242AbjEaI6l (ORCPT + 99 others); Wed, 31 May 2023 04:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231397AbjEaI6k (ORCPT ); Wed, 31 May 2023 04:58:40 -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 30D7210B; Wed, 31 May 2023 01:58:39 -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 BA6196311E; Wed, 31 May 2023 08:58:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F257C4339B; Wed, 31 May 2023 08:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685523518; bh=HaYbQJNi6y881NqAy/tkhEXGqgb8cgiQ7a1/RH6TbrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKwl+ueYa9OKC0VTzsZZm6QE+TtD+wHKIUCr/INiDLgF9vK6gK8Vasyu9RcSI3gQZ LdtJqjpTS1zuKkZpNXCRo9G8VN8UXcQr4mlVr2eUKYaoou5OrMPDYpAZEjbtdUmKVt 2zCOrSE25apXdIFqkxTGpx9DkmYCTp4hGmKQoUOmp7ZCbtcOpzG/HsgrkpQiHtQADx Ow8qtQehHdWoom1OUMwbf28DlkfGWVPmv7xWFRrUeHJMef7gyixk4v6mjUfoh9KdVx XBzNsuWeNTO9es6qJEjFKLBfcxPS8Zh5He0Z4ObGWuO8wBS6+4Ja09/edT+95W6qYv B4BwUqWcWuDtw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1q4HfF-0000jn-Oe; Wed, 31 May 2023 10:58:41 +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 RESEND 2/2] Bluetooth: hci_qca: fix debugfs registration Date: Wed, 31 May 2023 10:57:59 +0200 Message-Id: <20230531085759.2803-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230531085759.2803-1-johan+linaro@kernel.org> References: <20230531085759.2803-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1767400685988271182?= X-GMAIL-MSGID: =?utf-8?q?1767400685988271182?= 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 1b064504b388..e30c979535b1 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 */