drivers/infiniband/hw/mlx5/devx.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/devx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/devx.c- Extension
.c- Size
- 93250 bytes
- Lines
- 3271
- 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
rdma/ib_user_verbs.hrdma/ib_verbs.hrdma/uverbs_types.hrdma/uverbs_ioctl.hrdma/mlx5_user_ioctl_cmds.hrdma/mlx5_user_ioctl_verbs.hrdma/ib_umem.hrdma/uverbs_std_types.hlinux/mlx5/driver.hlinux/mlx5/fs.hrdma/ib_ucaps.hmlx5_ib.hdevx.hqp.hlinux/xarray.hrdma/uverbs_named_ioctl.h
Detected Declarations
struct mlx5_async_cmdstruct devx_async_datastruct devx_async_event_datastruct devx_eventstruct devx_obj_eventstruct devx_event_subscriptionstruct devx_async_event_filestruct devx_umemstruct devx_umem_reg_cmdstruct devx_async_event_queuestruct devx_async_cmd_event_fileenum devx_obj_flagsfunction devx_ufile2uctxfunction set_uctx_ucapsfunction mlx5_ib_devx_createfunction mlx5_ib_devx_destroyfunction is_legacy_unaffiliated_event_numfunction is_legacy_obj_event_numfunction get_legacy_obj_typefunction get_dec_obj_typefunction get_event_obj_typefunction get_dec_obj_idfunction get_enc_obj_idfunction devx_get_created_obj_idfunction devx_get_obj_idfunction devx_is_valid_obj_idfunction devx_set_umem_validfunction devx_is_obj_create_cmdfunction devx_is_obj_modify_cmdfunction devx_is_obj_query_cmdfunction devx_is_whitelist_cmdfunction devx_get_uidfunction devx_is_general_cmdfunction UVERBS_HANDLERfunction doorbellsfunction UVERBS_HANDLERfunction devx_obj_build_destroy_cmdfunction devx_handle_mkey_indirectfunction devx_handle_mkey_createfunction devx_cleanup_subscriptionfunction devx_obj_cleanupfunction devx_cq_compfunction is_apu_cqfunction UVERBS_HANDLERfunction UVERBS_HANDLERfunction UVERBS_HANDLERfunction devx_init_event_queuefunction UVERBS_HANDLER
Annotated Snippet
static const struct file_operations devx_async_cmd_event_fops = {
.owner = THIS_MODULE,
.read = devx_async_cmd_event_read,
.poll = devx_async_cmd_event_poll,
.release = uverbs_uobject_fd_release,
};
static ssize_t devx_async_event_read(struct file *filp, char __user *buf,
size_t count, loff_t *pos)
{
struct devx_async_event_file *ev_file = filp->private_data;
struct devx_event_subscription *event_sub;
struct devx_async_event_data *event;
int ret = 0;
size_t eventsz;
bool omit_data;
void *event_data;
omit_data = ev_file->omit_data;
spin_lock_irq(&ev_file->lock);
if (ev_file->is_overflow_err) {
ev_file->is_overflow_err = 0;
spin_unlock_irq(&ev_file->lock);
return -EOVERFLOW;
}
while (list_empty(&ev_file->event_list)) {
spin_unlock_irq(&ev_file->lock);
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
if (wait_event_interruptible(ev_file->poll_wait,
(!list_empty(&ev_file->event_list) ||
ev_file->is_destroyed))) {
return -ERESTARTSYS;
}
spin_lock_irq(&ev_file->lock);
if (ev_file->is_destroyed) {
spin_unlock_irq(&ev_file->lock);
return -EIO;
}
}
if (omit_data) {
event_sub = list_first_entry(&ev_file->event_list,
struct devx_event_subscription,
event_list);
eventsz = sizeof(event_sub->cookie);
event_data = &event_sub->cookie;
} else {
event = list_first_entry(&ev_file->event_list,
struct devx_async_event_data, list);
eventsz = sizeof(struct mlx5_eqe) +
sizeof(struct mlx5_ib_uapi_devx_async_event_hdr);
event_data = &event->hdr;
}
if (eventsz > count) {
spin_unlock_irq(&ev_file->lock);
return -EINVAL;
}
if (omit_data)
list_del_init(&event_sub->event_list);
else
list_del(&event->list);
spin_unlock_irq(&ev_file->lock);
if (copy_to_user(buf, event_data, eventsz))
/* This points to an application issue, not a kernel concern */
ret = -EFAULT;
else
ret = eventsz;
if (!omit_data)
kfree(event);
return ret;
}
static __poll_t devx_async_event_poll(struct file *filp,
struct poll_table_struct *wait)
{
struct devx_async_event_file *ev_file = filp->private_data;
__poll_t pollflags = 0;
Annotation
- Immediate include surface: `rdma/ib_user_verbs.h`, `rdma/ib_verbs.h`, `rdma/uverbs_types.h`, `rdma/uverbs_ioctl.h`, `rdma/mlx5_user_ioctl_cmds.h`, `rdma/mlx5_user_ioctl_verbs.h`, `rdma/ib_umem.h`, `rdma/uverbs_std_types.h`.
- Detected declarations: `struct mlx5_async_cmd`, `struct devx_async_data`, `struct devx_async_event_data`, `struct devx_event`, `struct devx_obj_event`, `struct devx_event_subscription`, `struct devx_async_event_file`, `struct devx_umem`, `struct devx_umem_reg_cmd`, `struct devx_async_event_queue`.
- 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.