drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
Extension
.c
Size
27191 bytes
Lines
916
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 sched_groups_fops = {
	.owner = THIS_MODULE,
	.open = sched_groups_open,
	.read = seq_read,
	.write = sched_groups_write,
	.llseek = seq_lseek,
	.release = single_release,
};

static int sched_groups_config_show(struct seq_file *m, void *data,
				    void (*get)(struct xe_gt *, unsigned int, u32 *, u32))
{
	struct drm_printer p = drm_seq_file_printer(m);
	unsigned int vfid = extract_vfid(m->private);
	struct xe_gt *gt = extract_gt(m->private);
	u32 values[GUC_MAX_SCHED_GROUPS];
	bool first = true;
	u8 group;

	get(gt, vfid, values, ARRAY_SIZE(values));

	for (group = 0; group < ARRAY_SIZE(values); group++) {
		drm_printf(&p, "%s%u", first ? "" : ",", values[group]);

		first = false;
	}

	drm_puts(&p, "\n");

	return 0;
}

static ssize_t sched_groups_config_write(struct file *file, const char __user *ubuf,
					 size_t size, loff_t *pos,
					 int (*set)(struct xe_gt *, unsigned int, u32 *, u32))
{
	struct dentry *parent = file_inode(file)->i_private;
	unsigned int vfid = extract_vfid(parent);
	struct xe_gt *gt = extract_gt(parent);
	u32 values[GUC_MAX_SCHED_GROUPS];
	int *input __free(kfree) = NULL;
	u32 count;
	int ret;
	int i;

	if (*pos)
		return -ESPIPE;

	if (!size)
		return -ENODATA;

	ret = parse_int_array_user(ubuf, min(size, GUC_MAX_SCHED_GROUPS * sizeof(u32)), &input);
	if (ret)
		return ret;

	count = input[0];
	if (count > GUC_MAX_SCHED_GROUPS)
		return -E2BIG;

	for (i = 0; i < count; i++) {
		if (input[i + 1] < 0 || input[i + 1] > S32_MAX)
			return -EINVAL;

		values[i] = input[i + 1];
	}

	guard(xe_pm_runtime)(gt_to_xe(gt));
	ret = set(gt, vfid, values, count);

	return ret < 0 ? ret : size;
}

#define DEFINE_SRIOV_GT_GRP_CFG_DEBUGFS_ATTRIBUTE(CONFIG)			\
static int sched_groups_##CONFIG##_show(struct seq_file *m, void *data)		\
{										\
	return sched_groups_config_show(m, data,				\
					xe_gt_sriov_pf_config_get_groups_##CONFIG); \
}										\
										\
static int sched_groups_##CONFIG##_open(struct inode *inode, struct file *file)	\
{										\
	return single_open(file, sched_groups_##CONFIG##_show,			\
			   inode->i_private);					\
}										\
										\
static ssize_t sched_groups_##CONFIG##_write(struct file *file,			\
					      const char __user *ubuf,		\
					      size_t size, loff_t *pos)		\
{										\
	return sched_groups_config_write(file, ubuf, size, pos,			\

Annotation

Implementation Notes