]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Create separate debugfs tree for SR-IOV files
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Sun, 28 Sep 2025 14:00:24 +0000 (16:00 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 29 Sep 2025 21:58:43 +0000 (23:58 +0200)
Currently we expose debugfs files related to SR-IOV functions
together with other native files, but that approach will not
scale well as we plan to add more attributes and also expose
some of them on the per-tile basis.

Start building separate tree for SR-IOV specific debugfs files
where we can replicate similar files per every SR-IOV function:

   /sys/kernel/debug/dri/BDF/
   ├── sriov
   │   ├── pf
   │   │   ├── tile0
   │   │   │   ├── gt0
   │   │   │   ├── gt1
   │   │   │   :
   │   │   ├── tile1
   │   │   :
   │   ├── vf1
   │   │   ├── tile0
   │   │   │   ├── gt0
   │   │   │   ├── gt1
   │   │   │   :
   │   │   :
   │   ├── vf2
   │   ├── ...

We will populate this new tree in upcoming patches.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250928140029.198847-3-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c

index 2a1316048439be8cdeef986286c004d5514bfc0f..37cc3a2976679c0e09fb7b01a8cca9a1e9ac7696 100644 (file)
@@ -9,7 +9,9 @@
 #include "xe_device_types.h"
 #include "xe_sriov_pf.h"
 #include "xe_sriov_pf_debugfs.h"
+#include "xe_sriov_pf_helpers.h"
 #include "xe_sriov_pf_service.h"
+#include "xe_sriov_printk.h"
 
 static int simple_show(struct seq_file *m, void *data)
 {
@@ -28,27 +30,65 @@ static const struct drm_info_list debugfs_list[] = {
        { .name = "versions", .show = simple_show, .data = xe_sriov_pf_service_print_versions },
 };
 
+static void pf_populate_pf(struct xe_device *xe, struct dentry *pfdent)
+{
+       struct drm_minor *minor = xe->drm.primary;
+
+       drm_debugfs_create_files(debugfs_list, ARRAY_SIZE(debugfs_list), pfdent, minor);
+}
+
 /**
  * xe_sriov_pf_debugfs_register - Register PF debugfs attributes.
  * @xe: the &xe_device
  * @root: the root &dentry
  *
- * Prepare debugfs attributes exposed by the PF.
+ * Create separate directory that will contain all SR-IOV related files,
+ * organized per each SR-IOV function (PF, VF1, VF2, ..., VFn).
  */
 void xe_sriov_pf_debugfs_register(struct xe_device *xe, struct dentry *root)
 {
-       struct drm_minor *minor = xe->drm.primary;
-       struct dentry *parent;
+       int totalvfs = xe_sriov_pf_get_totalvfs(xe);
+       struct dentry *pfdent;
+       struct dentry *vfdent;
+       struct dentry *dent;
+       char vfname[16]; /* should be more than enough for "vf%u\0" and VFID(UINT_MAX) */
+       unsigned int n;
 
        /*
-        *      /sys/kernel/debug/dri/0/
-        *      ├── pf
+        *      /sys/kernel/debug/dri/BDF/
+        *      ├── sriov         # d_inode->i_private = (xe_device*)
         *      │   ├── ...
         */
-       parent = debugfs_create_dir("pf", root);
-       if (IS_ERR(parent))
+       dent = debugfs_create_dir("sriov", root);
+       if (IS_ERR(dent))
+               return;
+       dent->d_inode->i_private = xe;
+
+       /*
+        *      /sys/kernel/debug/dri/BDF/
+        *      ├── sriov         # d_inode->i_private = (xe_device*)
+        *      │   ├── pf              # d_inode->i_private = (xe_device*)
+        *      │   │   ├── ...
+        */
+       pfdent = debugfs_create_dir("pf", dent);
+       if (IS_ERR(pfdent))
                return;
-       parent->d_inode->i_private = xe;
+       pfdent->d_inode->i_private = xe;
+
+       pf_populate_pf(xe, pfdent);
 
-       drm_debugfs_create_files(debugfs_list, ARRAY_SIZE(debugfs_list), parent, minor);
+       /*
+        *      /sys/kernel/debug/dri/BDF/
+        *      ├── sriov         # d_inode->i_private = (xe_device*)
+        *      │   ├── vf1             # d_inode->i_private = VFID(1)
+        *      │   ├── vf2             # d_inode->i_private = VFID(2)
+        *      │   ├── ...
+        */
+       for (n = 1; n <= totalvfs; n++) {
+               snprintf(vfname, sizeof(vfname), "vf%u", VFID(n));
+               vfdent = debugfs_create_dir(vfname, dent);
+               if (IS_ERR(vfdent))
+                       return;
+               vfdent->d_inode->i_private = (void *)(uintptr_t)VFID(n);
+       }
 }