drivers/gpu/drm/drm_atomic_uapi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_atomic_uapi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_atomic_uapi.c- Extension
.c- Size
- 53686 bytes
- Lines
- 1780
- 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.
- 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
drm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_atomic_uapi.hdrm/drm_framebuffer.hdrm/drm_print.hdrm/drm_drv.hdrm/drm_writeback.hdrm/drm_vblank.hdrm/drm_colorop.hlinux/export.hlinux/dma-fence.hlinux/uaccess.hlinux/sync_file.hlinux/file.hdrm_crtc_internal.h
Detected Declarations
struct drm_out_fence_statefunction Copyrightfunction modefunction drm_atomic_set_crtc_for_planefunction drm_atomic_set_fb_for_planefunction drm_atomic_set_colorop_for_planefunction drm_atomic_set_crtc_for_connectorfunction set_out_fence_for_crtcfunction set_out_fence_for_connectorfunction drm_atomic_crtc_set_propertyfunction drm_atomic_crtc_get_propertyfunction drm_atomic_plane_set_propertyfunction drm_atomic_plane_get_propertyfunction drm_atomic_color_set_data_propertyfunction drm_atomic_colorop_set_propertyfunction drm_atomic_colorop_get_propertyfunction drm_atomic_set_writeback_fb_for_connectorfunction drm_atomic_connector_set_propertyfunction drm_atomic_connector_get_propertyfunction drm_atomic_get_propertyfunction drm_atomic_connector_commit_dpmsfunction for_each_new_connector_in_statefunction drm_atomic_check_prop_changesfunction drm_atomic_set_propertyfunction setup_out_fencefunction prepare_signalingfunction for_each_new_crtc_in_statefunction for_each_new_connector_in_statefunction complete_signalingfunction for_each_new_crtc_in_statefunction set_async_flipfunction for_each_new_crtc_in_statefunction drm_mode_atomic_ioctlexport drm_atomic_set_mode_for_crtcexport drm_atomic_set_mode_prop_for_crtcexport drm_atomic_set_crtc_for_planeexport drm_atomic_set_fb_for_planeexport drm_atomic_set_colorop_for_planeexport drm_atomic_set_crtc_for_connector
Annotated Snippet
struct drm_out_fence_state {
s32 __user *out_fence_ptr;
struct sync_file *sync_file;
int fd;
};
static int setup_out_fence(struct drm_out_fence_state *fence_state,
struct dma_fence *fence)
{
fence_state->fd = get_unused_fd_flags(O_CLOEXEC);
if (fence_state->fd < 0)
return fence_state->fd;
if (put_user(fence_state->fd, fence_state->out_fence_ptr))
return -EFAULT;
fence_state->sync_file = sync_file_create(fence);
if (!fence_state->sync_file)
return -ENOMEM;
return 0;
}
static int prepare_signaling(struct drm_device *dev,
struct drm_atomic_commit *state,
struct drm_mode_atomic *arg,
struct drm_file *file_priv,
struct drm_out_fence_state **fence_state,
unsigned int *num_fences)
{
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
struct drm_connector *conn;
struct drm_connector_state *conn_state;
int i, c = 0, ret;
if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
return 0;
for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
s32 __user *fence_ptr;
fence_ptr = get_out_fence_for_crtc(crtc_state->state, crtc);
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT || fence_ptr) {
struct drm_pending_vblank_event *e;
e = create_vblank_event(crtc, arg->user_data);
if (!e)
return -ENOMEM;
crtc_state->event = e;
}
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
struct drm_pending_vblank_event *e = crtc_state->event;
if (!file_priv)
continue;
ret = drm_event_reserve_init(dev, file_priv, &e->base,
&e->event.base);
if (ret) {
kfree(e);
crtc_state->event = NULL;
return ret;
}
}
if (fence_ptr) {
struct dma_fence *fence;
struct drm_out_fence_state *f;
f = krealloc(*fence_state, sizeof(**fence_state) *
(*num_fences + 1), GFP_KERNEL);
if (!f)
return -ENOMEM;
memset(&f[*num_fences], 0, sizeof(*f));
f[*num_fences].out_fence_ptr = fence_ptr;
*fence_state = f;
fence = drm_crtc_create_fence(crtc);
if (!fence)
return -ENOMEM;
ret = setup_out_fence(&f[(*num_fences)++], fence);
if (ret) {
dma_fence_put(fence);
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_framebuffer.h`, `drm/drm_print.h`, `drm/drm_drv.h`, `drm/drm_writeback.h`, `drm/drm_vblank.h`.
- Detected declarations: `struct drm_out_fence_state`, `function Copyright`, `function mode`, `function drm_atomic_set_crtc_for_plane`, `function drm_atomic_set_fb_for_plane`, `function drm_atomic_set_colorop_for_plane`, `function drm_atomic_set_crtc_for_connector`, `function set_out_fence_for_crtc`, `function set_out_fence_for_connector`, `function drm_atomic_crtc_set_property`.
- 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.