mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +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
4f0b86adf9
commit
a65e01ae95
@ -376,6 +376,7 @@ virtio_audio_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
close(virt_audio->vbs_k.audio_fd);
|
close(virt_audio->vbs_k.audio_fd);
|
||||||
virt_audio->vbs_k.audio_fd = -1;
|
virt_audio->vbs_k.audio_fd = -1;
|
||||||
}
|
}
|
||||||
|
virtio_audio_reset(virt_audio);
|
||||||
pthread_mutex_destroy(&virt_audio->mtx);
|
pthread_mutex_destroy(&virt_audio->mtx);
|
||||||
DPRINTF(("%s: free struct virtio_audio!\n", __func__));
|
DPRINTF(("%s: free struct virtio_audio!\n", __func__));
|
||||||
free((struct virtio_audio *)dev->arg);
|
free((struct virtio_audio *)dev->arg);
|
||||||
|
@ -587,6 +587,7 @@ virtio_blk_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
WPRINTF(("vrito_blk: Failed to flush before close\n"));
|
WPRINTF(("vrito_blk: Failed to flush before close\n"));
|
||||||
blockif_close(bctxt);
|
blockif_close(bctxt);
|
||||||
}
|
}
|
||||||
|
virtio_reset_dev(&blk->base);
|
||||||
free(blk);
|
free(blk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,6 +1009,7 @@ static void
|
|||||||
virtio_console_destroy(struct virtio_console *console)
|
virtio_console_destroy(struct virtio_console *console)
|
||||||
{
|
{
|
||||||
if (console) {
|
if (console) {
|
||||||
|
virtio_console_reset(console);
|
||||||
if (console->config)
|
if (console->config)
|
||||||
free(console->config);
|
free(console->config);
|
||||||
free(console);
|
free(console);
|
||||||
|
@ -358,6 +358,7 @@ virtio_coreu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
pthread_cond_destroy(&vcoreu->rx_cond);
|
pthread_cond_destroy(&vcoreu->rx_cond);
|
||||||
pthread_join(vcoreu->rx_tid, NULL);
|
pthread_join(vcoreu->rx_tid, NULL);
|
||||||
|
|
||||||
|
virtio_coreu_reset(vcoreu);
|
||||||
free(vcoreu);
|
free(vcoreu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,6 +1433,7 @@ virtio_gpio_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
gpio_irq_deinit(gpio);
|
gpio_irq_deinit(gpio);
|
||||||
for (i = 0; i < gpio->nchip; i++)
|
for (i = 0; i < gpio->nchip; i++)
|
||||||
native_gpio_close_chip(&gpio->chips[i]);
|
native_gpio_close_chip(&gpio->chips[i]);
|
||||||
|
virtio_gpio_reset(gpio);
|
||||||
free(gpio);
|
free(gpio);
|
||||||
dev->arg = NULL;
|
dev->arg = NULL;
|
||||||
}
|
}
|
||||||
|
@ -480,6 +480,7 @@ virtio_hdcp_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
|
|
||||||
if (vhdcp) {
|
if (vhdcp) {
|
||||||
DPRINTF(("free struct virtio_hdcp\n"));
|
DPRINTF(("free struct virtio_hdcp\n"));
|
||||||
|
virtio_hdcp_reset(vhdcp);
|
||||||
free(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;
|
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);
|
free((struct virtio_hyper_dmabuf *)dev->arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pci_vdev_ops pci_ops_virtio_hyper_dmabuf = {
|
struct pci_vdev_ops pci_ops_virtio_hyper_dmabuf = {
|
||||||
|
@ -826,6 +826,7 @@ virtio_i2c_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
native_adapter_remove(vi2c);
|
native_adapter_remove(vi2c);
|
||||||
pthread_mutex_destroy(&vi2c->req_mtx);
|
pthread_mutex_destroy(&vi2c->req_mtx);
|
||||||
pthread_mutex_destroy(&vi2c->mtx);
|
pthread_mutex_destroy(&vi2c->mtx);
|
||||||
|
virtio_i2c_reset(vi2c);
|
||||||
free(vi2c);
|
free(vi2c);
|
||||||
dev->arg = NULL;
|
dev->arg = NULL;
|
||||||
}
|
}
|
||||||
|
@ -585,6 +585,8 @@ virtio_input_teardown(void *param)
|
|||||||
free(vi->evdev);
|
free(vi->evdev);
|
||||||
if (vi->serial)
|
if (vi->serial)
|
||||||
free(vi->serial);
|
free(vi->serial);
|
||||||
|
|
||||||
|
virtio_input_reset(vi);
|
||||||
free(vi);
|
free(vi);
|
||||||
vi = NULL;
|
vi = NULL;
|
||||||
}
|
}
|
||||||
|
@ -377,6 +377,7 @@ virtio_ipu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
close(ipu->vbs_k.ipu_fd);
|
close(ipu->vbs_k.ipu_fd);
|
||||||
ipu->vbs_k.ipu_fd = -1;
|
ipu->vbs_k.ipu_fd = -1;
|
||||||
}
|
}
|
||||||
|
virtio_ipu_reset(ipu);
|
||||||
pthread_mutex_destroy(&ipu->mtx);
|
pthread_mutex_destroy(&ipu->mtx);
|
||||||
free(ipu);
|
free(ipu);
|
||||||
}
|
}
|
||||||
|
@ -971,6 +971,7 @@ vmei_reset_teardown(void *param)
|
|||||||
vmei->reset_mevp = NULL;
|
vmei->reset_mevp = NULL;
|
||||||
|
|
||||||
pthread_mutex_destroy(&vmei->mutex);
|
pthread_mutex_destroy(&vmei->mutex);
|
||||||
|
virtio_reset_dev(&vmei->base);
|
||||||
free(vmei->config);
|
free(vmei->config);
|
||||||
free(vmei);
|
free(vmei);
|
||||||
}
|
}
|
||||||
|
@ -1067,6 +1067,7 @@ virtio_net_teardown(void *param)
|
|||||||
} else
|
} else
|
||||||
pr_err("net->tapfd is -1!\n");
|
pr_err("net->tapfd is -1!\n");
|
||||||
|
|
||||||
|
virtio_reset_dev(&net->base);
|
||||||
free(net);
|
free(net);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,6 +510,7 @@ virtio_rnd_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
close(rnd->fd);
|
close(rnd->fd);
|
||||||
rnd->fd = -1;
|
rnd->fd = -1;
|
||||||
}
|
}
|
||||||
|
virtio_rnd_reset(rnd);
|
||||||
DPRINTF(("%s: free struct virtio_rnd!\n", __func__));
|
DPRINTF(("%s: free struct virtio_rnd!\n", __func__));
|
||||||
free(rnd);
|
free(rnd);
|
||||||
}
|
}
|
||||||
|
@ -794,6 +794,7 @@ virtio_rpmb_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
{
|
{
|
||||||
if (dev->arg) {
|
if (dev->arg) {
|
||||||
DPRINTF(("virtio_rpmb_be_deinit: free struct virtio_rpmb!\n"));
|
DPRINTF(("virtio_rpmb_be_deinit: free struct virtio_rpmb!\n"));
|
||||||
|
virtio_rpmb_reset(dev->arg);
|
||||||
free((struct virtio_rpmb *)dev->arg);
|
free((struct virtio_rpmb *)dev->arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user