drivers/accel/qaic/qaic_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/accel/qaic/qaic_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/accel/qaic/qaic_debugfs.c
Extension
.c
Size
7410 bytes
Lines
307
Domain
Driver Families
Bucket
drivers/accel
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct bootlog_msg {
	/* Buffer for bootlog messages */
	char str[BOOTLOG_MSG_SIZE];
	/* Length of bootlog message */
	size_t len;
	/* Root struct of device, used to access device resources */
	struct qaic_device *qdev;
	/* Work struct to schedule work coming on QAIC_LOGGING channel */
	struct work_struct work;
};

struct bootlog_page {
	/* Node in list of bootlog pages maintained by root device struct */
	struct list_head node;
	/* Total size of the buffer that holds the bootlogs. It is PAGE_SIZE */
	unsigned int size;
	/* Offset for the next bootlog */
	unsigned int offset;
};

static int bootlog_show(struct seq_file *s, void *unused)
{
	struct bootlog_page *page;
	struct qaic_device *qdev;
	size_t len;
	void *log;

	qdev = s->private;
	mutex_lock(&qdev->bootlog_mutex);
	list_for_each_entry(page, &qdev->bootlog, node) {
		log = page + 1;
		len = page->offset - sizeof(*page);
		seq_write(s, log, len);
	}
	mutex_unlock(&qdev->bootlog_mutex);

	return 0;
}

DEFINE_SHOW_ATTRIBUTE(bootlog);

static int fifo_size_show(struct seq_file *s, void *unused)
{
	struct dma_bridge_chan *dbc = s->private;

	seq_printf(s, "%u\n", dbc->nelem);
	return 0;
}

DEFINE_SHOW_ATTRIBUTE(fifo_size);

static int queued_show(struct seq_file *s, void *unused)
{
	struct dma_bridge_chan *dbc = s->private;
	u32 tail = 0, head = 0;

	qaic_data_get_fifo_info(dbc, &head, &tail);

	if (head == U32_MAX || tail == U32_MAX)
		seq_printf(s, "%u\n", 0);
	else if (head > tail)
		seq_printf(s, "%u\n", dbc->nelem - head + tail);
	else
		seq_printf(s, "%u\n", tail - head);

	return 0;
}

DEFINE_SHOW_ATTRIBUTE(queued);

void qaic_debugfs_init(struct qaic_drm_device *qddev)
{
	struct qaic_device *qdev = qddev->qdev;
	struct dentry *debugfs_root;
	struct dentry *debugfs_dir;
	char name[QAIC_DBC_DIR_NAME];
	u32 i;

	debugfs_root = to_drm(qddev)->debugfs_root;

	debugfs_create_file("bootlog", 0400, debugfs_root, qdev, &bootlog_fops);
	/*
	 * 256 dbcs per device is likely the max we will ever see and lets static checking see a
	 * reasonable range.
	 */
	for (i = 0; i < qdev->num_dbc && i < 256; ++i) {
		snprintf(name, QAIC_DBC_DIR_NAME, "dbc%03u", i);
		debugfs_dir = debugfs_create_dir(name, debugfs_root);
		debugfs_create_file("fifo_size", 0400, debugfs_dir, &qdev->dbc[i], &fifo_size_fops);
		debugfs_create_file("queued", 0400, debugfs_dir, &qdev->dbc[i], &queued_fops);

Annotation

Implementation Notes