diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2016-04-03 08:23:37 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-04-07 08:16:39 -0400 |
commit | 05dbcb430795b2e1fb1d5c757f8619d3dbed0a1c (patch) | |
tree | 62a07c001c763f524d794ec83d25a5338f1a612c /drivers/virtio/virtio_pci_modern.c | |
parent | e8aabc64d7f5c8702e420c6fa478368f60718ae4 (diff) |
virtio: virtio 1.0 cs04 spec compliance for reset
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.
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio_pci_modern.c')
-rw-r--r-- | drivers/virtio/virtio_pci_modern.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index f6f28cc7eb45..e76bd91a29da 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/delay.h> | ||
20 | #define VIRTIO_PCI_NO_LEGACY | 21 | #define VIRTIO_PCI_NO_LEGACY |
21 | #include "virtio_pci_common.h" | 22 | #include "virtio_pci_common.h" |
22 | 23 | ||
@@ -271,9 +272,13 @@ static void vp_reset(struct virtio_device *vdev) | |||
271 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 272 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
272 | /* 0 status means a reset. */ | 273 | /* 0 status means a reset. */ |
273 | vp_iowrite8(0, &vp_dev->common->device_status); | 274 | vp_iowrite8(0, &vp_dev->common->device_status); |
274 | /* Flush out the status write, and flush in device writes, | 275 | /* After writing 0 to device_status, the driver MUST wait for a read of |
275 | * including MSI-X interrupts, if any. */ | 276 | * device_status to return 0 before reinitializing the device. |
276 | vp_ioread8(&vp_dev->common->device_status); | 277 | * This will flush out the status write, and flush in device writes, |
278 | * including MSI-X interrupts, if any. | ||
279 | */ | ||
280 | while (vp_ioread8(&vp_dev->common->device_status)) | ||
281 | msleep(1); | ||
277 | /* Flush pending VQ/configuration callbacks. */ | 282 | /* Flush pending VQ/configuration callbacks. */ |
278 | vp_synchronize_vectors(vdev); | 283 | vp_synchronize_vectors(vdev); |
279 | } | 284 | } |