DM: release mmio data structure for pci bar
We didn't release mmio/io data structure related with PCI bar of pci dev. Which could trigger memory leak when reboot UOS. With the new patch, we release the mmio/io data structure when pci core tries to deinit pci device. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
parent
3726a0f7a5
commit
f0b74016d1
|
@ -665,6 +665,20 @@ pci_emul_alloc_pbar(struct pci_vdev *pdi, int idx, uint64_t hostbase,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pci_emul_free_bars(struct pci_vdev *pdi)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < PCI_BARMAX; i++) {
|
||||||
|
if ((pdi->bar[i].type != PCIBAR_NONE) &&
|
||||||
|
(pdi->bar[i].type != PCIBAR_MEMHI64)){
|
||||||
|
unregister_bar(pdi, i);
|
||||||
|
pdi->bar[i].type = PCIBAR_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define CAP_START_OFFSET 0x40
|
#define CAP_START_OFFSET 0x40
|
||||||
int
|
int
|
||||||
pci_emul_add_capability(struct pci_vdev *dev, u_char *capdata, int caplen)
|
pci_emul_add_capability(struct pci_vdev *dev, u_char *capdata, int caplen)
|
||||||
|
@ -772,6 +786,8 @@ pci_emul_deinit(struct vmctx *ctx, struct pci_vdev_ops *ops, int bus, int slot,
|
||||||
(*ops->vdev_deinit)(ctx, fi->fi_devi, fi->fi_param);
|
(*ops->vdev_deinit)(ctx, fi->fi_devi, fi->fi_param);
|
||||||
if (fi->fi_param)
|
if (fi->fi_param)
|
||||||
free(fi->fi_param);
|
free(fi->fi_param);
|
||||||
|
|
||||||
|
pci_emul_free_bars(fi->fi_devi);
|
||||||
if (fi->fi_devi)
|
if (fi->fi_devi)
|
||||||
free(fi->fi_devi);
|
free(fi->fi_devi);
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,7 @@ int pci_emul_alloc_bar(struct pci_vdev *pdi, int idx,
|
||||||
int pci_emul_alloc_pbar(struct pci_vdev *pdi, int idx,
|
int pci_emul_alloc_pbar(struct pci_vdev *pdi, int idx,
|
||||||
uint64_t hostbase, enum pcibar_type type,
|
uint64_t hostbase, enum pcibar_type type,
|
||||||
uint64_t size);
|
uint64_t size);
|
||||||
|
void pci_emul_free_bars(struct pci_vdev *pdi);
|
||||||
int pci_emul_add_capability(struct pci_vdev *dev, u_char *capdata,
|
int pci_emul_add_capability(struct pci_vdev *dev, u_char *capdata,
|
||||||
int caplen);
|
int caplen);
|
||||||
int pci_emul_add_msicap(struct pci_vdev *pi, int msgnum);
|
int pci_emul_add_msicap(struct pci_vdev *pi, int msgnum);
|
||||||
|
|
Loading…
Reference in New Issue