Re: [PATCH 2/2] vfio: hugepage support for vfio_iommu_type1

2013-05-25 Thread Konrad Rzeszutek Wilk
 + * Turns out AMD IOMMU has a page table bug where it won't map large pages
 + * to a region that previously mapped smaller pages.  This should be fixed
 + * soon, so this is just a temporary workaround to break mappings down into
 + * PAGE_SIZE.  Better to map smaller pages than nothing.
 + */
 +static int map_try_harder(struct vfio_iommu *iommu, dma_addr_t iova,
 +   unsigned long pfn, long npage, int prot)
 +{
 + long i;
 + int ret;
 +
 + for (i = 0; i  npage; i++, pfn++, iova += PAGE_SIZE) {
 + ret = iommu_map(iommu-domain, iova,
 + (phys_addr_t)pfn  PAGE_SHIFT,
 + PAGE_SIZE, prot);
 + if (ret)
 + break;
 + }
 +
 + for (; i  npage  i  0; i--, iova -= PAGE_SIZE)
 + iommu_unmap(iommu-domain, iova, PAGE_SIZE);
 +
   return ret;
  }

This looks to belong to a vfio-quirk file (a something else) that deals with
various IOMMU's quirks.
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 0/2] vfio: type1 iommu hugepage support

2013-05-25 Thread Konrad Rzeszutek Wilk
On Fri, May 24, 2013 at 11:24:26AM -0600, Alex Williamson wrote:
 This series let's the vfio type1 iommu backend take advantage of iommu
 large page support.  See patch 2/2 for the details.  This has been
 tested on both amd_iommu and intel_iommu, but only my AMD system has
 large page support.  I'd appreciate any testing and feedback on other
 systems, particularly vt-d systems supporting large pages.  Mapping
 efficiency should be improved a bit without iommu hugepages, but I
 hope that it's much more noticeable with huge pages, especially for
 very large QEMU guests.

I took a very very quick look - and I am wondering if there should also
be a flag to turn it on/off in ther kernel in such case? Especially in the 
field if a user finds out that their particular IOMMU chipset might
be doing something funky with large-pages ?

 
 This change includes a clarification to the mapping expectations for
 users of the type1 iommu, but is compatible with known users and works
 with existing QEMU userspace supporting vfio.  Thanks,
 
 Alex
 
 ---
 
 Alex Williamson (2):
   vfio: Convert type1 iommu to use rbtree
   vfio: hugepage support for vfio_iommu_type1
 
 
  drivers/vfio/vfio_iommu_type1.c |  607 
 ---
  include/uapi/linux/vfio.h   |8 -
  2 files changed, 387 insertions(+), 228 deletions(-)
 ___
 iommu mailing list
 iommu@lists.linux-foundation.org
 https://lists.linuxfoundation.org/mailman/listinfo/iommu
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 0/2] vfio: type1 iommu hugepage support

2013-05-25 Thread Alex Williamson
On Sat, 2013-05-25 at 07:21 -0400, Konrad Rzeszutek Wilk wrote:
 On Fri, May 24, 2013 at 11:24:26AM -0600, Alex Williamson wrote:
  This series let's the vfio type1 iommu backend take advantage of iommu
  large page support.  See patch 2/2 for the details.  This has been
  tested on both amd_iommu and intel_iommu, but only my AMD system has
  large page support.  I'd appreciate any testing and feedback on other
  systems, particularly vt-d systems supporting large pages.  Mapping
  efficiency should be improved a bit without iommu hugepages, but I
  hope that it's much more noticeable with huge pages, especially for
  very large QEMU guests.
 
 I took a very very quick look - and I am wondering if there should also
 be a flag to turn it on/off in ther kernel in such case? Especially in the 
 field if a user finds out that their particular IOMMU chipset might
 be doing something funky with large-pages ?

Yeah, that's probably a reasonable feature.  intel-iommu has a boot
option to disable superpages, but we could make it more consistent at
the vfio level if we have a switch there.  It could provided interesting
performance and debugging info.  I'll add a module option to do this.
Thanks,

Alex
 
  This change includes a clarification to the mapping expectations for
  users of the type1 iommu, but is compatible with known users and works
  with existing QEMU userspace supporting vfio.  Thanks,
  
  Alex
  
  ---
  
  Alex Williamson (2):
vfio: Convert type1 iommu to use rbtree
vfio: hugepage support for vfio_iommu_type1
  
  
   drivers/vfio/vfio_iommu_type1.c |  607 
  ---
   include/uapi/linux/vfio.h   |8 -
   2 files changed, 387 insertions(+), 228 deletions(-)
  ___
  iommu mailing list
  iommu@lists.linux-foundation.org
  https://lists.linuxfoundation.org/mailman/listinfo/iommu



___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu