drivers/gpu/drm/drm_drv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_drv.c- Extension
.c- Size
- 36334 bytes
- Lines
- 1284
- 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.
- 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/bitops.hlinux/cgroup_dmem.hlinux/debugfs.hlinux/export.hlinux/fs.hlinux/module.hlinux/moduleparam.hlinux/mount.hlinux/pseudo_fs.hlinux/sched.hlinux/slab.hlinux/sprintf.hlinux/srcu.hlinux/xarray.hdrm/drm_accel.hdrm/drm_bridge.hdrm/drm_cache.hdrm/drm_client_event.hdrm/drm_color_mgmt.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_managed.hdrm/drm_mode_object.hdrm/drm_panic.hdrm/drm_print.hdrm/drm_privacy_screen_machine.hdrm/drm_ras_genl_family.hdrm_crtc_internal.hdrm_internal.h
Detected Declarations
function drm_minor_alloc_releasefunction drm_minor_allocfunction drm_minor_registerfunction drm_minor_unregisterfunction drm_minor_releasefunction drm_minor_releasefunction unpluggingfunction drm_dev_exitfunction drm_dev_exitfunction drm_dev_exitfunction drm_dev_set_dma_devfunction drm_dev_wedged_eventfunction for_each_set_bitfunction drm_fs_init_fs_contextfunction drm_fs_inode_freefunction devm_drm_dev_allocfunction drm_dev_initfunction devm_drm_dev_init_releasefunction devm_drm_dev_initfunction devm_drm_dev_allocfunction devm_drm_dev_allocfunction drm_dev_releasefunction drm_dev_getfunction drm_dev_putfunction drmm_cg_unregister_regionfunction create_compat_control_linkfunction remove_compat_control_linkfunction drm_dev_registerfunction drm_dev_registerfunction drm_stub_openfunction drm_core_exitfunction drm_core_initmodule init drm_core_initexport drm_put_devexport drm_dev_enterexport drm_dev_exitexport drm_dev_unplugexport drm_dev_set_dma_devexport drm_dev_wedged_eventexport __devm_drm_dev_allocexport __drm_dev_allocexport drm_dev_allocexport drm_dev_getexport drm_dev_putexport drmm_cgroup_register_regionexport drm_dev_registerexport drm_dev_unregister
Annotated Snippet
const struct file_operations *new_fops;
struct drm_minor *minor;
int err;
DRM_DEBUG("\n");
minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
if (IS_ERR(minor))
return PTR_ERR(minor);
new_fops = fops_get(minor->dev->driver->fops);
if (!new_fops) {
err = -ENODEV;
goto out;
}
replace_fops(filp, new_fops);
if (filp->f_op->open)
err = filp->f_op->open(inode, filp);
else
err = 0;
out:
drm_minor_release(minor);
return err;
}
static const struct file_operations drm_stub_fops = {
.owner = THIS_MODULE,
.open = drm_stub_open,
.llseek = noop_llseek,
};
static void drm_core_exit(void)
{
drm_ras_genl_family_unregister();
drm_privacy_screen_lookup_exit();
drm_panic_exit();
accel_core_exit();
unregister_chrdev(DRM_MAJOR, "drm");
drm_debugfs_remove_root();
drm_sysfs_destroy();
WARN_ON(!xa_empty(&drm_minors_xa));
drm_connector_ida_destroy();
}
static int __init drm_core_init(void)
{
int ret;
drm_connector_ida_init();
drm_memcpy_init_early();
ret = drm_sysfs_init();
if (ret < 0) {
DRM_ERROR("Cannot create DRM class: %d\n", ret);
goto error;
}
drm_debugfs_init_root();
drm_debugfs_bridge_params();
ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops);
if (ret < 0)
goto error;
ret = accel_core_init();
if (ret < 0)
goto error;
drm_panic_init();
drm_privacy_screen_lookup_init();
ret = drm_ras_genl_family_register();
if (ret < 0)
goto error;
drm_core_init_complete = true;
DRM_DEBUG("Initialized\n");
return 0;
error:
drm_core_exit();
return ret;
}
module_init(drm_core_init);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/cgroup_dmem.h`, `linux/debugfs.h`, `linux/export.h`, `linux/fs.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/mount.h`.
- Detected declarations: `function drm_minor_alloc_release`, `function drm_minor_alloc`, `function drm_minor_register`, `function drm_minor_unregister`, `function drm_minor_release`, `function drm_minor_release`, `function unplugging`, `function drm_dev_exit`, `function drm_dev_exit`, `function drm_dev_exit`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- 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.