From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 2/2] vfio: hugepage support for vfio_iommu_type1 Date: Sat, 25 May 2013 07:20:10 -0400 Message-ID: <20130525112009.GC2418@localhost.localdomain> References: <20130524171613.14229.84050.stgit@bling.home> <20130524172438.14229.59476.stgit@bling.home> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20130524172438.14229.59476.stgit-xdHQ/5r00wBBDLzU/O5InQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Alex Williamson Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, chegu_vinod-VXdhtT5mjnY@public.gmane.org, qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: iommu@lists.linux-foundation.org > + * 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.