drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_sriov_pf_sysfs.c
Extension
.c
Size
17889 bytes
Lines
665
Domain
Driver Families
Bucket
drivers/gpu
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 xe_sriov_kobj {
	struct kobject base;
	struct xe_device *xe;
	unsigned int vfid;
};
#define to_xe_sriov_kobj(p) container_of_const((p), struct xe_sriov_kobj, base)

struct xe_sriov_dev_attr {
	struct attribute attr;
	ssize_t (*show)(struct xe_device *xe, char *buf);
	ssize_t (*store)(struct xe_device *xe, const char *buf, size_t count);
};
#define to_xe_sriov_dev_attr(p) container_of_const((p), struct xe_sriov_dev_attr, attr)

#define XE_SRIOV_DEV_ATTR(NAME) \
struct xe_sriov_dev_attr xe_sriov_dev_attr_##NAME = \
	__ATTR(NAME, 0644, xe_sriov_dev_attr_##NAME##_show, xe_sriov_dev_attr_##NAME##_store)

#define XE_SRIOV_DEV_ATTR_RO(NAME) \
struct xe_sriov_dev_attr xe_sriov_dev_attr_##NAME = \
	__ATTR(NAME, 0444, xe_sriov_dev_attr_##NAME##_show, NULL)

#define XE_SRIOV_DEV_ATTR_WO(NAME) \
struct xe_sriov_dev_attr xe_sriov_dev_attr_##NAME = \
	__ATTR(NAME, 0200, NULL, xe_sriov_dev_attr_##NAME##_store)

struct xe_sriov_vf_attr {
	struct attribute attr;
	ssize_t (*show)(struct xe_device *xe, unsigned int vfid, char *buf);
	ssize_t (*store)(struct xe_device *xe, unsigned int vfid, const char *buf, size_t count);
};
#define to_xe_sriov_vf_attr(p) container_of_const((p), struct xe_sriov_vf_attr, attr)

#define XE_SRIOV_VF_ATTR(NAME) \
struct xe_sriov_vf_attr xe_sriov_vf_attr_##NAME = \
	__ATTR(NAME, 0644, xe_sriov_vf_attr_##NAME##_show, xe_sriov_vf_attr_##NAME##_store)

#define XE_SRIOV_VF_ATTR_RO(NAME) \
struct xe_sriov_vf_attr xe_sriov_vf_attr_##NAME = \
	__ATTR(NAME, 0444, xe_sriov_vf_attr_##NAME##_show, NULL)

#define XE_SRIOV_VF_ATTR_WO(NAME) \
struct xe_sriov_vf_attr xe_sriov_vf_attr_##NAME = \
	__ATTR(NAME, 0200, NULL, xe_sriov_vf_attr_##NAME##_store)

/* device level attributes go here */

#define DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(NAME, ITEM, TYPE)		\
											\
static ssize_t xe_sriov_dev_attr_##NAME##_store(struct xe_device *xe,			\
						const char *buf, size_t count)		\
{											\
	TYPE value;									\
	int err;									\
											\
	err = kstrto##TYPE(buf, 0, &value);						\
	if (err)									\
		return err;								\
											\
	err = xe_sriov_pf_provision_bulk_apply_##ITEM(xe, value);			\
	return err ?: count;								\
}											\
											\
static XE_SRIOV_DEV_ATTR_WO(NAME)

DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(exec_quantum_ms, eq, u32);
DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(preempt_timeout_us, pt, u32);
DEFINE_SIMPLE_BULK_PROVISIONING_SRIOV_DEV_ATTR_WO(vram_quota, vram, u64);

static const char * const sched_priority_names[] = {
	[GUC_SCHED_PRIORITY_LOW] = "low",
	[GUC_SCHED_PRIORITY_NORMAL] = "normal",
	[GUC_SCHED_PRIORITY_HIGH] = "high",
};

static bool sched_priority_change_allowed(unsigned int vfid)
{
	/* As of today GuC FW allows to selectively change only the PF priority. */
	return vfid == PFID;
}

static bool sched_priority_high_allowed(unsigned int vfid)
{
	/* As of today GuC FW allows to select 'high' priority only for the PF. */
	return vfid == PFID;
}

static bool sched_priority_bulk_high_allowed(struct xe_device *xe)
{
	/* all VFs are equal - it's sufficient to check VF1 only */

Annotation

Implementation Notes