On Tue, Apr 07, 2026 at 08:39:01AM -0400, Andrew Stellman wrote:
> 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.
It does? But where?
I see:
Reading from this register returns the current device status
flags.
Writing non-zero values to this register sets the status flags,
indicating the OS/driver progress. Writing zero (0x0) to this
register triggers a device reset. The device
sets \field{QueuePFN} to zero (0x0) for all queues in the device.
> 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