Skip to content

Commit d962178

Browse files
committed
drm/xe/pf: Expose basic info about VFs in debugfs
We already have function to print summary about VFs, but we missed to add debugfs attribute to make it visible. Do it now. Signed-off-by: Michal Wajdeczko <[email protected]> Reviewed-by: Piotr Piórkowski <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ffab82b commit d962178

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

drivers/gpu/drm/xe/xe_debugfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "xe_pm.h"
2121
#include "xe_pxp_debugfs.h"
2222
#include "xe_sriov.h"
23+
#include "xe_sriov_pf.h"
2324
#include "xe_step.h"
2425
#include "xe_wa.h"
2526

@@ -293,4 +294,7 @@ void xe_debugfs_register(struct xe_device *xe)
293294
xe_pxp_debugfs_register(xe->pxp);
294295

295296
fault_create_debugfs_attr("fail_gt_reset", root, &gt_reset_failure);
297+
298+
if (IS_SRIOV_PF(xe))
299+
xe_sriov_pf_debugfs_register(xe, root);
296300
}

drivers/gpu/drm/xe/xe_sriov_pf.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © 2023-2024 Intel Corporation
44
*/
55

6+
#include <linux/debugfs.h>
7+
#include <drm/drm_debugfs.h>
68
#include <drm/drm_managed.h>
79

810
#include "xe_assert.h"
@@ -102,3 +104,44 @@ void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p)
102104
drm_printf(p, "supported: %u\n", xe->sriov.pf.driver_max_vfs);
103105
drm_printf(p, "enabled: %u\n", pci_num_vf(pdev));
104106
}
107+
108+
static int simple_show(struct seq_file *m, void *data)
109+
{
110+
struct drm_printer p = drm_seq_file_printer(m);
111+
struct drm_info_node *node = m->private;
112+
struct dentry *parent = node->dent->d_parent;
113+
struct xe_device *xe = parent->d_inode->i_private;
114+
void (*print)(struct xe_device *, struct drm_printer *) = node->info_ent->data;
115+
116+
print(xe, &p);
117+
return 0;
118+
}
119+
120+
static const struct drm_info_list debugfs_list[] = {
121+
{ .name = "vfs", .show = simple_show, .data = xe_sriov_pf_print_vfs_summary },
122+
};
123+
124+
/**
125+
* xe_sriov_pf_debugfs_register - Register PF debugfs attributes.
126+
* @xe: the &xe_device
127+
* @root: the root &dentry
128+
*
129+
* Prepare debugfs attributes exposed by the PF.
130+
*/
131+
void xe_sriov_pf_debugfs_register(struct xe_device *xe, struct dentry *root)
132+
{
133+
struct drm_minor *minor = xe->drm.primary;
134+
struct dentry *parent;
135+
136+
/*
137+
* /sys/kernel/debug/dri/0/
138+
* ├── pf
139+
* │   ├── ...
140+
*/
141+
parent = debugfs_create_dir("pf", root);
142+
if (IS_ERR(parent))
143+
return;
144+
parent->d_inode->i_private = xe;
145+
146+
drm_debugfs_create_files(debugfs_list, ARRAY_SIZE(debugfs_list), parent, minor);
147+
}

drivers/gpu/drm/xe/xe_sriov_pf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88

99
#include <linux/types.h>
1010

11+
struct dentry;
1112
struct drm_printer;
1213
struct xe_device;
1314

1415
#ifdef CONFIG_PCI_IOV
1516
bool xe_sriov_pf_readiness(struct xe_device *xe);
1617
int xe_sriov_pf_init_early(struct xe_device *xe);
18+
void xe_sriov_pf_debugfs_register(struct xe_device *xe, struct dentry *root);
1719
void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p);
1820
#else
1921
static inline bool xe_sriov_pf_readiness(struct xe_device *xe)
@@ -25,6 +27,10 @@ static inline int xe_sriov_pf_init_early(struct xe_device *xe)
2527
{
2628
return 0;
2729
}
30+
31+
static inline void xe_sriov_pf_debugfs_register(struct xe_device *xe, struct dentry *root)
32+
{
33+
}
2834
#endif
2935

3036
#endif

0 commit comments

Comments
 (0)