From: Michal Wajdeczko Date: Sun, 28 Sep 2025 14:00:24 +0000 (+0200) Subject: drm/xe/pf: Create separate debugfs tree for SR-IOV files X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d4af0d6cbbfaf90ade642b29e50c745906c1187;p=thirdparty%2Fkernel%2Flinux.git 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 Cc: Lucas De Marchi Cc: Rodrigo Vivi Reviewed-by: Lucas De Marchi Link: https://lore.kernel.org/r/20250928140029.198847-3-michal.wajdeczko@intel.com --- diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c b/drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c index 2a1316048439b..37cc3a2976679 100644 --- a/drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c +++ b/drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c @@ -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); + } }