Skip to content

Commit b05d357

Browse files
committed
accel/qaic: Add fifo size debugfs
Each DMA Bridge Channel (dbc) has a unique configured fifo size which is specified by the userspace client of that dbc. Since the fifo is circular, it is useful to know the configured size when debugging issues. Add a per-dbc subdirectory in debugfs and in each subdirectory add a fifo_size entry that will display the size of that dbc's fifo when read. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com> Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com> Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240322175730.3855440-3-quic_jhugo@quicinc.com
1 parent 5f8df5c commit b05d357

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

drivers/accel/qaic/qaic_debugfs.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/overflow.h>
1313
#include <linux/pci.h>
1414
#include <linux/seq_file.h>
15+
#include <linux/sprintf.h>
1516
#include <linux/string.h>
1617
#include <linux/types.h>
1718
#include <linux/workqueue.h>
@@ -21,6 +22,7 @@
2122

2223
#define BOOTLOG_POOL_SIZE 16
2324
#define BOOTLOG_MSG_SIZE 512
25+
#define QAIC_DBC_DIR_NAME 9
2426

2527
struct bootlog_msg {
2628
/* Buffer for bootlog messages */
@@ -75,14 +77,47 @@ static const struct file_operations bootlog_fops = {
7577
.release = single_release,
7678
};
7779

80+
static int read_dbc_fifo_size(struct seq_file *s, void *unused)
81+
{
82+
struct dma_bridge_chan *dbc = s->private;
83+
84+
seq_printf(s, "%u\n", dbc->nelem);
85+
return 0;
86+
}
87+
88+
static int fifo_size_open(struct inode *inode, struct file *file)
89+
{
90+
return single_open(file, read_dbc_fifo_size, inode->i_private);
91+
}
92+
93+
static const struct file_operations fifo_size_fops = {
94+
.owner = THIS_MODULE,
95+
.open = fifo_size_open,
96+
.read = seq_read,
97+
.llseek = seq_lseek,
98+
.release = single_release,
99+
};
100+
78101
void qaic_debugfs_init(struct qaic_drm_device *qddev)
79102
{
80103
struct qaic_device *qdev = qddev->qdev;
81104
struct dentry *debugfs_root;
105+
struct dentry *debugfs_dir;
106+
char name[QAIC_DBC_DIR_NAME];
107+
u32 i;
82108

83109
debugfs_root = to_drm(qddev)->debugfs_root;
84110

85111
debugfs_create_file("bootlog", 0400, debugfs_root, qdev, &bootlog_fops);
112+
/*
113+
* 256 dbcs per device is likely the max we will ever see and lets static checking see a
114+
* reasonable range.
115+
*/
116+
for (i = 0; i < qdev->num_dbc && i < 256; ++i) {
117+
snprintf(name, QAIC_DBC_DIR_NAME, "dbc%03u", i);
118+
debugfs_dir = debugfs_create_dir(name, debugfs_root);
119+
debugfs_create_file("fifo_size", 0400, debugfs_dir, &qdev->dbc[i], &fifo_size_fops);
120+
}
86121
}
87122

88123
static struct bootlog_page *alloc_bootlog_page(struct qaic_device *qdev)

0 commit comments

Comments
 (0)