drivers/infiniband/sw/rxe/rxe_odp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rxe/rxe_odp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rxe/rxe_odp.c- Extension
.c- Size
- 13550 bytes
- Lines
- 579
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hmm.hlinux/libnvdimm.hrdma/ib_umem_odp.hrxe.h
Detected Declarations
struct prefetch_mr_workfunction Copyrightfunction rxe_odp_do_pagefault_and_lockfunction rxe_odp_init_pagesfunction rxe_odp_mr_init_userfunction rxe_check_pagefaultfunction rxe_odp_iova_to_indexfunction rxe_odp_iova_to_page_offsetfunction rxe_odp_map_range_and_lockfunction __rxe_odp_mr_copyfunction rxe_odp_mr_copyfunction rxe_odp_do_atomic_opfunction rxe_odp_atomic_opfunction rxe_odp_flush_pmem_iovafunction rxe_odp_do_atomic_writefunction rxe_ib_prefetch_mr_workfunction rxe_ib_prefetch_sg_listfunction rxe_ib_advise_mr_prefetchfunction rxe_ib_advise_mr
Annotated Snippet
struct prefetch_mr_work {
struct work_struct work;
u32 pf_flags;
u32 num_sge;
struct {
u64 io_virt;
struct rxe_mr *mr;
size_t length;
} frags[];
};
static void rxe_ib_prefetch_mr_work(struct work_struct *w)
{
struct prefetch_mr_work *work =
container_of(w, struct prefetch_mr_work, work);
int ret;
u32 i;
/*
* We rely on IB/core that work is executed
* if we have num_sge != 0 only.
*/
WARN_ON(!work->num_sge);
for (i = 0; i < work->num_sge; ++i) {
struct ib_umem_odp *umem_odp;
ret = rxe_odp_do_pagefault_and_lock(work->frags[i].mr,
work->frags[i].io_virt,
work->frags[i].length,
work->pf_flags);
if (ret < 0) {
rxe_dbg_mr(work->frags[i].mr,
"failed to prefetch the mr\n");
goto deref;
}
umem_odp = to_ib_umem_odp(work->frags[i].mr->umem);
mutex_unlock(&umem_odp->umem_mutex);
deref:
rxe_put(work->frags[i].mr);
}
kvfree(work);
}
static int rxe_ib_prefetch_sg_list(struct ib_pd *ibpd,
enum ib_uverbs_advise_mr_advice advice,
u32 pf_flags, struct ib_sge *sg_list,
u32 num_sge)
{
struct rxe_pd *pd = container_of(ibpd, struct rxe_pd, ibpd);
int ret = 0;
u32 i;
for (i = 0; i < num_sge; ++i) {
struct rxe_mr *mr;
struct ib_umem_odp *umem_odp;
mr = lookup_mr(pd, IB_ACCESS_LOCAL_WRITE,
sg_list[i].lkey, RXE_LOOKUP_LOCAL);
if (!mr) {
rxe_dbg_pd(pd, "mr with lkey %x not found\n",
sg_list[i].lkey);
return -EINVAL;
}
if (advice == IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_WRITE &&
!mr->umem->writable) {
rxe_dbg_mr(mr, "missing write permission\n");
rxe_put(mr);
return -EPERM;
}
ret = rxe_odp_do_pagefault_and_lock(
mr, sg_list[i].addr, sg_list[i].length, pf_flags);
if (ret < 0) {
rxe_dbg_mr(mr, "failed to prefetch the mr\n");
rxe_put(mr);
return ret;
}
umem_odp = to_ib_umem_odp(mr->umem);
mutex_unlock(&umem_odp->umem_mutex);
rxe_put(mr);
}
return 0;
Annotation
- Immediate include surface: `linux/hmm.h`, `linux/libnvdimm.h`, `rdma/ib_umem_odp.h`, `rxe.h`.
- Detected declarations: `struct prefetch_mr_work`, `function Copyright`, `function rxe_odp_do_pagefault_and_lock`, `function rxe_odp_init_pages`, `function rxe_odp_mr_init_user`, `function rxe_check_pagefault`, `function rxe_odp_iova_to_index`, `function rxe_odp_iova_to_page_offset`, `function rxe_odp_map_range_and_lock`, `function __rxe_odp_mr_copy`.
- 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.