drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c- Extension
.c- Size
- 8420 bytes
- Lines
- 305
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/errno.hlinux/slab.hlinux/bitmap.hpvrdma.h
Detected Declarations
function pvrdma_page_dir_initfunction pvrdma_page_dir_get_dmafunction pvrdma_page_dir_cleanup_pagesfunction pvrdma_page_dir_cleanup_tablesfunction pvrdma_page_dir_cleanupfunction pvrdma_page_dir_insert_dmafunction pvrdma_page_dir_insert_umemfunction rdma_umem_for_each_dma_blockfunction pvrdma_page_dir_insert_page_listfunction pvrdma_qp_cap_to_ibfunction ib_qp_cap_to_pvrdmafunction pvrdma_gid_to_ibfunction ib_gid_to_pvrdmafunction pvrdma_global_route_to_ibfunction ib_global_route_to_pvrdmafunction pvrdma_ah_attr_to_rdmafunction rdma_ah_attr_to_pvrdmafunction ib_gid_type_to_pvrdma
Annotated Snippet
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/bitmap.h>
#include "pvrdma.h"
int pvrdma_page_dir_init(struct pvrdma_dev *dev, struct pvrdma_page_dir *pdir,
u64 npages, bool alloc_pages)
{
u64 i;
if (npages > PVRDMA_PAGE_DIR_MAX_PAGES)
return -EINVAL;
memset(pdir, 0, sizeof(*pdir));
pdir->dir = dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
&pdir->dir_dma, GFP_KERNEL);
if (!pdir->dir)
goto err;
pdir->ntables = PVRDMA_PAGE_DIR_TABLE(npages - 1) + 1;
pdir->tables = kzalloc_objs(*pdir->tables, pdir->ntables);
if (!pdir->tables)
goto err;
for (i = 0; i < pdir->ntables; i++) {
pdir->tables[i] = dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
(dma_addr_t *)&pdir->dir[i],
GFP_KERNEL);
if (!pdir->tables[i])
goto err;
}
pdir->npages = npages;
if (alloc_pages) {
pdir->pages = kzalloc_objs(*pdir->pages, npages);
if (!pdir->pages)
goto err;
for (i = 0; i < pdir->npages; i++) {
dma_addr_t page_dma;
pdir->pages[i] = dma_alloc_coherent(&dev->pdev->dev,
PAGE_SIZE,
&page_dma,
GFP_KERNEL);
if (!pdir->pages[i])
goto err;
pvrdma_page_dir_insert_dma(pdir, i, page_dma);
}
}
return 0;
err:
pvrdma_page_dir_cleanup(dev, pdir);
return -ENOMEM;
}
static u64 *pvrdma_page_dir_table(struct pvrdma_page_dir *pdir, u64 idx)
{
return pdir->tables[PVRDMA_PAGE_DIR_TABLE(idx)];
}
dma_addr_t pvrdma_page_dir_get_dma(struct pvrdma_page_dir *pdir, u64 idx)
{
return pvrdma_page_dir_table(pdir, idx)[PVRDMA_PAGE_DIR_PAGE(idx)];
}
static void pvrdma_page_dir_cleanup_pages(struct pvrdma_dev *dev,
struct pvrdma_page_dir *pdir)
{
if (pdir->pages) {
u64 i;
for (i = 0; i < pdir->npages && pdir->pages[i]; i++) {
dma_addr_t page_dma = pvrdma_page_dir_get_dma(pdir, i);
dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
pdir->pages[i], page_dma);
}
kfree(pdir->pages);
}
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/slab.h`, `linux/bitmap.h`, `pvrdma.h`.
- Detected declarations: `function pvrdma_page_dir_init`, `function pvrdma_page_dir_get_dma`, `function pvrdma_page_dir_cleanup_pages`, `function pvrdma_page_dir_cleanup_tables`, `function pvrdma_page_dir_cleanup`, `function pvrdma_page_dir_insert_dma`, `function pvrdma_page_dir_insert_umem`, `function rdma_umem_for_each_dma_block`, `function pvrdma_page_dir_insert_page_list`, `function pvrdma_qp_cap_to_ib`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.