[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 03/39] pci: split exit and finalize
From: |
Anthony Liguori |
Subject: |
Re: [Qemu-devel] [PATCH 03/39] pci: split exit and finalize |
Date: |
Fri, 07 Jun 2013 09:05:15 -0500 |
User-agent: |
Notmuch/0.15.2+77~g661dcf8 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) |
Paolo Bonzini <address@hidden> writes:
> To properly support devices that do DMA out of the BQL, destruction
> needs to be done in two phases. First, the device is unrealized;
> at this point, pending memory accesses can still be completed, but
> no new accesses will be started. The second part is freeing the
> device, which happens only after the reference count drops to zero;
> this means that all memory accesses are complete.
>
> This patch changes the PCI core to delay destruction of the
> bus-master address space and root region.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Anthony Liguori <address@hidden>
Regards,
Anthony Liguori
> ---
> hw/pci/pci.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 776ad96..b60d9d0d 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -779,6 +779,16 @@ static void pci_config_free(PCIDevice *pci_dev)
> g_free(pci_dev->used);
> }
>
> +static void pci_device_instance_finalize(Object *obj)
> +{
> + PCIDevice *pci_dev = PCI_DEVICE(obj);
> +
> + qemu_free_irqs(pci_dev->irq);
> +
> + address_space_destroy(&pci_dev->bus_master_as);
> + memory_region_destroy(&pci_dev->bus_master_enable_region);
> +}
> +
> /* -1 for devfn means auto assign */
> static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
> const char *name, int devfn)
> @@ -866,12 +876,8 @@ static PCIDevice *do_pci_register_device(PCIDevice
> *pci_dev, PCIBus *bus,
>
> static void do_pci_unregister_device(PCIDevice *pci_dev)
> {
> - qemu_free_irqs(pci_dev->irq);
> pci_dev->bus->devices[pci_dev->devfn] = NULL;
> pci_config_free(pci_dev);
> -
> - address_space_destroy(&pci_dev->bus_master_as);
> - memory_region_destroy(&pci_dev->bus_master_enable_region);
> }
>
> static void pci_unregister_io_regions(PCIDevice *pci_dev)
> @@ -2243,6 +2249,7 @@ static const TypeInfo pci_device_type_info = {
> .abstract = true,
> .class_size = sizeof(PCIDeviceClass),
> .class_init = pci_device_class_init,
> + .instance_finalize = pci_device_instance_finalize,
> };
>
> static void pci_register_types(void)
> --
> 1.8.1.4
- [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 01/39] scsi: keep device alive while it has requests, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 02/39] dma: keep a device alive while it has SGLists, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 03/39] pci: split exit and finalize, Paolo Bonzini, 2013/06/04
- Re: [Qemu-devel] [PATCH 03/39] pci: split exit and finalize,
Anthony Liguori <=
- [Qemu-devel] [PATCH 04/39] ac97: use instance_finalize instead of exit, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 05/39] es1370: use instance_finalize instead of exit, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 06/39] hda: split exit and instance_finalize, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 07/39] serial: split exit and instance_finalize, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 08/39] tpci200: use instance_finalize instead of exit, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 09/39] pci-assign: split exit and instance_finalize, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 10/39] ahci: split exit and instance_finalize, Paolo Bonzini, 2013/06/04
- [Qemu-devel] [PATCH 11/39] msix: split msix_free from msix_uninit, Paolo Bonzini, 2013/06/04