virtio: Add polling virtio-mmio device reset completion
We write 0 to device_status to initiate reset of a virtio-mmio device. The reset operation itself may or may not be completed by the time write instruction completes. Add polling device_status to return 0 to ensure reset completion before reinitializing the device. Change-Id: If15d11d090dfd0d4972ad35f49af03e076872413 Signed-off-by: Jianguo Sun <quic_jianguos@quicinc.com> Signed-off-by: Sreenad Menon <quic_sreemeno@quicinc.com>
This commit is contained in:
parent
f8d51a3599
commit
4cb39792d0
@ -70,6 +70,7 @@
|
|||||||
#include <linux/virtio_config.h>
|
#include <linux/virtio_config.h>
|
||||||
#include <uapi/linux/virtio_mmio.h>
|
#include <uapi/linux/virtio_mmio.h>
|
||||||
#include <linux/virtio_ring.h>
|
#include <linux/virtio_ring.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
|
||||||
#ifdef CONFIG_GH_VIRTIO_DEBUG
|
#ifdef CONFIG_GH_VIRTIO_DEBUG
|
||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
@ -292,6 +293,13 @@ static void vm_reset(struct virtio_device *vdev)
|
|||||||
|
|
||||||
/* 0 status means a reset. */
|
/* 0 status means a reset. */
|
||||||
writel(0, vm_dev->base + VIRTIO_MMIO_STATUS);
|
writel(0, vm_dev->base + VIRTIO_MMIO_STATUS);
|
||||||
|
#ifdef CONFIG_VIRTIO_MMIO_POLL_RESET
|
||||||
|
/* After writing 0 to device_status, the driver MUST wait for a read of
|
||||||
|
* device_status to return 0 before reinitializing the device.
|
||||||
|
*/
|
||||||
|
while (readl(vm_dev->base + VIRTIO_MMIO_STATUS))
|
||||||
|
usleep_range(1000, 1100);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user