DM: release mem range allocated in init_pci

Two memory ranges are allocated:
  - PCI ECFG
  - PCI hole
They should be released when deinit_pci. Old code mark
this two ranges not unregistered. Which is wrong for
warm reboot case. Make them could be unregistered.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yin Fengwei
2018-04-13 18:03:02 +08:00
committed by Jack Ren
parent 097aee76bf
commit 96085d960f
3 changed files with 48 additions and 2 deletions

View File

@@ -234,6 +234,34 @@ register_mem_fallback(struct mem_range *memp)
return register_mem_int(&mmio_rb_fallback, memp);
}
int
unregister_mem_fallback(struct mem_range *memp)
{
struct mem_range *mr;
struct mmio_rb_range *entry = NULL;
int err;
pthread_rwlock_wrlock(&mmio_rwlock);
err = mmio_rb_lookup(&mmio_rb_fallback, memp->base, &entry);
if (err == 0) {
mr = &entry->mr_param;
assert(mr->name == memp->name);
assert(mr->base == memp->base && mr->size == memp->size);
assert((mr->flags & MEM_F_IMMUTABLE) == 0);
RB_REMOVE(mmio_rb_tree, &mmio_rb_fallback, entry);
/* flush Per-VM cache */
if (mmio_hint == entry)
mmio_hint = NULL;
}
pthread_rwlock_unlock(&mmio_rwlock);
if (entry)
free(entry);
return err;
}
int
unregister_mem(struct mem_range *memp)
{