All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH kernel] vfio-pci: Allow write combining
@ 2017-10-09  2:50 Alexey Kardashevskiy
  2017-10-10 21:55 ` Alex Williamson
  0 siblings, 1 reply; 23+ messages in thread
From: Alexey Kardashevskiy @ 2017-10-09  2:50 UTC (permalink / raw)
  To: kvm
  Cc: Alexey Kardashevskiy, David Gibson, Eric Auger,
	Benjamin Herrenschmidt, Alex Williamson

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@ozlabs.ru>
---

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-11-30 20:06 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09  2:50 [RFC PATCH kernel] vfio-pci: Allow write combining Alexey Kardashevskiy
2017-10-10 21:55 ` Alex Williamson
2017-10-11  2:05   ` Alexey Kardashevskiy
2017-10-11  2:42     ` Alex Williamson
2017-10-11  2:56       ` Alexey Kardashevskiy
2017-10-11 15:35         ` Benjamin Herrenschmidt
2017-10-16  5:54           ` Alexey Kardashevskiy
2017-10-16  6:00             ` David Gibson
2017-10-16  7:36               ` Alexey Kardashevskiy
2017-10-16  8:01                 ` David Gibson
2017-11-06  5:44                   ` Alexey Kardashevskiy
2017-11-14  2:23                     ` David Gibson
2017-11-14  2:29                       ` Benjamin Herrenschmidt
2017-11-14 16:28                         ` Alex Williamson
2017-11-24  4:58                           ` Alexey Kardashevskiy
2017-11-29 18:47                             ` Alex Williamson
2017-11-30  4:20                               ` David Gibson
2017-11-30 20:06                                 ` Benjamin Herrenschmidt
2017-10-16  8:38                 ` Benjamin Herrenschmidt
2017-10-16 11:11                   ` Alexey Kardashevskiy
2017-10-18  7:33                     ` Benjamin Herrenschmidt
2017-10-18  9:00                       ` Alexey Kardashevskiy
2017-10-18 14:21                         ` Benjamin Herrenschmidt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.