On 13 January 2018 at 05:07, Philippe Mathieu-Daudé <[email protected]> wrote: > While SysBus devices can use the get_system_memory() address space, > PCI devices should use the bus master address space for DMA. > > Suggested-by: Peter Maydell <[email protected]> > Signed-off-by: Philippe Mathieu-Daudé <[email protected]> > --- > Should we check for the PCI_COMMAND_MASTER bit before > using pci_get_address_space()?
That isn't necessary -- the PCI core code handles the master bit by mapping or unmapping a memory region from the container which is what the pci_get_address_space() does its writes to. > @@ -1382,6 +1381,9 @@ static void sdhci_sysbus_realize(DeviceState *dev, > Error ** errp) > return; > } > > + s->dma_as = g_new0(AddressSpace, 1); > + address_space_init(s->dma_as, get_system_memory(), "sdhci-dma"); You can just use address_space_memory rather than creating a new address space here. > + > sysbus_init_irq(sbd, &s->irq); > sysbus_init_mmio(sbd, &s->iomem); > } > @@ -1391,6 +1393,9 @@ static void sdhci_sysbus_unrealize(DeviceState *dev, > Error **errp) > SDHCIState *s = SYSBUS_SDHCI(dev); > > sdhci_common_unrealize(s, &error_abort); > + > + address_space_destroy(s->dma_as); > + g_free(s->dma_as); > } > > static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) > -- > 2.15.1 Otherwise Reviewed-by: Peter Maydell <[email protected]> thanks -- PMM
