drivers/gpu/drm/drm_mode_object.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_mode_object.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_mode_object.c- Extension
.c- Size
- 18458 bytes
- Lines
- 637
- 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_atomic.hdrm/drm_drv.hdrm/drm_device.hdrm/drm_file.hdrm/drm_mode_object.hdrm/drm_plane.hdrm/drm_print.hdrm_crtc_internal.h
Detected Declarations
function Copyrightfunction drm_mode_object_addfunction drm_mode_object_registerfunction drm_mode_object_unregisterfunction drm_mode_object_lease_requiredfunction drm_mode_object_putfunction drm_mode_object_getfunction drm_mode_object_putfunction drm_object_attach_propertyfunction valuefunction __drm_object_property_get_prop_valuefunction __drm_object_property_get_valuefunction drm_object_property_get_valuefunction drm_object_property_get_default_valuefunction drm_object_immutable_property_get_valuefunction drm_mode_object_get_propertiesfunction drm_mode_obj_get_properties_ioctlfunction set_property_legacyfunction set_property_atomicfunction drm_mode_obj_set_property_ioctlexport drm_mode_object_findexport drm_mode_object_putexport drm_mode_object_getexport drm_object_attach_propertyexport drm_object_property_set_valueexport drm_object_property_get_valueexport drm_object_property_get_default_valueexport drm_object_immutable_property_get_value
Annotated Snippet
if (obj_free_cb) {
obj->free_cb = obj_free_cb;
kref_init(&obj->refcount);
}
}
mutex_unlock(&dev->mode_config.idr_mutex);
return ret < 0 ? ret : 0;
}
/**
* drm_mode_object_add - allocate a new modeset identifier
* @dev: DRM device
* @obj: object pointer, used to generate unique ID
* @obj_type: object type
*
* Create a unique identifier based on @ptr in @dev's identifier space. Used
* for tracking modes, CRTCs and connectors.
*
* Returns:
* Zero on success, error code on failure.
*/
int drm_mode_object_add(struct drm_device *dev,
struct drm_mode_object *obj, uint32_t obj_type)
{
return __drm_mode_object_add(dev, obj, obj_type, true, NULL);
}
EXPORT_SYMBOL_FOR_TESTS_ONLY(drm_mode_object_add);
void drm_mode_object_register(struct drm_device *dev,
struct drm_mode_object *obj)
{
mutex_lock(&dev->mode_config.idr_mutex);
idr_replace(&dev->mode_config.object_idr, obj, obj->id);
mutex_unlock(&dev->mode_config.idr_mutex);
}
/**
* drm_mode_object_unregister - free a modeset identifier
* @dev: DRM device
* @object: object to free
*
* Free @id from @dev's unique identifier pool.
* This function can be called multiple times, and guards against
* multiple removals.
* These modeset identifiers are _not_ reference counted. Hence don't use this
* for reference counted modeset objects like framebuffers.
*/
void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object)
{
WARN_ON(!dev->driver->load && dev->registered && !object->free_cb);
mutex_lock(&dev->mode_config.idr_mutex);
if (object->id) {
idr_remove(&dev->mode_config.object_idr, object->id);
object->id = 0;
}
mutex_unlock(&dev->mode_config.idr_mutex);
}
/**
* drm_mode_object_lease_required - check types which must be leased to be used
* @type: type of object
*
* Returns whether the provided type of drm_mode_object must
* be owned or leased to be used by a process.
*/
bool drm_mode_object_lease_required(uint32_t type)
{
switch(type) {
case DRM_MODE_OBJECT_CRTC:
case DRM_MODE_OBJECT_CONNECTOR:
case DRM_MODE_OBJECT_PLANE:
return true;
default:
return false;
}
}
struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,
struct drm_file *file_priv,
uint32_t id, uint32_t type)
{
struct drm_mode_object *obj = NULL;
mutex_lock(&dev->mode_config.idr_mutex);
obj = idr_find(&dev->mode_config.object_idr, id);
if (obj && type != DRM_MODE_OBJECT_ANY && obj->type != type)
obj = NULL;
Annotation
- Immediate include surface: `linux/export.h`, `linux/uaccess.h`, `drm/drm_atomic.h`, `drm/drm_drv.h`, `drm/drm_device.h`, `drm/drm_file.h`, `drm/drm_mode_object.h`, `drm/drm_plane.h`.
- Detected declarations: `function Copyright`, `function drm_mode_object_add`, `function drm_mode_object_register`, `function drm_mode_object_unregister`, `function drm_mode_object_lease_required`, `function drm_mode_object_put`, `function drm_mode_object_get`, `function drm_mode_object_put`, `function drm_object_attach_property`, `function value`.
- 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.