The virtio specification requires that after writing 0 to the status register, the driver must wait until the device has actually completed the reset (status reads back as 0) before proceeding. vm_reset() writes 0 but returns immediately without confirming the device has reset.
Add a poll loop matching the pattern already used in virtio-pci's vp_reset(), which calls msleep(1) in a loop until the status register reads 0. Signed-off-by: Andrew Stellman <[email protected]> --- drivers/virtio/virtio_mmio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 595c227..a477977 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -56,6 +56,7 @@ #include <linux/acpi.h> #include <linux/dma-mapping.h> +#include <linux/delay.h> #include <linux/highmem.h> #include <linux/interrupt.h> #include <linux/io.h> @@ -254,6 +255,8 @@ static void vm_reset(struct virtio_device *vdev) /* 0 status means a reset. */ writel(0, vm_dev->base + VIRTIO_MMIO_STATUS); + while (readl(vm_dev->base + VIRTIO_MMIO_STATUS)) + msleep(1); } -- 2.34.1
