drivers/infiniband/core/uverbs_main.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/uverbs_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/uverbs_main.c- Extension
.c- Size
- 36088 bytes
- Lines
- 1358
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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/module.hlinux/init.hlinux/device.hlinux/err.hlinux/fs.hlinux/poll.hlinux/sched.hlinux/file.hlinux/cdev.hlinux/anon_inodes.hlinux/slab.hlinux/sched/mm.hlinux/uaccess.hrdma/ib.hrdma/uverbs_std_types.hrdma/rdma_netlink.hrdma/ib_ucaps.huverbs.hcore_priv.hrdma_core.h
Detected Declarations
function uverbs_dealloc_mwfunction ib_uverbs_release_devfunction ib_uverbs_release_ucqfunction list_for_each_entry_safefunction ib_uverbs_release_ueventfunction ib_uverbs_detach_umcastfunction list_for_each_entry_safefunction ib_uverbs_event_readfunction ib_uverbs_async_event_readfunction ib_uverbs_comp_event_readfunction ib_uverbs_event_pollfunction ib_uverbs_async_event_pollfunction ib_uverbs_comp_event_pollfunction ib_uverbs_async_event_fasyncfunction ib_uverbs_comp_event_fasyncfunction ib_uverbs_comp_handlerfunction ib_uverbs_async_handlerfunction uverbs_uobj_eventfunction ib_uverbs_cq_event_handlerfunction ib_uverbs_qp_event_handlerfunction ib_uverbs_wq_event_handlerfunction ib_uverbs_srq_event_handlerfunction ib_uverbs_event_handlerfunction ib_uverbs_init_event_queuefunction ib_uverbs_init_async_event_filefunction verify_hdrfunction ib_uverbs_writefunction ib_uverbs_mmapfunction rdma_umap_openfunction rdma_umap_closefunction rdma_umap_faultfunction uverbs_user_mmap_disassociatefunction list_for_each_entry_safefunction rdma_user_mmap_disassociatefunction ib_uverbs_openfunction ufile_destroy_ucontextfunction uverbs_destroy_ufile_hwfunction ib_uverbs_closefunction ib_uverbs_get_nl_infofunction ibdev_showfunction abi_version_showfunction ib_uverbs_create_uapifunction ib_uverbs_add_onefunction ib_uverbs_free_hw_resourcesfunction ib_uverbs_remove_onefunction ib_uverbs_initfunction ib_uverbs_cleanupmodule init ib_uverbs_init
Annotated Snippet
const struct file_operations uverbs_event_fops = {
.owner = THIS_MODULE,
.read = ib_uverbs_comp_event_read,
.poll = ib_uverbs_comp_event_poll,
.release = uverbs_uobject_fd_release,
.fasync = ib_uverbs_comp_event_fasync,
};
const struct file_operations uverbs_async_event_fops = {
.owner = THIS_MODULE,
.read = ib_uverbs_async_event_read,
.poll = ib_uverbs_async_event_poll,
.release = uverbs_uobject_fd_release,
.fasync = ib_uverbs_async_event_fasync,
};
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
{
struct ib_uverbs_event_queue *ev_queue = cq_context;
struct ib_ucq_object *uobj;
struct ib_uverbs_event *entry;
unsigned long flags;
if (!ev_queue)
return;
spin_lock_irqsave(&ev_queue->lock, flags);
if (ev_queue->is_closed) {
spin_unlock_irqrestore(&ev_queue->lock, flags);
return;
}
entry = kmalloc_obj(*entry, GFP_ATOMIC);
if (!entry) {
spin_unlock_irqrestore(&ev_queue->lock, flags);
return;
}
uobj = cq->uobject;
entry->desc.comp.cq_handle = cq->uobject->uevent.uobject.user_handle;
entry->counter = &uobj->comp_events_reported;
list_add_tail(&entry->list, &ev_queue->event_list);
list_add_tail(&entry->obj_list, &uobj->comp_list);
spin_unlock_irqrestore(&ev_queue->lock, flags);
wake_up_interruptible(&ev_queue->poll_wait);
kill_fasync(&ev_queue->async_queue, SIGIO, POLL_IN);
}
void ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
__u64 element, __u64 event,
struct list_head *obj_list, u32 *counter)
{
struct ib_uverbs_event *entry;
unsigned long flags;
if (!async_file)
return;
spin_lock_irqsave(&async_file->ev_queue.lock, flags);
if (async_file->ev_queue.is_closed) {
spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
return;
}
entry = kmalloc_obj(*entry, GFP_ATOMIC);
if (!entry) {
spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
return;
}
entry->desc.async.element = element;
entry->desc.async.event_type = event;
entry->desc.async.reserved = 0;
entry->counter = counter;
list_add_tail(&entry->list, &async_file->ev_queue.event_list);
if (obj_list)
list_add_tail(&entry->obj_list, obj_list);
spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
wake_up_interruptible(&async_file->ev_queue.poll_wait);
kill_fasync(&async_file->ev_queue.async_queue, SIGIO, POLL_IN);
}
static void uverbs_uobj_event(struct ib_uevent_object *eobj,
struct ib_event *event)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/device.h`, `linux/err.h`, `linux/fs.h`, `linux/poll.h`, `linux/sched.h`, `linux/file.h`.
- Detected declarations: `function uverbs_dealloc_mw`, `function ib_uverbs_release_dev`, `function ib_uverbs_release_ucq`, `function list_for_each_entry_safe`, `function ib_uverbs_release_uevent`, `function ib_uverbs_detach_umcast`, `function list_for_each_entry_safe`, `function ib_uverbs_event_read`, `function ib_uverbs_async_event_read`, `function ib_uverbs_comp_event_read`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.