drivers/gpu/drm/xe/xe_eu_stall.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_eu_stall.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_eu_stall.c- Extension
.c- Size
- 30578 bytes
- Lines
- 1012
- 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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/anon_inodes.hlinux/fs.hlinux/poll.hlinux/types.hdrm/drm_drv.hgenerated/xe_wa_oob.huapi/drm/xe_drm.hxe_bo.hxe_device.hxe_eu_stall.hxe_force_wake.hxe_gt_mcr.hxe_gt_printk.hxe_gt_topology.hxe_macros.hxe_observation.hxe_pm.hxe_trace.hxe_wa.hregs/xe_eu_stall_regs.hregs/xe_gt_regs.h
Detected Declarations
struct per_xecore_bufstruct xe_eu_stall_data_streamstruct xe_eu_stall_gtstruct eu_stall_open_propertiesstruct xe_eu_stall_data_pvcstruct xe_eu_stall_data_xe2struct xe_eu_stall_data_xe3pfunction xe_eu_stall_get_sampling_ratesfunction xe_eu_stall_get_per_xecore_buf_sizefunction xe_eu_stall_data_record_sizefunction num_data_rowsfunction xe_eu_stall_finifunction xe_eu_stall_initfunction set_prop_eu_stall_sampling_ratefunction set_prop_eu_stall_wait_num_reportsfunction set_prop_eu_stall_gt_idfunction xe_eu_stall_user_ext_set_propertyfunction xe_eu_stall_user_extensionsfunction buf_data_sizefunction eu_stall_data_buf_pollfunction clear_dropped_eviction_line_bitfunction xe_eu_stall_data_buf_readfunction readfunction xe_eu_stall_stream_read_lockedfunction readfunction readfunction xe_eu_stall_stream_freefunction xe_eu_stall_data_buf_destroyfunction xe_eu_stall_data_buf_allocfunction xe_eu_stall_stream_enablefunction for_each_dss_steeringfunction eu_stall_data_buf_poll_work_fnfunction xe_eu_stall_stream_initfunction for_each_dss_steeringfunction xe_eu_stall_stream_poll_lockedfunction xe_eu_stall_stream_pollfunction xe_eu_stall_enable_lockedfunction xe_eu_stall_disable_lockedfunction xe_eu_stall_stream_ioctl_lockedfunction xe_eu_stall_stream_ioctlfunction xe_eu_stall_stream_closefunction xe_eu_stall_stream_open_lockedfunction xe_eu_stall_stream_open
Annotated Snippet
static const struct file_operations fops_eu_stall = {
.owner = THIS_MODULE,
.llseek = noop_llseek,
.release = xe_eu_stall_stream_close,
.poll = xe_eu_stall_stream_poll,
.read = xe_eu_stall_stream_read,
.unlocked_ioctl = xe_eu_stall_stream_ioctl,
.compat_ioctl = xe_eu_stall_stream_ioctl,
};
static int xe_eu_stall_stream_open_locked(struct drm_device *dev,
struct eu_stall_open_properties *props,
struct drm_file *file)
{
struct xe_eu_stall_data_stream *stream;
struct xe_gt *gt = props->gt;
unsigned long f_flags = 0;
int ret, stream_fd;
/* Only one session can be active at any time */
if (gt->eu_stall->stream) {
xe_gt_dbg(gt, "EU stall sampling session already active\n");
return -EBUSY;
}
stream = kzalloc_obj(*stream);
if (!stream)
return -ENOMEM;
gt->eu_stall->stream = stream;
stream->gt = gt;
ret = xe_eu_stall_stream_init(stream, props);
if (ret) {
xe_gt_dbg(gt, "EU stall stream init failed : %d\n", ret);
goto err_free;
}
stream_fd = anon_inode_getfd("[xe_eu_stall]", &fops_eu_stall, stream, f_flags);
if (stream_fd < 0) {
ret = stream_fd;
xe_gt_dbg(gt, "EU stall inode get fd failed : %d\n", ret);
goto err_destroy;
}
/* Take a reference on the driver that will be kept with stream_fd
* until its release.
*/
drm_dev_get(>->tile->xe->drm);
return stream_fd;
err_destroy:
xe_eu_stall_data_buf_destroy(stream);
err_free:
xe_eu_stall_stream_free(stream);
return ret;
}
/**
* xe_eu_stall_stream_open - Open a xe EU stall data stream fd
*
* @dev: DRM device pointer
* @data: pointer to first struct @drm_xe_ext_set_property in
* the chain of input properties from the user space.
* @file: DRM file pointer
*
* This function opens a EU stall data stream with input properties from
* the user space.
*
* Returns: EU stall data stream fd on success or a negative error code.
*/
int xe_eu_stall_stream_open(struct drm_device *dev, u64 data, struct drm_file *file)
{
struct xe_device *xe = to_xe_device(dev);
struct eu_stall_open_properties props = {};
int ret;
if (!xe_eu_stall_supported_on_platform(xe)) {
drm_dbg(&xe->drm, "EU stall monitoring is not supported on this platform\n");
return -ENODEV;
}
if (xe_observation_paranoid && !perfmon_capable()) {
drm_dbg(&xe->drm, "Insufficient privileges for EU stall monitoring\n");
return -EACCES;
}
/* Initialize and set default values */
props.wait_num_reports = 1;
Annotation
- Immediate include surface: `linux/anon_inodes.h`, `linux/fs.h`, `linux/poll.h`, `linux/types.h`, `drm/drm_drv.h`, `generated/xe_wa_oob.h`, `uapi/drm/xe_drm.h`, `xe_bo.h`.
- Detected declarations: `struct per_xecore_buf`, `struct xe_eu_stall_data_stream`, `struct xe_eu_stall_gt`, `struct eu_stall_open_properties`, `struct xe_eu_stall_data_pvc`, `struct xe_eu_stall_data_xe2`, `struct xe_eu_stall_data_xe3p`, `function xe_eu_stall_get_sampling_rates`, `function xe_eu_stall_get_per_xecore_buf_size`, `function xe_eu_stall_data_record_size`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.