On 5/31/20 7:54 PM, Philippe Mathieu-Daudé wrote: > The DMA operations should not use the CPU address space, but > the DMA address space. Add support for a DMA address space, > and replace the cpu_physical_memory API calls by equivalent > dma_memory_read/write calls. > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > include/hw/sd/allwinner-sdhost.h | 4 ++++ > hw/sd/allwinner-sdhost.c | 36 ++++++++++++++++++++++++++------ > 2 files changed, 34 insertions(+), 6 deletions(-) > [...]> @@ -742,6 +747,17 @@ static void allwinner_sdhost_init(Object *obj) > sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq); > } > > +static void allwinner_sdhost_realize(DeviceState *dev, Error **errp) > +{ > + AwSdHostState *s = AW_SDHOST(dev); > + > + if (!s->dma_mr) { > + error_setg(errp, "\"dma\" property must be provided.");
Oops I forgot to include the part that sets this property in the A10/H3 SoCs. > + return; > + } > + address_space_init(&s->dma_as, s->dma_mr, "sdhost-dma"); > +} > + > static void allwinner_sdhost_reset(DeviceState *dev) > { > AwSdHostState *s = AW_SDHOST(dev); > @@ -787,6 +803,12 @@ static void allwinner_sdhost_reset(DeviceState *dev) > s->status_crc = REG_SD_CRC_STA_RST; > } > > +static Property allwinner_sdhost_properties[] = { > + DEFINE_PROP_LINK("dma", AwSdHostState, > + dma_mr, TYPE_MEMORY_REGION, MemoryRegion *), > + DEFINE_PROP_END_OF_LIST(), > +}; > + > static void allwinner_sdhost_bus_class_init(ObjectClass *klass, void *data) > { > SDBusClass *sbc = SD_BUS_CLASS(klass); > @@ -798,7 +820,9 @@ static void allwinner_sdhost_class_init(ObjectClass > *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > > + device_class_set_props(dc, allwinner_sdhost_properties); > dc->reset = allwinner_sdhost_reset; > + dc->realize = allwinner_sdhost_realize; > dc->vmsd = &vmstate_allwinner_sdhost; > } > >