* [PATCH V2 1/2] firmware: tegra: bpmp: Propagate debugfs errors
@ 2026-05-29 15:08 Jon Hunter
2026-05-29 15:08 ` [PATCH V2 2/2] firmware: tegra: bpmp: Add support for multi-socket platforms Jon Hunter
0 siblings, 1 reply; 3+ messages in thread
From: Jon Hunter @ 2026-05-29 15:08 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-tegra, Jon Hunter
The Tegra BPMP debugfs code returns -ENOMEM for most cases where calls
to debugfs_create_dir() or debugfs_create_file() fail. These debugfs
functions return an ERR_PTR with the actual error code on failure.
Therefore, update the Tegra BPMP debugfs code to propagate the actual
error code on failure.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
Changes since V1:
- Added this patch for V2
drivers/firmware/tegra/bpmp-debugfs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index 4221fed70ad4..29037e2b3158 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -468,7 +468,7 @@ static int bpmp_populate_debugfs_inband(struct tegra_bpmp *bpmp,
dentry = debugfs_create_file(name, mode, parent, bpmp,
&bpmp_debug_fops);
if (IS_ERR(dentry)) {
- err = -ENOMEM;
+ err = PTR_ERR(dentry);
goto out;
}
}
@@ -719,7 +719,7 @@ static int bpmp_populate_dir(struct tegra_bpmp *bpmp, struct seqbuf *seqbuf,
if (t & DEBUGFS_S_ISDIR) {
dentry = debugfs_create_dir(name, parent);
if (IS_ERR(dentry))
- return -ENOMEM;
+ return PTR_ERR(dentry);
err = bpmp_populate_dir(bpmp, seqbuf, dentry, depth+1);
if (err < 0)
return err;
@@ -732,7 +732,7 @@ static int bpmp_populate_dir(struct tegra_bpmp *bpmp, struct seqbuf *seqbuf,
parent, bpmp,
&debugfs_fops);
if (IS_ERR(dentry))
- return -ENOMEM;
+ return PTR_ERR(dentry);
}
}
@@ -782,11 +782,11 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
root = debugfs_create_dir("bpmp", NULL);
if (IS_ERR(root))
- return -ENOMEM;
+ return PTR_ERR(root);
bpmp->debugfs_mirror = debugfs_create_dir("debug", root);
if (IS_ERR(bpmp->debugfs_mirror)) {
- err = -ENOMEM;
+ err = PTR_ERR(bpmp->debugfs_mirror);
goto out;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH V2 2/2] firmware: tegra: bpmp: Add support for multi-socket platforms
2026-05-29 15:08 [PATCH V2 1/2] firmware: tegra: bpmp: Propagate debugfs errors Jon Hunter
@ 2026-05-29 15:08 ` Jon Hunter
2026-05-29 15:50 ` Jon Hunter
0 siblings, 1 reply; 3+ messages in thread
From: Jon Hunter @ 2026-05-29 15:08 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-tegra, Jon Hunter
On multi-socket platforms each socket has its own BPMP that is
registered with the kernel, so the existing single fixed "bpmp"
debugfs directory name cannot accommodate more than one instance.
Group the per-socket BPMP debugfs entries under a shared top-level
/sys/kernel/debug/bpmp/ directory, with each socket's BPMP device
under a "bpmp.<numa-node-id>" subdirectory:
/sys/kernel/debug/bpmp/bpmp.0/...
/sys/kernel/debug/bpmp/bpmp.1/...
For a multi-socket platform, the root debugfs bpmp/ directory is created
by the first BPMP device that is populated. For single-socket platforms,
the existing directory structure is preserved.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
Changes since V1:
- Moved BPMP debugfs nodes for each socket under a top-level 'bpmp'
directory.
drivers/firmware/tegra/bpmp-debugfs.c | 44 ++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index 29037e2b3158..28a59ef1af12 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
*/
+#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
@@ -769,9 +770,21 @@ static int bpmp_populate_debugfs_shmem(struct tegra_bpmp *bpmp)
return err;
}
+static DEFINE_MUTEX(bpmp_debugfs_root_lock);
+static struct dentry *bpmp_debugfs_root;
+
+static struct dentry *bpmp_debugfs_get_root(void)
+{
+ guard(mutex)(&bpmp_debugfs_root_lock);
+ if (!bpmp_debugfs_root)
+ bpmp_debugfs_root = debugfs_create_dir("bpmp", NULL);
+ return bpmp_debugfs_root;
+}
+
int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
{
- struct dentry *root;
+ struct dentry *root, *d;
+ char name[32];
bool inband;
int err;
@@ -780,11 +793,22 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
if (!inband && !tegra_bpmp_mrq_is_supported(bpmp, MRQ_DEBUGFS))
return 0;
- root = debugfs_create_dir("bpmp", NULL);
+ root = bpmp_debugfs_get_root();
if (IS_ERR(root))
return PTR_ERR(root);
- bpmp->debugfs_mirror = debugfs_create_dir("debug", root);
+ if (dev_to_node(bpmp->dev) == NUMA_NO_NODE) {
+ d = root;
+ } else {
+ snprintf(name, sizeof(name), "bpmp.%d", dev_to_node(bpmp->dev));
+ d = debugfs_create_dir(name, root);
+ if (IS_ERR(d)) {
+ err = PTR_ERR(d);
+ goto out;
+ }
+ }
+
+ bpmp->debugfs_mirror = debugfs_create_dir("debug", d);
if (IS_ERR(bpmp->debugfs_mirror)) {
err = PTR_ERR(bpmp->debugfs_mirror);
goto out;
@@ -797,8 +821,18 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
err = bpmp_populate_debugfs_shmem(bpmp);
out:
- if (err < 0)
- debugfs_remove_recursive(root);
+ if (err < 0) {
+ if (!IS_ERR(d))
+ debugfs_remove_recursive(d);
+
+ guard(mutex)(&bpmp_debugfs_root_lock);
+ if (root == d) {
+ bpmp_debugfs_root = NULL;
+ } else if (simple_empty(root)) {
+ debugfs_remove(root);
+ bpmp_debugfs_root = NULL;
+ }
+ }
return err;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2 2/2] firmware: tegra: bpmp: Add support for multi-socket platforms
2026-05-29 15:08 ` [PATCH V2 2/2] firmware: tegra: bpmp: Add support for multi-socket platforms Jon Hunter
@ 2026-05-29 15:50 ` Jon Hunter
0 siblings, 0 replies; 3+ messages in thread
From: Jon Hunter @ 2026-05-29 15:50 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-tegra
On 29/05/2026 16:08, Jon Hunter wrote:
> On multi-socket platforms each socket has its own BPMP that is
> registered with the kernel, so the existing single fixed "bpmp"
> debugfs directory name cannot accommodate more than one instance.
>
> Group the per-socket BPMP debugfs entries under a shared top-level
> /sys/kernel/debug/bpmp/ directory, with each socket's BPMP device
> under a "bpmp.<numa-node-id>" subdirectory:
>
> /sys/kernel/debug/bpmp/bpmp.0/...
> /sys/kernel/debug/bpmp/bpmp.1/...
Thierry commented on a similar patch [0] that his preference is to
prefix the NUMA ID rather than append because this is more hierarchical.
We agreed that we should be consistent in our approach and do the same
here. I will send a V2 with this change.
Jon
[0] https://lore.kernel.org/linux-tegra/ahmsDANt8D7RSYdK@orome/T/#t
--
nvpublic
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-29 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 15:08 [PATCH V2 1/2] firmware: tegra: bpmp: Propagate debugfs errors Jon Hunter
2026-05-29 15:08 ` [PATCH V2 2/2] firmware: tegra: bpmp: Add support for multi-socket platforms Jon Hunter
2026-05-29 15:50 ` Jon Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox