mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
pci: vfio: VFIO_IOMMU_MAP_DMA mmio regions
For all VFIO devices, map all non-emulated MMIO regions to the vfio container to allow PCIe P2P between all VFIO devices on the virtual machine. This is required for a wide variety of advanced GPU workloads such as GPUDirect P2P (DMA between two GPUs), GPUDirect RDMA (DMA between a GPU and an IB device). Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
This commit is contained in:
parent
56dbb8f0db
commit
f0c1f8d079
@ -1568,6 +1568,16 @@ impl VfioPciDevice {
|
|||||||
self.vm
|
self.vm
|
||||||
.create_user_memory_region(mem_region)
|
.create_user_memory_region(mem_region)
|
||||||
.map_err(VfioPciError::CreateUserMemoryRegion)?;
|
.map_err(VfioPciError::CreateUserMemoryRegion)?;
|
||||||
|
|
||||||
|
if !self.iommu_attached {
|
||||||
|
self.container
|
||||||
|
.vfio_dma_map(
|
||||||
|
user_memory_region.start,
|
||||||
|
user_memory_region.size,
|
||||||
|
user_memory_region.host_addr,
|
||||||
|
)
|
||||||
|
.map_err(VfioPciError::DmaMap)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1578,6 +1588,16 @@ impl VfioPciDevice {
|
|||||||
pub fn unmap_mmio_regions(&mut self) {
|
pub fn unmap_mmio_regions(&mut self) {
|
||||||
for region in self.common.mmio_regions.iter() {
|
for region in self.common.mmio_regions.iter() {
|
||||||
for user_memory_region in region.user_memory_regions.iter() {
|
for user_memory_region in region.user_memory_regions.iter() {
|
||||||
|
// Unmap from vfio container
|
||||||
|
if !self.iommu_attached {
|
||||||
|
if let Err(e) = self
|
||||||
|
.container
|
||||||
|
.vfio_dma_unmap(user_memory_region.start, user_memory_region.size)
|
||||||
|
{
|
||||||
|
error!("Could not unmap mmio region from vfio container: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove region
|
// Remove region
|
||||||
let r = self.vm.make_user_memory_region(
|
let r = self.vm.make_user_memory_region(
|
||||||
user_memory_region.slot,
|
user_memory_region.slot,
|
||||||
|
Loading…
Reference in New Issue
Block a user