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<da...@gibson.dropbear.id.au> > > > >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