Commit 84b7fc44 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Pengyuan Zhao
Browse files

virtio: wrap config->reset calls

mainline inclusion
from mainline-v5.17-rc1
commit d9679d00
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WXCZ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d9679d0013a66849f23057978f92e76b255c50aa



----------------------------------------------------------------------

This will enable cleanups down the road.
The idea is to disable cbs, then add "flush_queued_cbs" callback
as a parameter, this way drivers can flush any work
queued after callbacks have been disabled.

Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20211013105226.20225-1-mst@redhat.com


Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarPengyuan Zhao <zhaopengyuan@hisilicon.com>
parent 21ea447d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -933,7 +933,7 @@ static void virtblk_remove(struct virtio_device *vdev)
	mutex_lock(&vblk->vdev_mutex);

	/* Stop all the virtqueues. */
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);

	/* Virtqueues are stopped, nothing can use vblk->vdev anymore. */
	vblk->vdev = NULL;
@@ -953,7 +953,7 @@ static int virtblk_freeze(struct virtio_device *vdev)
	struct virtio_blk *vblk = vdev->priv;

	/* Ensure we don't receive any more interrupts */
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);

	/* Make sure no work handler is accessing the device. */
	flush_work(&vblk->config_work);
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ static void remove_common(struct virtio_device *vdev)
	vi->hwrng_removed = true;
	vi->data_avail = 0;
	complete(&vi->have_data);
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	vi->busy = false;
	if (vi->hwrng_register_done)
		hwrng_unregister(&vi->hwrng);
+2 −2
Original line number Diff line number Diff line
@@ -1967,7 +1967,7 @@ static void virtcons_remove(struct virtio_device *vdev)
		flush_work(&portdev->config_work);

	/* Disable interrupts for vqs */
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	/* Finish up work that's lined up */
	if (use_multiport(portdev))
		cancel_work_sync(&portdev->control_work);
@@ -2149,7 +2149,7 @@ static int virtcons_freeze(struct virtio_device *vdev)

	portdev = vdev->priv;

	vdev->config->reset(vdev);
	virtio_reset_device(vdev);

	if (use_multiport(portdev))
		virtqueue_disable_cb(portdev->c_ivq);
+4 −4
Original line number Diff line number Diff line
@@ -404,7 +404,7 @@ static int virtcrypto_probe(struct virtio_device *vdev)
free_engines:
	virtcrypto_clear_crypto_engines(vcrypto);
free_vqs:
	vcrypto->vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	virtcrypto_del_vqs(vcrypto);
free_dev:
	virtcrypto_devmgr_rm_dev(vcrypto);
@@ -436,7 +436,7 @@ static void virtcrypto_remove(struct virtio_device *vdev)

	if (virtcrypto_dev_started(vcrypto))
		virtcrypto_dev_stop(vcrypto);
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	virtcrypto_free_unused_reqs(vcrypto);
	virtcrypto_clear_crypto_engines(vcrypto);
	virtcrypto_del_vqs(vcrypto);
@@ -456,7 +456,7 @@ static int virtcrypto_freeze(struct virtio_device *vdev)
{
	struct virtio_crypto *vcrypto = vdev->priv;

	vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	virtcrypto_free_unused_reqs(vcrypto);
	if (virtcrypto_dev_started(vcrypto))
		virtcrypto_dev_stop(vcrypto);
@@ -492,7 +492,7 @@ static int virtcrypto_restore(struct virtio_device *vdev)
free_engines:
	virtcrypto_clear_crypto_engines(vcrypto);
free_vqs:
	vcrypto->vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	virtcrypto_del_vqs(vcrypto);
	return err;
}
+1 −1
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ void virtio_gpu_deinit(struct drm_device *dev)
	flush_work(&vgdev->ctrlq.dequeue_work);
	flush_work(&vgdev->cursorq.dequeue_work);
	flush_work(&vgdev->config_changed_work);
	vgdev->vdev->config->reset(vgdev->vdev);
	virtio_reset_device(vgdev->vdev);
	vgdev->vdev->config->del_vqs(vgdev->vdev);
}

Loading