drivers/gpu/drm/imagination/pvr_fw_trace.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imagination/pvr_fw_trace.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/imagination/pvr_fw_trace.c
Extension
.c
Size
15451 bytes
Lines
564
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations pvr_fw_trace_fops = {
	.owner = THIS_MODULE,
	.open = fw_trace_open,
	.read = seq_read,
	.llseek = seq_lseek,
	.release = fw_trace_release,
};

static int pvr_fw_trace_mask_get(void *data, u64 *value)
{
	struct pvr_device *pvr_dev = data;

	*value = pvr_dev->fw_dev.fw_trace.group_mask;

	return 0;
}

static int pvr_fw_trace_mask_set(void *data, u64 value)
{
	struct pvr_device *pvr_dev = data;
	const u32 group_mask = (u32)value;
	int err;

	err = validate_group_mask(pvr_dev, group_mask);
	if (err)
		return err;

	return update_logtype(pvr_dev, group_mask);
}

DEFINE_DEBUGFS_ATTRIBUTE(pvr_fw_trace_mask_fops, pvr_fw_trace_mask_get,
			 pvr_fw_trace_mask_set, "0x%08llx\n");

void
pvr_fw_trace_debugfs_init(struct pvr_device *pvr_dev, struct dentry *dir)
{
	struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace;

	if (!IS_ENABLED(CONFIG_DEBUG_FS))
		return;

	static_assert(ARRAY_SIZE(fw_trace->buffers) <= 10,
		      "The filename buffer is only large enough for a single-digit thread count");

	for (u32 thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); ++thread_nr) {
		char filename[8];

		snprintf(filename, ARRAY_SIZE(filename), "trace_%u", thread_nr);
		debugfs_create_file(filename, 0400, dir,
				    &fw_trace->buffers[thread_nr],
				    &pvr_fw_trace_fops);
	}

	debugfs_create_file("trace_mask", 0600, dir, pvr_dev,
			    &pvr_fw_trace_mask_fops);
}

Annotation

Implementation Notes