drivers/gpu/drm/i915/i915_gpu_error.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_gpu_error.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_gpu_error.c- Extension
.c- Size
- 66506 bytes
- Lines
- 2623
- 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/ascii85.hlinux/debugfs.hlinux/highmem.hlinux/nmi.hlinux/folio_batch.hlinux/scatterlist.hlinux/string_helpers.hlinux/utsname.hlinux/zlib.hdrm/drm_cache.hdrm/drm_print.hdisplay/intel_display_snapshot.hgem/i915_gem_context.hgem/i915_gem_lmem.hgt/intel_engine_regs.hgt/intel_gt.hgt/intel_gt_mcr.hgt/intel_gt_pm.hgt/intel_gt_regs.hgt/uc/intel_guc_capture.hi915_driver.hi915_drv.hi915_gpu_error.hi915_memcpy.hi915_reg.hi915_scatterlist.hi915_sysfs.hi915_utils.h
Detected Declarations
struct i915_vma_compressstruct i915_vma_compressstruct intel_engine_capture_vmafunction Copyrightfunction __i915_error_growfunction i915_error_vprintffunction i915_error_putsfunction __i915_printfn_errorfunction i915_error_printerfunction pool_finifunction pool_refillfunction pool_initfunction pool_freefunction compress_initfunction compress_startfunction compress_pagefunction compress_flushfunction compress_finishfunction compress_finifunction err_compression_markerfunction compress_initfunction compress_startfunction compress_pagefunction compress_flushfunction compress_finishfunction err_compression_markerfunction error_print_instdonefunction error_print_requestfunction error_print_contextfunction __find_vmafunction intel_gpu_error_find_batchfunction error_print_enginefunction i915_error_printffunction intel_gpu_error_print_vmafunction err_print_capabilitiesfunction err_print_paramsfunction err_print_pciidfunction err_print_guc_ctbfunction print_range_linefunction err_print_guc_hw_statefunction err_print_ucfunction err_free_sglfunction err_print_gt_infofunction err_print_gt_global_nongucfunction err_print_gt_globalfunction err_print_gt_fencesfunction err_print_gt_enginesfunction __err_print_to_sgl
Annotated Snippet
static const struct file_operations i915_gpu_info_fops = {
.owner = THIS_MODULE,
.open = i915_gpu_info_open,
.read = gpu_state_read,
.llseek = default_llseek,
.release = gpu_state_release,
};
static ssize_t
i915_error_state_write(struct file *filp,
const char __user *ubuf,
size_t cnt,
loff_t *ppos)
{
struct i915_gpu_coredump *error = filp->private_data;
if (!error)
return 0;
drm_dbg(&error->i915->drm, "Resetting error state\n");
i915_reset_error_state(error->i915);
return cnt;
}
static int i915_error_state_open(struct inode *inode, struct file *file)
{
struct i915_gpu_coredump *error;
error = i915_first_error_state(inode->i_private);
if (IS_ERR(error))
return PTR_ERR(error);
file->private_data = error;
return 0;
}
static const struct file_operations i915_error_state_fops = {
.owner = THIS_MODULE,
.open = i915_error_state_open,
.read = gpu_state_read,
.write = i915_error_state_write,
.llseek = default_llseek,
.release = gpu_state_release,
};
void i915_gpu_error_debugfs_register(struct drm_i915_private *i915)
{
struct dentry *debugfs_root = i915->drm.debugfs_root;
debugfs_create_file("i915_error_state", 0644, debugfs_root, i915,
&i915_error_state_fops);
debugfs_create_file("i915_gpu_info", 0644, debugfs_root, i915,
&i915_gpu_info_fops);
}
static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
struct device *kdev = kobj_to_dev(kobj);
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
struct i915_gpu_coredump *gpu;
ssize_t ret = 0;
/*
* FIXME: Concurrent clients triggering resets and reading + clearing
* dumps can cause inconsistent sysfs reads when a user calls in with a
* non-zero offset to complete a prior partial read but the
* gpu_coredump has been cleared or replaced.
*/
gpu = i915_first_error_state(i915);
if (IS_ERR(gpu)) {
ret = PTR_ERR(gpu);
} else if (gpu) {
ret = i915_gpu_coredump_copy_to_buffer(gpu, buf, off, count);
i915_gpu_coredump_put(gpu);
} else {
const char *str = "No error state collected\n";
size_t len = strlen(str);
if (off < len) {
ret = min_t(size_t, count, len - off);
memcpy(buf, str + off, ret);
}
}
return ret;
Annotation
- Immediate include surface: `linux/ascii85.h`, `linux/debugfs.h`, `linux/highmem.h`, `linux/nmi.h`, `linux/folio_batch.h`, `linux/scatterlist.h`, `linux/string_helpers.h`, `linux/utsname.h`.
- Detected declarations: `struct i915_vma_compress`, `struct i915_vma_compress`, `struct intel_engine_capture_vma`, `function Copyright`, `function __i915_error_grow`, `function i915_error_vprintf`, `function i915_error_puts`, `function __i915_printfn_error`, `function i915_error_printer`, `function pool_fini`.
- 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.