Received: from eggs.gnu.org ([140.186.70.92]:50463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzLzB-0000wk-2f for qemu-devel@nongnu.org; Fri, 02 Sep 2011 01:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzLz9-0004LF-HF for qemu-devel@nongnu.org; Fri, 02 Sep 2011 01:08:13 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:38487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzLz9-0004Be-15 for qemu-devel@nongnu.org; Fri, 02 Sep 2011 01:08:11 -0400 Received: from /spool/local by au.ibm.com with XMail ESMTP for from ; Fri, 2 Sep 2011 06:04:45 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8256OI71097966 for ; Fri, 2 Sep 2011 15:06:26 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8257sgW029190 for ; Fri, 2 Sep 2011 15:07:54 +1000 Date: Fri, 2 Sep 2011 14:40:28 +1000 From: David Gibson Message-ID: <20110902044028.GY11906@yookeroo.fritz.box> References: <1314853263-2086-1-git-send-email-david@gibson.dropbear.id.au> <1314853263-2086-2-git-send-email-david@gibson.dropbear.id.au> <4E5FAADF.1040704@us.ibm.com> <4E5FACD6.9000603@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E5FACD6.9000603@redhat.com> Subject: Re: [Qemu-devel] [PATCH 01/10] Add stub functions for PCI device models to do PCI DMA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Anthony Liguori , joerg.roedel@amd.com, agraf@suse.de, qemu-devel@nongnu.org, eduard.munteanu@linux360.ro, rth@twiddle.net On Thu, Sep 01, 2011 at 07:03:34PM +0300, Avi Kivity wrote: > On 09/01/2011 06:55 PM, Anthony Liguori wrote: > >On 09/01/2011 12:00 AM, David Gibson wrote: > >>This patch adds functions to pci.[ch] to perform PCI DMA operations. At > >>present, these are just stubs which perform directly cpu physical memory > >>accesses. > >> > >>Using these stubs, however, distinguishes PCI device DMA > >>transactions from > >>other accesses to physical memory, which will allow PCI IOMMU support to > >>be added in one place, rather than updating every PCI driver at > >>that time. > >> > >>That is, it allows us to update individual PCI drivers to > >>support an IOMMU > >>without having yet determined the details of how the IOMMU > >>emulation will > >>operate. This will let us remove the most bitrot-sensitive part of an > >>IOMMU patch in advance. > >> > >>Signed-off-by: David Gibson > > > >I think this is the wrong approach given the introduction of the > >memory API. > > > >I think we should have a generic memory access function that takes > >a MemoryRegion as it's first argument. > > > >The PCI bus should then expose one memory region for each device > >(that's how it can figure out where the access is coming from). > > > >Richard/Avi, what do you think? > > I think the patchset is fine. It routes all access through > pci_dma_rw(), which accepts a PCIDevice. We can later define > pci_dma_rw() in terms of the memory API and get the benefit of the > memory hierarchy. Right. Exactly what to use as a handle on the right bus / DMA addressing context is something still to be thrashed out - a MemoryRegion may well be the right answer. But whatever we do there, a convenience wrapper would be useful for the common case of PCI devices - certainly the correct addressing context should be reachable from the PCI device. This approach means we can get most of the PCI drivers IOMMU ready now, and we just need fix the final IOMMU support in one place, instead of in every PCI driver. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson