summaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_ring.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2014-04-28 03:45:08 +0200
committerRusty Russell <rusty@rustcorp.com.au>2014-04-28 04:04:13 +0200
commite2dcdfe95c0bd67e37db6057edd9c4ee1f1c7b17 (patch)
treed6e0676596a6f906362d836a08e4629dc9442fdd /drivers/virtio/virtio_ring.c
parentword-at-a-time: avoid undefined behaviour in zero_bytemask macro (diff)
downloadlinux-e2dcdfe95c0bd67e37db6057edd9c4ee1f1c7b17.tar.xz
linux-e2dcdfe95c0bd67e37db6057edd9c4ee1f1c7b17.zip
virtio: virtio_break_device() to mark all virtqueues broken.
Good for post-apocalyptic scenarios, like S/390 hotplug. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio_ring.c')
-rw-r--r--drivers/virtio/virtio_ring.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 1e443629f76d..4d08f45a9c29 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -865,4 +865,19 @@ bool virtqueue_is_broken(struct virtqueue *_vq)
}
EXPORT_SYMBOL_GPL(virtqueue_is_broken);
+/*
+ * This should prevent the device from being used, allowing drivers to
+ * recover. You may need to grab appropriate locks to flush.
+ */
+void virtio_break_device(struct virtio_device *dev)
+{
+ struct virtqueue *_vq;
+
+ list_for_each_entry(_vq, &dev->vqs, list) {
+ struct vring_virtqueue *vq = to_vvq(_vq);
+ vq->broken = true;
+ }
+}
+EXPORT_SYMBOL_GPL(virtio_break_device);
+
MODULE_LICENSE("GPL");