drivers/infiniband/sw/rxe/rxe_mr.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rxe/rxe_mr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rxe/rxe_mr.c- Extension
.c- Size
- 18263 bytes
- Lines
- 817
- 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/libnvdimm.hrxe.hrxe_loc.h
Detected Declarations
function Copyrightfunction mr_check_rangefunction rxe_mr_initfunction rxe_mr_init_dmafunction basefunction rxe_mr_iova_to_page_offsetfunction is_pmem_pagefunction rxe_mr_fill_pages_from_sgtfunction __alloc_mr_page_infofunction alloc_mr_page_infofunction free_mr_page_infofunction rxe_mr_init_userfunction rxe_mr_init_fastfunction pagefunction rxe_map_mr_sgfunction rxe_mr_copy_xarrayfunction rxe_mr_copy_dmafunction rxe_mr_copyfunction copy_datafunction rxe_mr_flush_pmem_iovafunction rxe_flush_pmem_iovafunction rxe_mr_do_atomic_opfunction rxe_mr_do_atomic_writefunction advance_dma_datafunction rxe_invalidate_mrfunction rxe_reg_fast_mrfunction rxe_mr_cleanup
Annotated Snippet
if (persistent && !is_pmem_page(page)) {
rxe_dbg_mr(mr, "Page can't be persistent\n");
return -EINVAL;
}
mr->page_info[mr->nbuf].page = page;
mr->page_info[mr->nbuf].offset = 0;
mr->nbuf++;
if (!__sg_page_iter_next(&sg_iter))
break;
}
return 0;
}
static int __alloc_mr_page_info(struct rxe_mr *mr, int num_pages)
{
mr->page_info = kzalloc_objs(struct rxe_mr_page, num_pages);
if (!mr->page_info)
return -ENOMEM;
mr->max_allowed_buf = num_pages;
mr->nbuf = 0;
return 0;
}
static int alloc_mr_page_info(struct rxe_mr *mr, int num_pages)
{
int ret;
WARN_ON(mr->num_buf);
ret = __alloc_mr_page_info(mr, num_pages);
if (ret)
return ret;
mr->num_buf = num_pages;
return 0;
}
static void free_mr_page_info(struct rxe_mr *mr)
{
if (!mr->page_info)
return;
kfree(mr->page_info);
mr->page_info = NULL;
}
int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length,
int access, struct rxe_mr *mr)
{
struct ib_umem *umem;
int err;
rxe_mr_init(access, mr);
umem = ib_umem_get_va(&rxe->ib_dev, start, length, access);
if (IS_ERR(umem)) {
rxe_dbg_mr(mr, "Unable to pin memory region err = %d\n",
(int)PTR_ERR(umem));
return PTR_ERR(umem);
}
err = alloc_mr_page_info(mr, ib_umem_num_pages(umem));
if (err)
goto err2;
err = rxe_mr_fill_pages_from_sgt(mr, &umem->sgt_append.sgt);
if (err)
goto err1;
mr->umem = umem;
mr->ibmr.type = IB_MR_TYPE_USER;
mr->state = RXE_MR_STATE_VALID;
return 0;
err1:
free_mr_page_info(mr);
err2:
ib_umem_release(umem);
return err;
}
int rxe_mr_init_fast(int max_pages, struct rxe_mr *mr)
{
int err;
Annotation
- Immediate include surface: `linux/libnvdimm.h`, `rxe.h`, `rxe_loc.h`.
- Detected declarations: `function Copyright`, `function mr_check_range`, `function rxe_mr_init`, `function rxe_mr_init_dma`, `function base`, `function rxe_mr_iova_to_page_offset`, `function is_pmem_page`, `function rxe_mr_fill_pages_from_sgt`, `function __alloc_mr_page_info`, `function alloc_mr_page_info`.
- 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.