From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ4Mf-0005d8-Pd for qemu-devel@nongnu.org; Mon, 14 Nov 2011 16:46:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQ4Md-0007pI-FR for qemu-devel@nongnu.org; Mon, 14 Nov 2011 16:46:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ4Md-0007p1-3r for qemu-devel@nongnu.org; Mon, 14 Nov 2011 16:46:51 -0500 Message-ID: <1321307200.17169.90.camel@bling.home> From: Alex Williamson Date: Mon, 14 Nov 2011 14:46:40 -0700 In-Reply-To: <1321304079.17169.74.camel@bling.home> References: <20111103195452.21259.93021.stgit@bling.home> <4EBDBA50.3070801@freescale.com> <1321304079.17169.74.camel@bling.home> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: Re: [Qemu-devel] [RFC PATCH] vfio: VFIO Driver core framework List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Scott Wood Cc: aafabbri@cisco.com, aik@au1.ibm.com, kvm@vger.kernel.org, pmac@au1.ibm.com, qemu-devel@nongnu.org, joerg.roedel@amd.com, konrad.wilk@oracle.com, agraf@suse.de, dwg@au1.ibm.com, chrisw@sous-sol.org, B08248@freescale.com, iommu@lists.linux-foundation.org, avi@redhat.com, linux-pci@vger.kernel.org, B07421@freescale.com, benve@cisco.com On Mon, 2011-11-14 at 13:54 -0700, Alex Williamson wrote: > On Fri, 2011-11-11 at 18:14 -0600, Scott Wood wrote: > > On 11/03/2011 03:12 PM, Alex Williamson wrote: > > > + for (i = 0; i < npage; i++, iova += PAGE_SIZE, vaddr += PAGE_SIZE) { > > > + unsigned long pfn = 0; > > > + > > > + ret = vaddr_get_pfn(vaddr, rdwr, &pfn); > > > + if (ret) { > > > + __vfio_dma_unmap(iommu, start, i, rdwr); > > > + return ret; > > > + } > > > + > > > + /* Only add actual locked pages to accounting */ > > > + if (!is_invalid_reserved_pfn(pfn)) > > > + locked++; > > > + > > > + ret = iommu_map(iommu->domain, iova, > > > + (phys_addr_t)pfn << PAGE_SHIFT, 0, prot); > > > + if (ret) { > > > + /* Back out mappings on error */ > > > + put_pfn(pfn, rdwr); > > > + __vfio_dma_unmap(iommu, start, i, rdwr); > > > + return ret; > > > + } > > > + } > > > > There's no way to hand this stuff to the IOMMU driver in chunks larger > > than a page? That's going to be a problem for our IOMMU, which wants to > > deal with large windows. > > There is, this is just a simple implementation that maps individual > pages. We "just" need to determine physically contiguous chunks and > mlock them instead of using get_user_pages. The current implementation > is much like how KVM maps iommu pages, but there shouldn't be a user API > change to try to use larger chinks. We want this for IOMMU large page > support too. Also, at one point intel-iommu didn't allow sub-ranges to be unmapped; an unmap of a single page would unmap the entire original mapping that contained that page. That made it easier to map each page individually for the flexibility it provided on unmap. I need to see if we still have that restriction. Thanks, Alex