On Tue, Sep 5, 2023 at 3:45 PM Peter Xu <pet...@redhat.com> wrote: > > On Tue, Sep 05, 2023 at 09:38:39AM +0200, Mattias Nissler wrote: > > It would be nice to use a property on the device that originates the > > DMA operation to configure this. However, I don't see how to do this > > in a reasonable way without bigger changes: A typical call path is > > pci_dma_map -> dma_memory_map -> address_space_map. While pci_dma_map > > has a PCIDevice*, address_space_map only receives the AddressSpace*. > > So, we'd probably have to pass through a new QObject parameter to > > address_space_map that indicates the originator and pass that through? > > Or is there a better alternative to supply context information to > > address_space map? Let me know if any of these approaches sound > > appropriate and I'll be happy to explore them further. > > Should be possible to do. The pci address space is not shared but > per-device by default (even if there is no vIOMMU intervention). See > do_pci_register_device(): > > address_space_init(&pci_dev->bus_master_as, > &pci_dev->bus_master_container_region, pci_dev->name);
Ah, thanks for that hint! This works, and it probably even makes more sense to treat bounce buffering as a concept tied to AddressSpace rather than a global thing. I'll send an updated series shortly, with the configuration parameter attached to the PCI device, so it can be specified as a -device option on the command line. In that light, I decided to keep the default at 4096 bytes though, since we now have the ability for each device model to choose its default independently.