Revision 817dcc53 hw/pci.c

b/hw/pci.c
33 33
#include "qmp-commands.h"
34 34
#include "msi.h"
35 35
#include "msix.h"
36
#include "exec-memory.h"
36 37

  
37 38
//#define DEBUG_PCI
38 39
#ifdef DEBUG_PCI
......
777 778
    pci_dev->bus = bus;
778 779
    if (bus->dma_context_fn) {
779 780
        pci_dev->dma = bus->dma_context_fn(bus, bus->dma_context_opaque, devfn);
781
    } else {
782
        /* FIXME: Make dma_context_fn use MemoryRegions instead, so this path is
783
         * taken unconditionally */
784
        /* FIXME: inherit memory region from bus creator */
785
        address_space_init(&pci_dev->bus_master_as, get_system_memory());
786
        pci_dev->dma = g_new(DMAContext, 1);
787
        dma_context_init(pci_dev->dma, &pci_dev->bus_master_as, NULL, NULL, NULL);
780 788
    }
781 789
    pci_dev->devfn = devfn;
782 790
    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
......
830 838
    qemu_free_irqs(pci_dev->irq);
831 839
    pci_dev->bus->devices[pci_dev->devfn] = NULL;
832 840
    pci_config_free(pci_dev);
841

  
842
    if (!pci_dev->bus->dma_context_fn) {
843
        address_space_destroy(&pci_dev->bus_master_as);
844
        g_free(pci_dev->dma);
845
        pci_dev->dma = NULL;
846
    }
833 847
}
834 848

  
835 849
static void pci_unregister_io_regions(PCIDevice *pci_dev)

Also available in: Unified diff