diff mbox series

[v1,4/4] vfio/type1: Add support for VFIO_DMA_MAP_FLAG_SYS_CACHE

Message ID 20240826071641.2691374-5-manojvishy@google.com (mailing list archive)
State New
Headers show
Series vfio/iommu: Flag to allow userspace to set DMA buffers system cacheable | expand

Commit Message

Manoj Vishwanathan Aug. 26, 2024, 7:16 a.m. UTC
Introducing the VFIO_DMA_MAP_FLAG_SYS_CACHE flag to control
whether mapped DMA regions are cached in the system cache.

Signed-off-by: Manoj Vishwanathan <manojvishy@google.com>
---
 drivers/vfio/vfio_iommu_type1.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 0960699e7554..c84bb6c8b12f 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1562,7 +1562,8 @@  static int vfio_dma_do_map(struct vfio_iommu *iommu,
 		prot |= IOMMU_WRITE;
 	if (map->flags & VFIO_DMA_MAP_FLAG_READ)
 		prot |= IOMMU_READ;
-
+	if (map->flags & VFIO_DMA_MAP_FLAG_SYS_CACHE)
+		prot |= IOMMU_SYS_CACHE;
 	if ((prot && set_vaddr) || (!prot && !set_vaddr))
 		return -EINVAL;
 
@@ -2815,7 +2816,7 @@  static int vfio_iommu_type1_map_dma(struct vfio_iommu *iommu,
 	struct vfio_iommu_type1_dma_map map;
 	unsigned long minsz;
 	uint32_t mask = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE |
-			VFIO_DMA_MAP_FLAG_VADDR;
+			VFIO_DMA_MAP_FLAG_SYS_CACHE | VFIO_DMA_MAP_FLAG_VADDR;
 
 	minsz = offsetofend(struct vfio_iommu_type1_dma_map, size);