From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [RFC PATCH kernel] vfio-pci: Allow write combining Date: Tue, 10 Oct 2017 15:55:15 -0600 Message-ID: <20171010155515.39a0c5fe@t450s.home> References: <20171009025000.39435-1-aik@ozlabs.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, David Gibson , Eric Auger , Benjamin Herrenschmidt To: Alexey Kardashevskiy Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46746 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756941AbdJJVzW (ORCPT ); Tue, 10 Oct 2017 17:55:22 -0400 In-Reply-To: <20171009025000.39435-1-aik@ozlabs.ru> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, 9 Oct 2017 13:50:00 +1100 Alexey Kardashevskiy wrote: > 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 > --- > > 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); Are you testing __HAVE_PHYS_MEM_ACCESS_PROT because the version of phys_mem_access_prot() defined in drivers/char/mem.c can dereference @file and we're hoping that platforms we care about won't both define __HAVE_PHYS_MEM_ACCESS_PROT and look at @file? Sketchy. Thanks, Alex