drivers/infiniband/sw/rxe/rxe_mmap.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rxe/rxe_mmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rxe/rxe_mmap.c- Extension
.c- Size
- 3832 bytes
- Lines
- 162
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/vmalloc.hlinux/mm.hlinux/errno.hrdma/uverbs_ioctl.hrxe.hrxe_loc.hrxe_queue.h
Detected Declarations
function Copyrightfunction rxe_vma_openfunction rxe_vma_closefunction rxe_mmap
Annotated Snippet
if (size > ip->info.size) {
rxe_dbg_dev(rxe, "mmap region is larger than the object!\n");
spin_unlock_bh(&rxe->pending_lock);
ret = -EINVAL;
goto done;
}
goto found_it;
}
rxe_dbg_dev(rxe, "unable to find pending mmap info\n");
spin_unlock_bh(&rxe->pending_lock);
ret = -EINVAL;
goto done;
found_it:
/*
* Increment refcount and check whether it is being freed atm while
* holding lock to prevent UAF
*/
if (!kref_get_unless_zero(&ip->ref)) {
spin_unlock_bh(&rxe->pending_lock);
ret = -ENXIO;
goto done;
}
list_del_init(&ip->pending_mmaps);
spin_unlock_bh(&rxe->pending_lock);
vma->vm_ops = &rxe_vm_ops;
vma->vm_private_data = ip;
ret = remap_vmalloc_range(vma, ip->obj, 0);
if (ret) {
vma->vm_private_data = NULL;
vma->vm_ops = NULL;
kref_put(&ip->ref, rxe_mmap_release);
rxe_dbg_dev(rxe, "err %d from remap_vmalloc_range\n", ret);
goto done;
}
done:
return ret;
}
/*
* Allocate information for rxe_mmap
*/
struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *rxe, u32 size,
struct ib_udata *udata, void *obj)
{
struct rxe_mmap_info *ip;
if (!udata)
return ERR_PTR(-EINVAL);
ip = kmalloc_obj(*ip);
if (!ip)
return ERR_PTR(-ENOMEM);
size = PAGE_ALIGN(size);
spin_lock_bh(&rxe->mmap_offset_lock);
if (rxe->mmap_offset == 0)
rxe->mmap_offset = ALIGN(PAGE_SIZE, SHMLBA);
ip->info.offset = rxe->mmap_offset;
rxe->mmap_offset += ALIGN(size, SHMLBA);
spin_unlock_bh(&rxe->mmap_offset_lock);
INIT_LIST_HEAD(&ip->pending_mmaps);
ip->info.size = size;
ip->context =
container_of(udata, struct uverbs_attr_bundle, driver_udata)
->context;
ip->obj = obj;
kref_init(&ip->ref);
return ip;
}
Annotation
- Immediate include surface: `linux/vmalloc.h`, `linux/mm.h`, `linux/errno.h`, `rdma/uverbs_ioctl.h`, `rxe.h`, `rxe_loc.h`, `rxe_queue.h`.
- Detected declarations: `function Copyright`, `function rxe_vma_open`, `function rxe_vma_close`, `function rxe_mmap`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- 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.