drivers/gpu/drm/xe/xe_device.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_device.c
Extension
.c
Size
39837 bytes
Lines
1515
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 xe_driver_fops = {
	.owner = THIS_MODULE,
	.open = drm_open,
	.release = drm_release_noglobal,
	.unlocked_ioctl = xe_drm_ioctl,
	.mmap = xe_mmap,
	.poll = drm_poll,
	.read = drm_read,
	.compat_ioctl = xe_drm_compat_ioctl,
	.llseek = noop_llseek,
#ifdef CONFIG_PROC_FS
	.show_fdinfo = drm_show_fdinfo,
#endif
	.fop_flags = FOP_UNSIGNED_OFFSET,
};

/**
 * xe_is_xe_file() - Is the file an xe device file?
 * @file: The file.
 *
 * Checks whether the file is opened against
 * an xe device.
 *
 * Return: %true if an xe file, %false if not.
 */
bool xe_is_xe_file(const struct file *file)
{
	return file->f_op == &xe_driver_fops;
}

static const struct drm_driver regular_driver = {
	.driver_features =
	    XE_DISPLAY_DRIVER_FEATURES |
	    DRIVER_GEM |
	    DRIVER_RENDER | DRIVER_SYNCOBJ |
	    DRIVER_SYNCOBJ_TIMELINE | DRIVER_GEM_GPUVA,
	.open = xe_file_open,
	.postclose = xe_file_close,

	.gem_prime_import = xe_gem_prime_import,

	.dumb_create = xe_bo_dumb_create,
	.dumb_map_offset = drm_gem_ttm_dumb_map_offset,
#ifdef CONFIG_PROC_FS
	.show_fdinfo = xe_drm_client_fdinfo,
#endif
	.ioctls = xe_ioctls,
	.num_ioctls = ARRAY_SIZE(xe_ioctls),
	.fops = &xe_driver_fops,
	.name = DRIVER_NAME,
	.desc = DRIVER_DESC,
	.major = DRIVER_MAJOR,
	.minor = DRIVER_MINOR,
	.patchlevel = DRIVER_PATCHLEVEL,
	XE_DISPLAY_DRIVER_OPS,
};

#ifdef CONFIG_PCI_IOV
static const struct drm_ioctl_desc xe_ioctls_admin_only[] = {
	DRM_IOCTL_DEF_DRV(XE_DEVICE_QUERY, xe_query_ioctl, DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(XE_OBSERVATION, xe_observation_ioctl, DRM_RENDER_ALLOW),
};

static const struct drm_driver admin_only_driver = {
	.driver_features =
	    XE_DISPLAY_DRIVER_FEATURES |
	    DRIVER_GEM | DRIVER_RENDER | DRIVER_GEM_GPUVA,
	.open = xe_file_open,
	.postclose = xe_file_close,
	.ioctls = xe_ioctls_admin_only,
	.num_ioctls = ARRAY_SIZE(xe_ioctls_admin_only),
	.fops = &xe_driver_fops,
	.name = DRIVER_NAME,
	.desc = DRIVER_DESC,
	.major = DRIVER_MAJOR,
	.minor = DRIVER_MINOR,
	.patchlevel = DRIVER_PATCHLEVEL,
	XE_DISPLAY_DRIVER_OPS,
};

/**
 * xe_device_is_admin_only() - Check whether device is admin only or not.
 * @xe: the &xe_device to check
 *
 * Return: true if the device is admin only, false otherwise.
 */
bool xe_device_is_admin_only(const struct xe_device *xe)
{
	KUNIT_STATIC_STUB_REDIRECT(xe_device_is_admin_only, xe);
	return xe->drm.driver == &admin_only_driver;

Annotation

Implementation Notes