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). I'll be leaving soon for a few days of vacation, hence I'm not sending a pull request for the previous part yet. Paolo Paolo Bonzini (15): 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: 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 memory: return MemoryRegion from qemu_ram_addr_from_host memory: ref/unref memory across address_space_map/unmap exec.c | 79 ++++++++++++++++++++++++++--------- 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 | 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 | 2 +- include/exec/ioport.h | 3 ++ include/exec/memory.h | 51 +++++++++++++++++++++- include/hw/virtio/dataplane/hostmem.h | 1 + ioport.c | 10 +++++ kvm-all.c | 2 + memory.c | 51 ++++++++++++++++++++++ target-arm/kvm.c | 2 + target-i386/kvm.c | 4 +- target-sparc/mmu_helper.c | 1 + xen-all.c | 2 + 38 files changed, 301 insertions(+), 51 deletions(-) -- 1.8.1.4