drivers/gpu/drm/drm_mode_config.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_mode_config.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_mode_config.c- Extension
.c- Size
- 22389 bytes
- Lines
- 741
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/uaccess.hdrm/drm_drv.hdrm/drm_encoder.hdrm/drm_file.hdrm/drm_framebuffer.hdrm/drm_managed.hdrm/drm_mode_config.hdrm/drm_print.hdrm/drm_colorop.hlinux/dma-resv.hdrm_crtc_internal.hdrm_internal.h
Detected Declarations
function Copyrightfunction drm_modeset_unregister_allfunction drm_mode_getresourcesfunction drm_dev_registerfunction drm_mode_config_resetfunction drm_mode_create_standard_propertiesfunction drm_mode_config_init_releasefunction drmm_add_actionfunction drm_mode_config_cleanupfunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safefunction full_encoder_maskfunction fixup_encoder_possible_clonesfunction validate_encoder_possible_clonesfunction drm_for_each_encoderfunction full_crtc_maskfunction validate_encoder_possible_crtcsfunction drm_mode_config_validatefunction drm_for_each_encoderfunction drm_for_each_crtcfunction drm_for_each_planeexport drm_mode_config_resetexport drmm_mode_config_initexport drm_mode_config_cleanup
Annotated Snippet
put_user(fb->base.id, fb_id + count)) {
mutex_unlock(&file_priv->fbs_lock);
return -EFAULT;
}
count++;
}
card_res->count_fbs = count;
mutex_unlock(&file_priv->fbs_lock);
card_res->max_height = dev->mode_config.max_height;
card_res->min_height = dev->mode_config.min_height;
card_res->max_width = dev->mode_config.max_width;
card_res->min_width = dev->mode_config.min_width;
count = 0;
crtc_id = u64_to_user_ptr(card_res->crtc_id_ptr);
drm_for_each_crtc(crtc, dev) {
if (drm_lease_held(file_priv, crtc->base.id)) {
if (count < card_res->count_crtcs &&
put_user(crtc->base.id, crtc_id + count))
return -EFAULT;
count++;
}
}
card_res->count_crtcs = count;
count = 0;
encoder_id = u64_to_user_ptr(card_res->encoder_id_ptr);
drm_for_each_encoder(encoder, dev) {
if (count < card_res->count_encoders &&
put_user(encoder->base.id, encoder_id + count))
return -EFAULT;
count++;
}
card_res->count_encoders = count;
drm_connector_list_iter_begin(dev, &conn_iter);
count = 0;
connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
/*
* FIXME: the connectors on the list may not be fully initialized yet,
* if the ioctl is called before the connectors are registered. (See
* drm_dev_register()->drm_modeset_register_all() for static and
* drm_connector_dynamic_register() for dynamic connectors.)
* The driver should only get registered after static connectors are
* fully initialized and dynamic connectors should be added to the
* connector list only after fully initializing them.
*/
drm_for_each_connector_iter(connector, &conn_iter) {
/* only expose writeback connectors if userspace understands them */
if (!file_priv->writeback_connectors &&
(connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))
continue;
if (drm_lease_held(file_priv, connector->base.id)) {
if (count < card_res->count_connectors &&
put_user(connector->base.id, connector_id + count)) {
drm_connector_list_iter_end(&conn_iter);
return -EFAULT;
}
count++;
}
}
card_res->count_connectors = count;
drm_connector_list_iter_end(&conn_iter);
return ret;
}
/**
* drm_mode_config_reset - call ->reset callbacks
* @dev: drm device
*
* This functions calls all the crtc's, encoder's and connector's ->reset
* callback. Drivers can use this in e.g. their driver load or resume code to
* reset hardware and software state.
*/
void drm_mode_config_reset(struct drm_device *dev)
{
struct drm_crtc *crtc;
struct drm_colorop *colorop;
struct drm_plane *plane;
struct drm_encoder *encoder;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter;
drm_for_each_colorop(colorop, dev)
drm_colorop_reset(colorop);
drm_for_each_plane(plane, dev)
Annotation
- Immediate include surface: `linux/export.h`, `linux/uaccess.h`, `drm/drm_drv.h`, `drm/drm_encoder.h`, `drm/drm_file.h`, `drm/drm_framebuffer.h`, `drm/drm_managed.h`, `drm/drm_mode_config.h`.
- Detected declarations: `function Copyright`, `function drm_modeset_unregister_all`, `function drm_mode_getresources`, `function drm_dev_register`, `function drm_mode_config_reset`, `function drm_mode_create_standard_properties`, `function drm_mode_config_init_release`, `function drmm_add_action`, `function drm_mode_config_cleanup`, `function list_for_each_entry_safe`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.