drivers/vdpa/vdpa_user/iova_domain.c
Source file repositories/reference/linux-study-clean/drivers/vdpa/vdpa_user/iova_domain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vdpa/vdpa_user/iova_domain.c- Extension
.c- Size
- 17743 bytes
- Lines
- 686
- Domain
- Driver Families
- Bucket
- drivers/vdpa
- 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.
- 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/slab.hlinux/file.hlinux/anon_inodes.hlinux/highmem.hlinux/vmalloc.hlinux/vdpa.hiova_domain.h
Detected Declarations
function Copyrightfunction vduse_iotlb_del_rangefunction vduse_domain_set_mapfunction vduse_domain_clear_mapfunction vduse_domain_map_bounce_pagefunction vduse_domain_unmap_bounce_pagefunction offset_in_bounce_pagefunction do_bouncefunction vduse_domain_bouncefunction vduse_domain_get_coherent_pagefunction vduse_domain_get_bounce_pagefunction vduse_domain_free_kernel_bounce_pagesfunction vduse_domain_add_user_bounce_pagesfunction vduse_domain_remove_user_bounce_pagesfunction vduse_domain_reset_bounce_mapfunction vduse_domain_init_bounce_mapfunction vduse_domain_alloc_iovafunction vduse_domain_free_iovafunction vduse_domain_sync_single_for_devicefunction vduse_domain_sync_single_for_cpufunction vduse_domain_map_pagefunction vduse_domain_unmap_pagefunction vduse_domain_alloc_coherentfunction virt_to_physfunction vduse_domain_free_coherentfunction vduse_domain_mmap_faultfunction vduse_domain_mmapfunction vduse_domain_releasefunction vduse_domain_destroyfunction vduse_domain_createfunction vduse_domain_initfunction vduse_domain_exit
Annotated Snippet
static const struct file_operations vduse_domain_fops = {
.owner = THIS_MODULE,
.mmap = vduse_domain_mmap,
.release = vduse_domain_release,
};
void vduse_domain_destroy(struct vduse_iova_domain *domain)
{
fput(domain->file);
}
struct vduse_iova_domain *
vduse_domain_create(unsigned long iova_limit, size_t bounce_size)
{
struct vduse_iova_domain *domain;
struct file *file;
struct vduse_bounce_map *map;
unsigned long pfn, bounce_pfns;
int ret;
bounce_pfns = PAGE_ALIGN(bounce_size) >> BOUNCE_MAP_SHIFT;
if (iova_limit <= bounce_size)
return NULL;
domain = kzalloc_obj(*domain);
if (!domain)
return NULL;
domain->iotlb = vhost_iotlb_alloc(0, 0);
if (!domain->iotlb)
goto err_iotlb;
domain->iova_limit = iova_limit;
domain->bounce_size = PAGE_ALIGN(bounce_size);
domain->bounce_maps = vzalloc(bounce_pfns *
sizeof(struct vduse_bounce_map));
if (!domain->bounce_maps)
goto err_map;
for (pfn = 0; pfn < bounce_pfns; pfn++) {
map = &domain->bounce_maps[pfn];
map->orig_phys = INVALID_PHYS_ADDR;
}
file = anon_inode_getfile("[vduse-domain]", &vduse_domain_fops,
domain, O_RDWR);
if (IS_ERR(file))
goto err_file;
domain->file = file;
rwlock_init(&domain->bounce_lock);
spin_lock_init(&domain->iotlb_lock);
init_iova_domain(&domain->stream_iovad,
BOUNCE_MAP_SIZE, IOVA_START_PFN);
ret = iova_domain_init_rcaches(&domain->stream_iovad);
if (ret)
goto err_iovad_stream;
init_iova_domain(&domain->consistent_iovad,
PAGE_SIZE, bounce_pfns);
ret = iova_domain_init_rcaches(&domain->consistent_iovad);
if (ret)
goto err_iovad_consistent;
return domain;
err_iovad_consistent:
put_iova_domain(&domain->stream_iovad);
err_iovad_stream:
fput(file);
err_file:
vfree(domain->bounce_maps);
err_map:
vhost_iotlb_free(domain->iotlb);
err_iotlb:
kfree(domain);
return NULL;
}
int vduse_domain_init(void)
{
return iova_cache_get();
}
void vduse_domain_exit(void)
{
iova_cache_put();
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/file.h`, `linux/anon_inodes.h`, `linux/highmem.h`, `linux/vmalloc.h`, `linux/vdpa.h`, `iova_domain.h`.
- Detected declarations: `function Copyright`, `function vduse_iotlb_del_range`, `function vduse_domain_set_map`, `function vduse_domain_clear_map`, `function vduse_domain_map_bounce_page`, `function vduse_domain_unmap_bounce_page`, `function offset_in_bounce_page`, `function do_bounce`, `function vduse_domain_bounce`, `function vduse_domain_get_coherent_page`.
- Atlas domain: Driver Families / drivers/vdpa.
- Implementation status: pattern 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.