Commit db755556 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Kamal Mostafa

virtio: virtio 1.0 cs04 spec compliance for reset

commit 05dbcb43 upstream.

The spec says: after writing 0 to device_status, the driver MUST wait
for a read of device_status to return 0 before reinitializing the
device.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent afaa781e
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* *
*/ */
#include <linux/delay.h>
#define VIRTIO_PCI_NO_LEGACY #define VIRTIO_PCI_NO_LEGACY
#include "virtio_pci_common.h" #include "virtio_pci_common.h"
...@@ -271,9 +272,13 @@ static void vp_reset(struct virtio_device *vdev) ...@@ -271,9 +272,13 @@ static void vp_reset(struct virtio_device *vdev)
struct virtio_pci_device *vp_dev = to_vp_device(vdev); struct virtio_pci_device *vp_dev = to_vp_device(vdev);
/* 0 status means a reset. */ /* 0 status means a reset. */
vp_iowrite8(0, &vp_dev->common->device_status); vp_iowrite8(0, &vp_dev->common->device_status);
/* Flush out the status write, and flush in device writes, /* After writing 0 to device_status, the driver MUST wait for a read of
* including MSI-X interrupts, if any. */ * device_status to return 0 before reinitializing the device.
vp_ioread8(&vp_dev->common->device_status); * This will flush out the status write, and flush in device writes,
* including MSI-X interrupts, if any.
*/
while (vp_ioread8(&vp_dev->common->device_status))
msleep(1);
/* Flush pending VQ/configuration callbacks. */ /* Flush pending VQ/configuration callbacks. */
vp_synchronize_vectors(vdev); vp_synchronize_vectors(vdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment