drivers/gpu/drm/drm_syncobj.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_syncobj.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_syncobj.c- Extension
.c- Size
- 46990 bytes
- Lines
- 1722
- 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/anon_inodes.hlinux/dma-fence-unwrap.hlinux/eventfd.hlinux/export.hlinux/file.hlinux/fs.hlinux/sched/signal.hlinux/sync_file.hlinux/uaccess.hdrm/drm.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_gem.hdrm/drm_print.hdrm/drm_syncobj.hdrm/drm_utils.hdrm_internal.h
Detected Declarations
struct syncobj_wait_entrystruct syncobj_eventfd_entryfunction drm_syncobj_putfunction drm_syncobj_fence_add_waitfunction drm_syncobj_remove_waitfunction syncobj_eventfd_entry_freefunction drm_syncobj_add_eventfdfunction drm_syncobj_add_pointfunction drm_syncobj_replace_fencefunction drm_syncobj_assign_null_handlefunction drm_syncobj_findfunction drm_syncobj_freefunction drm_syncobj_get_handlefunction drm_syncobj_createfunction drm_syncobj_create_as_handlefunction drm_syncobj_destroyfunction drm_syncobj_file_releasefunction drm_syncobj_createfunction drm_syncobj_handle_to_fdfunction drm_syncobj_fd_to_handlefunction drm_syncobj_import_sync_file_fencefunction drm_syncobj_export_sync_filefunction drm_syncobj_openfunction drm_syncobj_releasefunction drm_syncobj_create_ioctlfunction drm_syncobj_destroy_ioctlfunction drm_syncobj_handle_to_fd_ioctlfunction drm_syncobj_fd_to_handle_ioctlfunction drm_syncobj_transfer_to_timelinefunction drm_syncobj_transfer_to_binaryfunction drm_syncobj_transfer_ioctlfunction syncobj_wait_fence_funcfunction syncobj_wait_syncobj_funcfunction drm_syncobj_array_wait_timeoutfunction drm_timeout_abs_to_jiffiesfunction drm_syncobj_array_waitfunction drm_syncobj_array_findfunction drm_syncobj_array_freefunction drm_syncobj_wait_ioctlfunction drm_syncobj_timeline_wait_ioctlfunction syncobj_eventfd_entry_fence_funcfunction syncobj_eventfd_entry_funcfunction drm_syncobj_eventfd_ioctlfunction drm_syncobj_reset_ioctlfunction drm_syncobj_signal_ioctlfunction drm_syncobj_timeline_signal_ioctlfunction drm_syncobj_query_ioctlfunction dma_fence_chain_for_each
Annotated Snippet
static const struct file_operations drm_syncobj_file_fops = {
.release = drm_syncobj_file_release,
};
/**
* drm_syncobj_get_fd - get a file descriptor from a syncobj
* @syncobj: Sync object to export
* @p_fd: out parameter with the new file descriptor
*
* Exports a sync object created with drm_syncobj_create() as a file descriptor.
*
* Returns 0 on success or a negative error value on failure.
*/
int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
{
struct file *file;
int fd;
fd = get_unused_fd_flags(O_CLOEXEC);
if (fd < 0)
return fd;
file = anon_inode_getfile("syncobj_file",
&drm_syncobj_file_fops,
syncobj, 0);
if (IS_ERR(file)) {
put_unused_fd(fd);
return PTR_ERR(file);
}
drm_syncobj_get(syncobj);
fd_install(fd, file);
*p_fd = fd;
return 0;
}
EXPORT_SYMBOL(drm_syncobj_get_fd);
static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
u32 handle, int *p_fd)
{
struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
int ret;
if (!syncobj)
return -EINVAL;
ret = drm_syncobj_get_fd(syncobj, p_fd);
drm_syncobj_put(syncobj);
return ret;
}
static int drm_syncobj_fd_to_handle(struct drm_file *file_private,
int fd, u32 *handle)
{
struct drm_syncobj *syncobj;
CLASS(fd, f)(fd);
int ret;
if (fd_empty(f))
return -EINVAL;
if (fd_file(f)->f_op != &drm_syncobj_file_fops)
return -EINVAL;
/* take a reference to put in the xarray */
syncobj = fd_file(f)->private_data;
drm_syncobj_get(syncobj);
ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b,
GFP_KERNEL);
if (ret)
drm_syncobj_put(syncobj);
return ret;
}
static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,
int fd, int handle, u64 point)
{
struct dma_fence *fence = sync_file_get_fence(fd);
struct drm_syncobj *syncobj;
if (!fence)
return -EINVAL;
syncobj = drm_syncobj_find(file_private, handle);
if (!syncobj) {
dma_fence_put(fence);
return -ENOENT;
Annotation
- Immediate include surface: `linux/anon_inodes.h`, `linux/dma-fence-unwrap.h`, `linux/eventfd.h`, `linux/export.h`, `linux/file.h`, `linux/fs.h`, `linux/sched/signal.h`, `linux/sync_file.h`.
- Detected declarations: `struct syncobj_wait_entry`, `struct syncobj_eventfd_entry`, `function drm_syncobj_put`, `function drm_syncobj_fence_add_wait`, `function drm_syncobj_remove_wait`, `function syncobj_eventfd_entry_free`, `function drm_syncobj_add_eventfd`, `function drm_syncobj_add_point`, `function drm_syncobj_replace_fence`, `function drm_syncobj_assign_null_handle`.
- 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.