netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/2] Bluetooth: fix debugfs registration
@ 2023-05-31  8:57 Johan Hovold
  2023-05-31  8:57 ` [PATCH RESEND 1/2] " Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johan Hovold @ 2023-05-31  8:57 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-bluetooth, linux-kernel, netdev, Johan Hovold

The HCI controller debugfs interface is created during setup or when a
controller is configured, but there is nothing preventing a controller
from being configured multiple times (e.g. by setting the device
address), which results in a host of errors in the logs:

	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!

The Qualcomm driver suffers from a related problem for controllers with
non-persistent setup.

Johan


Johan Hovold (2):
  Bluetooth: fix debugfs registration
  Bluetooth: hci_qca: fix debugfs registration

 drivers/bluetooth/hci_qca.c | 6 +++++-
 include/net/bluetooth/hci.h | 1 +
 net/bluetooth/hci_sync.c    | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.39.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH RESEND 1/2] Bluetooth: fix debugfs registration
  2023-05-31  8:57 [PATCH RESEND 0/2] Bluetooth: fix debugfs registration Johan Hovold
@ 2023-05-31  8:57 ` Johan Hovold
  2023-05-31  8:57 ` [PATCH RESEND 2/2] Bluetooth: hci_qca: " Johan Hovold
  2023-05-31 19:00 ` [PATCH RESEND 0/2] Bluetooth: " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2023-05-31  8:57 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-bluetooth, linux-kernel, netdev, Johan Hovold, stable

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 <johan+linaro@kernel.org>
---
 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))
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH RESEND 2/2] Bluetooth: hci_qca: fix debugfs registration
  2023-05-31  8:57 [PATCH RESEND 0/2] Bluetooth: fix debugfs registration Johan Hovold
  2023-05-31  8:57 ` [PATCH RESEND 1/2] " Johan Hovold
@ 2023-05-31  8:57 ` Johan Hovold
  2023-05-31 19:00 ` [PATCH RESEND 0/2] Bluetooth: " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2023-05-31  8:57 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-bluetooth, linux-kernel, netdev, Johan Hovold, stable

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 <johan+linaro@kernel.org>
---
 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 */
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND 0/2] Bluetooth: fix debugfs registration
  2023-05-31  8:57 [PATCH RESEND 0/2] Bluetooth: fix debugfs registration Johan Hovold
  2023-05-31  8:57 ` [PATCH RESEND 1/2] " Johan Hovold
  2023-05-31  8:57 ` [PATCH RESEND 2/2] Bluetooth: hci_qca: " Johan Hovold
@ 2023-05-31 19:00 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2023-05-31 19:00 UTC (permalink / raw)
  To: Johan Hovold
  Cc: marcel, johan.hedberg, luiz.dentz, davem, edumazet, kuba, pabeni,
	linux-bluetooth, linux-kernel, netdev

Hello:

This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 31 May 2023 10:57:57 +0200 you wrote:
> The HCI controller debugfs interface is created during setup or when a
> controller is configured, but there is nothing preventing a controller
> from being configured multiple times (e.g. by setting the device
> address), which results in a host of errors in the logs:
> 
> 	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!
> 
> [...]

Here is the summary with links:
  - [RESEND,1/2] Bluetooth: fix debugfs registration
    https://git.kernel.org/bluetooth/bluetooth-next/c/3e972279b782
  - [RESEND,2/2] Bluetooth: hci_qca: fix debugfs registration
    https://git.kernel.org/bluetooth/bluetooth-next/c/22307d477e3f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-31 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31  8:57 [PATCH RESEND 0/2] Bluetooth: fix debugfs registration Johan Hovold
2023-05-31  8:57 ` [PATCH RESEND 1/2] " Johan Hovold
2023-05-31  8:57 ` [PATCH RESEND 2/2] Bluetooth: hci_qca: " Johan Hovold
2023-05-31 19:00 ` [PATCH RESEND 0/2] Bluetooth: " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).