]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firmware: tegra: bpmp: Add support for multi-socket platforms
authorJon Hunter <jonathanh@nvidia.com>
Fri, 29 May 2026 17:33:37 +0000 (18:33 +0100)
committerThierry Reding <treding@nvidia.com>
Sun, 31 May 2026 05:25:25 +0000 (07:25 +0200)
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 "<numa-node-id>-bpmp" subdirectory:

  /sys/kernel/debug/bpmp/0-bpmp/...
  /sys/kernel/debug/bpmp/1-bpmp/...

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>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/firmware/tegra/bpmp-debugfs.c

index 29037e2b31585765340dfaf3fd6c781da7bee821..33c6300af9642f901521b551e8710fba0981461f 100644 (file)
@@ -2,6 +2,8 @@
 /*
  * 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 +771,21 @@ free:
        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 +794,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), "%d-bpmp", 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 +822,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;
 }