On 06/12/17 23:21, Mark Cave-Ayland wrote: > The setting of the FW_CFG_VERSION_DMA bit is the same across both the > TYPE_FW_CFG_MEM and TYPE_FW_CFG_IO devices, so unify the logic in > fw_cfg_init1(). > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk> > --- > hw/nvram/fw_cfg.c | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) > > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c > index be5b04e..e1aa4fc 100644 > --- a/hw/nvram/fw_cfg.c > +++ b/hw/nvram/fw_cfg.c > @@ -914,6 +914,7 @@ static void fw_cfg_init1(DeviceState *dev) > { > FWCfgState *s = FW_CFG(dev); > MachineState *machine = MACHINE(qdev_get_machine()); > + uint32_t version = FW_CFG_VERSION; > > assert(!object_resolve_path(FW_CFG_PATH, NULL)); > > @@ -928,6 +929,12 @@ static void fw_cfg_init1(DeviceState *dev) > fw_cfg_bootsplash(s); > fw_cfg_reboot(s); > > + if (s->dma_enabled) { > + version |= FW_CFG_VERSION_DMA; > + } > + > + fw_cfg_add_i32(s, FW_CFG_ID, version); > + > s->machine_ready.notify = fw_cfg_machine_ready; > qemu_add_machine_init_done_notifier(&s->machine_ready); > } > @@ -938,7 +945,6 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t > dma_iobase, > DeviceState *dev; > SysBusDevice *sbd; > FWCfgState *s; > - uint32_t version = FW_CFG_VERSION; > bool dma_requested = dma_iobase && dma_as; > > dev = qdev_create(NULL, TYPE_FW_CFG_IO); > @@ -960,12 +966,8 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t > dma_iobase, > s->dma_as = dma_as; > s->dma_addr = 0; > sysbus_add_io(sbd, dma_iobase, sysbus_mmio_get_region(sbd, 1)); > - > - version |= FW_CFG_VERSION_DMA; > } > > - fw_cfg_add_i32(s, FW_CFG_ID, version); > - > return s; > } > > @@ -981,7 +983,6 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, > DeviceState *dev; > SysBusDevice *sbd; > FWCfgState *s; > - uint32_t version = FW_CFG_VERSION; > bool dma_requested = dma_addr && dma_as; > > dev = qdev_create(NULL, TYPE_FW_CFG_MEM); > @@ -1002,11 +1003,8 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, > s->dma_as = dma_as; > s->dma_addr = 0; > sysbus_mmio_map(sbd, 2, dma_addr); > - version |= FW_CFG_VERSION_DMA; > } > > - fw_cfg_add_i32(s, FW_CFG_ID, version); > - > return s; > } > >
Reviewed-by: Laszlo Ersek <ler...@redhat.com>