mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-26 15:31:35 +00:00
dm: Reset virtio device before release
With virtio polling mode enabled, a timer is running in the virtio backend service. And the timer will also be triggered if its frondend driver didn't do the device reset in shutdown. A freed virtio device will be accessed in the polling timer handler. Do the virtio reset() callback specifically to clear the polling timer before the free. Tracked-On: #6147 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
parent
65a957dff8
commit
2b91780b4e
@ -372,6 +372,7 @@ virtio_audio_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
close(virt_audio->vbs_k.audio_fd);
|
||||
virt_audio->vbs_k.audio_fd = -1;
|
||||
}
|
||||
virtio_audio_reset(virt_audio);
|
||||
pthread_mutex_destroy(&virt_audio->mtx);
|
||||
DPRINTF(("%s: free struct virtio_audio!\n", __func__));
|
||||
free((struct virtio_audio *)dev->arg);
|
||||
|
@ -482,6 +482,7 @@ virtio_blk_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
WPRINTF(("vrito_blk:"
|
||||
"Failed to flush before close\n"));
|
||||
blockif_close(bctxt);
|
||||
virtio_reset_dev(&blk->base);
|
||||
free(blk);
|
||||
}
|
||||
}
|
||||
|
@ -740,6 +740,7 @@ static void
|
||||
virtio_console_destroy(struct virtio_console *console)
|
||||
{
|
||||
if (console) {
|
||||
virtio_console_reset(console);
|
||||
if (console->config)
|
||||
free(console->config);
|
||||
free(console);
|
||||
|
@ -341,6 +341,7 @@ virtio_coreu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
pthread_cond_destroy(&vcoreu->rx_cond);
|
||||
pthread_join(vcoreu->rx_tid, NULL);
|
||||
|
||||
virtio_coreu_reset(vcoreu);
|
||||
free(vcoreu);
|
||||
}
|
||||
|
||||
|
@ -466,6 +466,7 @@ virtio_hdcp_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
|
||||
if (vhdcp) {
|
||||
DPRINTF(("free struct virtio_hdcp\n"));
|
||||
virtio_hdcp_reset(vhdcp);
|
||||
free(vhdcp);
|
||||
}
|
||||
}
|
||||
|
@ -348,8 +348,10 @@ virtio_hyper_dmabuf_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
vbs_k_hyper_dmabuf_fd = -1;
|
||||
}
|
||||
|
||||
if (dev->arg)
|
||||
if (dev->arg) {
|
||||
virtio_hyper_dmabuf_reset(dev->arg);
|
||||
free((struct virtio_hyper_dmabuf *)dev->arg);
|
||||
}
|
||||
}
|
||||
|
||||
struct pci_vdev_ops pci_ops_virtio_hyper_dmabuf = {
|
||||
|
@ -559,6 +559,8 @@ virtio_input_teardown(void *param)
|
||||
free(vi->evdev);
|
||||
if (vi->serial)
|
||||
free(vi->serial);
|
||||
|
||||
virtio_input_reset(vi);
|
||||
free(vi);
|
||||
vi = NULL;
|
||||
}
|
||||
|
@ -379,6 +379,7 @@ virtio_ipu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
close(ipu->vbs_k.ipu_fd);
|
||||
ipu->vbs_k.ipu_fd = -1;
|
||||
}
|
||||
virtio_ipu_reset(ipu);
|
||||
pthread_mutex_destroy(&ipu->mtx);
|
||||
free(ipu);
|
||||
}
|
||||
|
@ -976,6 +976,7 @@ vmei_reset_teardown(void *param)
|
||||
vmei->reset_mevp = NULL;
|
||||
|
||||
pthread_mutex_destroy(&vmei->mutex);
|
||||
virtio_reset_dev(&vmei->base);
|
||||
free(vmei->config);
|
||||
free(vmei);
|
||||
}
|
||||
|
@ -975,6 +975,7 @@ virtio_net_teardown(void *param)
|
||||
} else
|
||||
fprintf(stderr, "net->tapfd is -1!\n");
|
||||
|
||||
virtio_reset_dev(&net->base);
|
||||
free(net);
|
||||
}
|
||||
|
||||
|
@ -492,6 +492,7 @@ virtio_rnd_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
assert(rnd->fd >= 0);
|
||||
close(rnd->fd);
|
||||
DPRINTF(("%s: free struct virtio_rnd!\n", __func__));
|
||||
virtio_rnd_reset(rnd);
|
||||
free(rnd);
|
||||
}
|
||||
|
||||
|
@ -777,6 +777,7 @@ virtio_rpmb_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
{
|
||||
if (dev->arg) {
|
||||
DPRINTF(("virtio_rpmb_be_deinit: free struct virtio_rpmb!\n"));
|
||||
virtio_rpmb_reset(dev->arg);
|
||||
free((struct virtio_rpmb *)dev->arg);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user