[RFC PATCH kernel] vfio-pci: Allow write combining

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At the moment the protection in VFIO MMIO mappings is forced to
_PAGE_NON_IDEMPOTENT which means that write combining is not really
available to the userspace even for prefetchable 64bit MMIO BARs.

This replaces pgprot_noncached() with a platform specific
phys_mem_access_prot() when available and depending on the platform
the vm_page_prot may be set to _PAGE_TOLERANT allowing to exploit
the write combining feature.

The guest drivers still have to use _wc versions of
the ioremap/pci_ioremap API to get write combininig working.

Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxxxx>
---

This should allow DPDK and radix guests (x86, POWERPC, etc) to
do write combining.

POWERPC hash guests should not be affected by this change, it should
work even without this.
---
 drivers/vfio/pci/vfio_pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index f041b1a6cf66..014192b42724 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1156,8 +1156,13 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
 	}
 
 	vma->vm_private_data = vdev;
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 	vma->vm_pgoff = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff;
+#ifdef __HAVE_PHYS_MEM_ACCESS_PROT
+	vma->vm_page_prot = phys_mem_access_prot(NULL, vma->vm_pgoff,
+			req_len, vma->vm_page_prot);
+#else
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+#endif
 
 	return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 			       req_len, vma->vm_page_prot);
-- 
2.11.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux