drm/xe/pf: Create separate debugfs tree for SR-IOV files

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
This commit is contained in:
Michal Wajdeczko
2025-09-28 16:00:24 +02:00
parent 1238b84ea3
commit 4d4af0d6cb

View 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;
parent->d_inode->i_private = xe;
dent->d_inode->i_private = xe;
drm_debugfs_create_files(debugfs_list, ARRAY_SIZE(debugfs_list), parent, minor);
/*
* /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;
pfdent->d_inode->i_private = xe;
pf_populate_pf(xe, pfdent);
/*
* /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);
}
}