Now that the DMA APIs are unified, we move closer and closer to breaking memory access from the BQL dependency. This series adds an API to reference/unreference memory regions, which is not really needed only for BQL-less memory access: the big lock can already be dropped between address_space_map and the corresponding unmap, and the last patch fixes potential problems in this area if the DMA destination is hot-unplugged. Lockless memory access only makes things a bit worse.
Reference counting the region piggybacks on reference counting of a QOM object, the "owner" of the region. The owner API is designed so that it will be called as little as possible. Unowned subregions will get a region if memory_region_set_owner is called after the subregion is added. This is in general the common case already; often setting the owner can be delegated to a bus-specific API that already takes a DeviceState (for example pci_register_bar or sysbus_init_mmio). As mentioned earlier, I'm not sending a pull request for the previous part yet. Unplugging a PCI bridge found a reference counting bug in memory_region_set_owner. To test this I tried hot-unplug for all PCI devices. Paolo v1->v2: fixed reference counting bug in memory_region_set_owner added sysbus_pass_mmio (patch 6) moved qemu_ram_addr_from_host_nofail to cputlb.c (patch 15) Paolo Bonzini (17): memory: add getter/setter for owner memory: add ref/unref memory: add ref/unref calls exec: add a reference to the region returned by address_space_translate pci: set owner for BARs sysbus: add sysbus_pass_mmio sysbus: set owner for MMIO regions acpi: add memory_region_set_owner calls misc: add memory_region_set_owner calls isa/portio: allow setting an owner vga: add memory_region_set_owner calls pci-assign: add memory_region_set_owner calls vfio: add memory_region_set_owner calls exec: check MRU in qemu_ram_addr_from_host exec: move qemu_ram_addr_from_host_nofail to cputlb.c memory: return MemoryRegion from qemu_ram_addr_from_host memory: ref/unref memory across address_space_map/unmap cputlb.c | 11 +++++ exec.c | 90 +++++++++++++++++++++++------------ hw/acpi/ich9.c | 1 + hw/acpi/piix4.c | 5 ++ hw/char/serial-pci.c | 1 + hw/core/loader.c | 1 + hw/core/sysbus.c | 14 ++++++ hw/cpu/arm11mpcore.c | 2 +- hw/display/cirrus_vga.c | 19 ++++++-- hw/display/exynos4210_fimd.c | 6 +++ hw/display/framebuffer.c | 12 +++-- hw/display/qxl.c | 6 ++- hw/display/vga-isa-mm.c | 2 +- hw/display/vga-isa.c | 4 +- hw/display/vga-pci.c | 5 +- hw/display/vga.c | 19 ++++++-- hw/display/vga_int.h | 9 ++-- hw/display/vmware_vga.c | 4 +- hw/i386/kvm/pci-assign.c | 11 +++++ hw/i386/kvmvapic.c | 1 + hw/isa/apm.c | 1 + hw/isa/isa-bus.c | 2 + hw/misc/pc-testdev.c | 7 +++ hw/misc/vfio.c | 10 ++++ hw/pci/pci.c | 2 + hw/virtio/dataplane/hostmem.c | 7 +++ hw/virtio/vhost.c | 2 + hw/virtio/virtio-balloon.c | 1 + hw/xen/xen_pt.c | 4 ++ include/exec/cpu-common.h | 3 +- include/exec/ioport.h | 3 ++ include/exec/memory.h | 69 ++++++++++++++++++++++++++- include/hw/sysbus.h | 1 + include/hw/virtio/dataplane/hostmem.h | 1 + ioport.c | 10 ++++ kvm-all.c | 2 + memory.c | 79 ++++++++++++++++++++++++++++++ target-arm/kvm.c | 2 + target-i386/kvm.c | 4 +- target-sparc/mmu_helper.c | 1 + xen-all.c | 2 + 41 files changed, 372 insertions(+), 64 deletions(-) -- 1.8.1.4