Commit 469b046e authored by Paolo Bonzini's avatar Paolo Bonzini

memory: remove memory_region_destroy

The function is empty after the previous patch, so remove it.
Reviewed-by: default avatarPeter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent d8d95814
......@@ -257,15 +257,6 @@ static void host_memory_backend_init(Object *obj)
host_memory_backend_set_policy, NULL, NULL, NULL);
}
static void host_memory_backend_finalize(Object *obj)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
if (memory_region_size(&backend->mr)) {
memory_region_destroy(&backend->mr);
}
}
MemoryRegion *
host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
{
......@@ -360,7 +351,6 @@ static const TypeInfo host_memory_backend_info = {
.class_init = host_memory_backend_class_init,
.instance_size = sizeof(HostMemoryBackend),
.instance_init = host_memory_backend_init,
.instance_finalize = host_memory_backend_finalize,
.interfaces = (InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
{ }
......
......@@ -1388,14 +1388,6 @@ static int ac97_initfn (PCIDevice *dev)
return 0;
}
static void ac97_exitfn (PCIDevice *dev)
{
AC97LinkState *s = DO_UPCAST (AC97LinkState, dev, dev);
memory_region_destroy (&s->io_nam);
memory_region_destroy (&s->io_nabm);
}
static int ac97_init (PCIBus *bus)
{
pci_create_simple (bus, -1, "AC97");
......@@ -1413,7 +1405,6 @@ static void ac97_class_init (ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);
k->init = ac97_initfn;
k->exit = ac97_exitfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82801AA_5;
k->revision = 0x01;
......
......@@ -1042,13 +1042,6 @@ static int es1370_initfn (PCIDevice *dev)
return 0;
}
static void es1370_exitfn (PCIDevice *dev)
{
ES1370State *s = DO_UPCAST (ES1370State, dev, dev);
memory_region_destroy (&s->io);
}
static int es1370_init (PCIBus *bus)
{
pci_create_simple (bus, -1, "ES1370");
......@@ -1061,7 +1054,6 @@ static void es1370_class_init (ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);
k->init = es1370_initfn;
k->exit = es1370_exitfn;
k->vendor_id = PCI_VENDOR_ID_ENSONIQ;
k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370;
k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
......
......@@ -1155,7 +1155,6 @@ static void intel_hda_exit(PCIDevice *pci)
IntelHDAState *d = INTEL_HDA(pci);
msi_uninit(&d->pci);
memory_region_destroy(&d->mmio);
}
static int intel_hda_post_load(void *opaque, int version)
......
......@@ -839,7 +839,6 @@ static void nvme_exit(PCIDevice *pci_dev)
g_free(n->cq);
g_free(n->sq);
msix_uninit_exclusive_bar(pci_dev);
memory_region_destroy(&n->iomem);
}
static Property nvme_props[] = {
......
......@@ -781,7 +781,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
if (ret < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
memory_region_destroy(&pfl->mem);
error_setg(errp, "failed to read the initial flash content");
return;
}
......
......@@ -617,7 +617,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
ret = bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);
if (ret < 0) {
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
memory_region_destroy(&pfl->orig_mem);
error_setg(errp, "failed to read the initial flash content");
return;
}
......
......@@ -135,7 +135,6 @@ static void serial_pci_exit(PCIDevice *dev)
SerialState *s = &pci->state;
serial_exit_core(s);
memory_region_destroy(&s->io);
qemu_free_irq(s->irq);
}
......@@ -149,10 +148,8 @@ static void multi_serial_pci_exit(PCIDevice *dev)
s = pci->state + i;
serial_exit_core(s);
memory_region_del_subregion(&pci->iobar, &s->io);
memory_region_destroy(&s->io);
g_free(pci->name[i]);
}
memory_region_destroy(&pci->iobar);
qemu_free_irqs(pci->irqs, pci->ports);
}
......
......@@ -697,8 +697,6 @@ static void free_assigned_device(AssignedDevice *dev)
if (region->u.r_baseport) {
memory_region_del_subregion(&region->container,
&region->real_iomem);
memory_region_destroy(&region->real_iomem);
memory_region_destroy(&region->container);
}
} else if (pci_region->type & IORESOURCE_MEM) {
if (region->u.r_virtbase) {
......@@ -712,9 +710,6 @@ static void free_assigned_device(AssignedDevice *dev)
memory_region_del_subregion(&region->container,
&dev->mmio);
}
memory_region_destroy(&region->real_iomem);
memory_region_destroy(&region->container);
if (munmap(region->u.r_virtbase,
(pci_region->size + 0xFFF) & 0xFFFFF000)) {
error_report("Failed to unmap assigned device region: %s",
......@@ -1680,8 +1675,6 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
return;
}
memory_region_destroy(&dev->mmio);
if (munmap(dev->msix_table, MSIX_PAGE_SIZE) == -1) {
error_report("error unmapping msix_table! %s", strerror(errno));
}
......@@ -1953,7 +1946,6 @@ static void assigned_dev_load_option_rom(AssignedDevice *dev)
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
memory_region_destroy(&dev->dev.rom);
goto close_rom;
}
......
......@@ -1197,8 +1197,6 @@ void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
void ahci_uninit(AHCIState *s)
{
memory_region_destroy(&s->mem);
memory_region_destroy(&s->idp);
g_free(s->dev);
}
......
......@@ -310,13 +310,8 @@ static void pci_cmd646_ide_exitfn(PCIDevice *dev)
for (i = 0; i < 2; ++i) {
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io);
memory_region_destroy(&d->bmdma[i].extra_io);
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport);
memory_region_destroy(&d->bmdma[i].addr_ioport);
memory_region_destroy(&d->cmd646_bar[i].cmd);
memory_region_destroy(&d->cmd646_bar[i].data);
}
memory_region_destroy(&d->bmdma_bar);
}
void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,
......
......@@ -207,11 +207,8 @@ static void pci_piix_ide_exitfn(PCIDevice *dev)
for (i = 0; i < 2; ++i) {
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io);
memory_region_destroy(&d->bmdma[i].extra_io);
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport);
memory_region_destroy(&d->bmdma[i].addr_ioport);
}
memory_region_destroy(&d->bmdma_bar);
}
/* hd_table must contain 4 block drivers */
......
......@@ -198,11 +198,8 @@ static void vt82c686b_ide_exitfn(PCIDevice *dev)
for (i = 0; i < 2; ++i) {
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io);
memory_region_destroy(&d->bmdma[i].extra_io);
memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport);
memory_region_destroy(&d->bmdma[i].addr_ioport);
}
memory_region_destroy(&d->bmdma_bar);
}
void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
......
......@@ -613,18 +613,6 @@ static int tpci200_initfn(PCIDevice *pci_dev)
return 0;
}
static void tpci200_exitfn(PCIDevice *pci_dev)
{
TPCI200State *s = TPCI200(pci_dev);
memory_region_destroy(&s->mmio);
memory_region_destroy(&s->io);
memory_region_destroy(&s->las0);
memory_region_destroy(&s->las1);
memory_region_destroy(&s->las2);
memory_region_destroy(&s->las3);
}
static const VMStateDescription vmstate_tpci200 = {
.name = "tpci200",
.version_id = 1,
......@@ -645,7 +633,6 @@ static void tpci200_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = tpci200_initfn;
k->exit = tpci200_exitfn;
k->vendor_id = PCI_VENDOR_ID_TEWS;
k->device_id = PCI_DEVICE_ID_TEWS_TPCI200;
k->class_id = PCI_CLASS_BRIDGE_OTHER;
......
......@@ -789,11 +789,8 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
error_free(s->migration_blocker);
}
memory_region_destroy(&s->ivshmem_mmio);
memory_region_del_subregion(&s->bar, &s->ivshmem);
vmstate_unregister_ram(&s->ivshmem, DEVICE(dev));
memory_region_destroy(&s->ivshmem);
memory_region_destroy(&s->bar);
unregister_savevm(DEVICE(dev), "ivshmem", s);
}
......
......@@ -293,8 +293,6 @@ pci_testdev_uninit(PCIDevice *dev)
g_free(d->tests[i].hdr);
}
g_free(d->tests);
memory_region_destroy(&d->mmio);
memory_region_destroy(&d->portio);
}
static void qdev_pci_testdev_reset(DeviceState *dev)
......
......@@ -2857,15 +2857,11 @@ static void vfio_unmap_bar(VFIODevice *vdev, int nr)
memory_region_del_subregion(&bar->mem, &bar->mmap_mem);
munmap(bar->mmap, memory_region_size(&bar->mmap_mem));
memory_region_destroy(&bar->mmap_mem);
if (vdev->msix && vdev->msix->table_bar == nr) {
memory_region_del_subregion(&bar->mem, &vdev->msix->mmap_mem);
munmap(vdev->msix->mmap, memory_region_size(&vdev->msix->mmap_mem));
memory_region_destroy(&vdev->msix->mmap_mem);
}
memory_region_destroy(&bar->mem);
}
static int vfio_mmap_bar(VFIODevice *vdev, VFIOBAR *bar,
......@@ -3018,9 +3014,6 @@ static void vfio_unmap_bars(VFIODevice *vdev)
if (vdev->has_vga) {
vfio_vga_quirk_teardown(vdev);
pci_unregister_vga(&vdev->pdev);
memory_region_destroy(&vdev->vga.region[QEMU_PCI_VGA_MEM].mem);
memory_region_destroy(&vdev->vga.region[QEMU_PCI_VGA_IO_LO].mem);
memory_region_destroy(&vdev->vga.region[QEMU_PCI_VGA_IO_HI].mem);
}
}
......
......@@ -1496,8 +1496,6 @@ pci_e1000_uninit(PCIDevice *dev)
timer_free(d->autoneg_timer);
timer_del(d->mit_timer);
timer_free(d->mit_timer);
memory_region_destroy(&d->mmio);
memory_region_destroy(&d->io);
qemu_del_nic(d->nic);
}
......
......@@ -1843,9 +1843,6 @@ static void pci_nic_uninit(PCIDevice *pci_dev)
{
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
memory_region_destroy(&s->mmio_bar);
memory_region_destroy(&s->io_bar);
memory_region_destroy(&s->flash_bar);
vmstate_unregister(&pci_dev->qdev, s->vmstate, s);
eeprom93xx_free(&pci_dev->qdev, s->eeprom);
qemu_del_nic(s->nic);
......
......@@ -748,7 +748,6 @@ static void pci_ne2000_exit(PCIDevice *pci_dev)
PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
NE2000State *s = &d->ne2000;
memory_region_destroy(&s->io);
qemu_del_nic(s->nic);
qemu_free_irq(s->irq);
}
......
......@@ -282,8 +282,6 @@ static void pci_pcnet_uninit(PCIDevice *dev)
PCIPCNetState *d = PCI_PCNET(dev);
qemu_free_irq(d->state.irq);
memory_region_destroy(&d->state.mmio);
memory_region_destroy(&d->io_bar);
timer_del(d->state.poll_timer);
timer_free(d->state.poll_timer);
qemu_del_nic(d->state.nic);
......
......@@ -3462,8 +3462,6 @@ static void pci_rtl8139_uninit(PCIDevice *dev)
{
RTL8139State *s = RTL8139(dev);
memory_region_destroy(&s->bar_io);
memory_region_destroy(&s->bar_mem);
if (s->cplus_txbuffer) {
g_free(s->cplus_txbuffer);
s->cplus_txbuffer = NULL;
......
......@@ -485,13 +485,6 @@ static int stellaris_enet_init(SysBusDevice *sbd)
return 0;
}
static void stellaris_enet_unrealize(DeviceState *dev, Error **errp)
{
stellaris_enet_state *s = STELLARIS_ENET(dev);
memory_region_destroy(&s->mmio);
}
static Property stellaris_enet_properties[] = {
DEFINE_NIC_PROPERTIES(stellaris_enet_state, conf),
DEFINE_PROP_END_OF_LIST(),
......@@ -503,7 +496,6 @@ static void stellaris_enet_class_init(ObjectClass *klass, void *data)
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = stellaris_enet_init;
dc->unrealize = stellaris_enet_unrealize;
dc->props = stellaris_enet_properties;
dc->vmsd = &vmstate_stellaris_enet;
}
......
......@@ -2182,10 +2182,6 @@ static void vmxnet3_pci_uninit(PCIDevice *pci_dev)
vmxnet3_cleanup_msix(s);
vmxnet3_cleanup_msi(s);
memory_region_destroy(&s->bar0);
memory_region_destroy(&s->bar1);
memory_region_destroy(&s->msix_bar);
}
static void vmxnet3_qdev_reset(DeviceState *dev)
......
......@@ -81,7 +81,6 @@ msi_error:
slotid_error:
shpc_cleanup(dev, &bridge_dev->bar);
shpc_error:
memory_region_destroy(&bridge_dev->bar);
pci_bridge_exitfn(dev);
bridge_error:
return err;
......@@ -95,7 +94,6 @@ static void pci_bridge_dev_exitfn(PCIDevice *dev)
}
slotid_cap_cleanup(dev);
shpc_cleanup(dev, &bridge_dev->bar);
memory_region_destroy(&bridge_dev->bar);
pci_bridge_exitfn(dev);
}
......
......@@ -319,7 +319,6 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
bar_nr, MSIX_EXCLUSIVE_BAR_PBA_OFFSET,
MSIX_EXCLUSIVE_CAP_OFFSET);
if (ret) {
memory_region_destroy(&dev->msix_exclusive_bar);
return ret;
}
......@@ -359,11 +358,9 @@ void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar)
msix_free_irq_entries(dev);
dev->msix_entries_nr = 0;
memory_region_del_subregion(pba_bar, &dev->msix_pba_mmio);
memory_region_destroy(&dev->msix_pba_mmio);
g_free(dev->msix_pba);
dev->msix_pba = NULL;
memory_region_del_subregion(table_bar, &dev->msix_table_mmio);
memory_region_destroy(&dev->msix_table_mmio);
g_free(dev->msix_table);
dev->msix_table = NULL;
g_free(dev->msix_entry_used);
......@@ -375,7 +372,6 @@ void msix_uninit_exclusive_bar(PCIDevice *dev)
{
if (msix_present(dev)) {
msix_uninit(dev, &dev->msix_exclusive_bar, &dev->msix_exclusive_bar);
memory_region_destroy(&dev->msix_exclusive_bar);
}
}
......
......@@ -799,7 +799,6 @@ static void do_pci_unregister_device(PCIDevice *pci_dev)
pci_config_free(pci_dev);
address_space_destroy(&pci_dev->bus_master_as);
memory_region_destroy(&pci_dev->bus_master_enable_region);
}
/* -1 for devfn means auto assign */
......@@ -1996,7 +1995,6 @@ static void pci_del_option_rom(PCIDevice *pdev)
return;
vmstate_unregister_ram(&pdev->rom, &pdev->qdev);
memory_region_destroy(&pdev->rom);
pdev->has_rom = false;
}
......
......@@ -219,12 +219,6 @@ static void pci_bridge_region_del(PCIBridge *br, PCIBridgeWindows *w)
static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)
{
memory_region_destroy(&w->alias_io);
memory_region_destroy(&w->alias_mem);
memory_region_destroy(&w->alias_pref_mem);
memory_region_destroy(&w->alias_vga[QEMU_PCI_VGA_IO_LO]);
memory_region_destroy(&w->alias_vga[QEMU_PCI_VGA_IO_HI]);
memory_region_destroy(&w->alias_vga[QEMU_PCI_VGA_MEM]);
g_free(w);
}
......@@ -389,8 +383,6 @@ void pci_bridge_exitfn(PCIDevice *pci_dev)
QLIST_REMOVE(&s->sec_bus, sibling);
pci_bridge_region_del(s, s->windows);
pci_bridge_region_cleanup(s, s->windows);
memory_region_destroy(&s->address_space_mem);
memory_region_destroy(&s->address_space_io);
/* object_unparent() is called automatically during device deletion */
}
......
......@@ -94,7 +94,6 @@ void pcie_host_mmcfg_unmap(PCIExpressHost *e)
{
if (e->base_addr != PCIE_BASE_ADDR_UNMAPPED) {
memory_region_del_subregion(get_system_memory(), &e->mmio);
memory_region_destroy(&e->mmio);
e->base_addr = PCIE_BASE_ADDR_UNMAPPED;
}
}
......
......@@ -667,7 +667,6 @@ void shpc_cleanup(PCIDevice *d, MemoryRegion *bar)
g_free(shpc->cmask);
g_free(shpc->wmask);
g_free(shpc->w1cmask);
memory_region_destroy(&shpc->mmio);
g_free(shpc);
}
......
......@@ -378,7 +378,6 @@ static void esp_pci_scsi_uninit(PCIDevice *d)
PCIESPState *pci = PCI_ESP(d);
qemu_free_irq(pci->esp.irq);
memory_region_destroy(&pci->io);
}
static void esp_pci_class_init(ObjectClass *klass, void *data)
......
......@@ -2072,15 +2072,6 @@ static const VMStateDescription vmstate_lsi_scsi = {
}
};
static void lsi_scsi_uninit(PCIDevice *d)
{
LSIState *s = LSI53C895A(d);
memory_region_destroy(&s->mmio_io);
memory_region_destroy(&s->ram_io);
memory_region_destroy(&s->io_io);
}
static const struct SCSIBusInfo lsi_scsi_info = {
.tcq = true,
.max_target = LSI_MAX_DEVS,
......@@ -2134,7 +2125,6 @@ static void lsi_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = lsi_scsi_init;
k->exit = lsi_scsi_uninit;
k->vendor_id = PCI_VENDOR_ID_LSI_LOGIC;
k->device_id = PCI_DEVICE_ID_LSI_53C895A;
k->class_id = PCI_CLASS_STORAGE_SCSI;
......
......@@ -2129,9 +2129,6 @@ static void megasas_scsi_uninit(PCIDevice *d)
if (megasas_use_msi(s)) {
msi_uninit(d);
}
memory_region_destroy(&s->mmio_io);
memory_region_destroy(&s->port_io);
memory_region_destroy(&s->queue_io);
}
static const struct SCSIBusInfo megasas_scsi_info = {
......
......@@ -1087,7 +1087,6 @@ pvscsi_init(PCIDevice *pci_dev)
s->completion_worker = qemu_bh_new(pvscsi_process_completion_queue, s);
if (!s->completion_worker) {
pvscsi_cleanup_msi(s);
memory_region_destroy(&s->io_space);
return -ENOMEM;
}
......@@ -1107,8 +1106,6 @@ pvscsi_uninit(PCIDevice *pci_dev)
qemu_bh_delete(s->completion_worker);
pvscsi_cleanup_msi(s);
memory_region_destroy(&s->io_space);
}
static void
......
......@@ -901,7 +901,6 @@ static void tpm_tis_uninitfn(Object *obj)
TPMState *s = TPM(obj);
memory_region_del_subregion(get_system_memory(), &s->mmio);
memory_region_destroy(&s->mmio);
}
static void tpm_tis_class_init(ObjectClass *klass, void *data)
......
......@@ -1256,13 +1256,6 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
return usb_uhci_common_initfn(dev);
}
static void usb_uhci_exit(PCIDevice *dev)
{
UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
memory_region_destroy(&s->io_bar);
}
static Property uhci_properties[] = {
DEFINE_PROP_STRING("masterbus", UHCIState, masterbus),
DEFINE_PROP_UINT32("firstport", UHCIState, firstport, 0),
......@@ -1279,7 +1272,6 @@ static void uhci_class_init(ObjectClass *klass, void *data)
UHCIInfo *info = data;
k->init = info->initfn ? info->initfn : usb_uhci_common_initfn;
k->exit = info->unplug ? usb_uhci_exit : NULL;
k->vendor_id = info->vendor_id;
k->device_id = info->device_id;
k->revision = info->revision;
......
......@@ -1020,10 +1020,7 @@ static int virtio_pci_init(PCIDevice *pci_dev)
static void virtio_pci_exit(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev);
msix_uninit_exclusive_bar(pci_dev);
memory_region_destroy(&proxy->bar);
}
static void virtio_pci_reset(DeviceState *qdev)
......
......@@ -425,13 +425,6 @@ static int i6300esb_init(PCIDevice *dev)
return 0;
}
static void i6300esb_exit(PCIDevice *dev)
{
I6300State *d = DO_UPCAST(I6300State, dev, dev);
memory_region_destroy(&d->io_mem);
}
static WatchdogTimerModel model = {
.wdt_name = "i6300esb",
.wdt_description = "Intel 6300ESB",
......@@ -445,7 +438,6 @@ static void i6300esb_class_init(ObjectClass *klass, void *data)
k->config_read = i6300esb_config_read;
k->config_write = i6300esb_config_write;
k->init = i6300esb_init;
k->exit = i6300esb_exit;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
k->class_id = PCI_CLASS_SYSTEM_OTHER;
......
......@@ -453,25 +453,6 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s)
return 0;
}
static void xen_pt_unregister_regions(XenPCIPassthroughState *s)
{
XenHostPCIDevice *d = &s->real_device;
int i;