Commit e2dcdfe95c0bd67e37db6057edd9c4ee1f1c7b17

Authored by Rusty Russell
1 parent ec6931b281

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>

Showing 2 changed files with 17 additions and 0 deletions Side-by-side Diff

drivers/virtio/virtio_ring.c
... ... @@ -865,5 +865,20 @@
865 865 }
866 866 EXPORT_SYMBOL_GPL(virtqueue_is_broken);
867 867  
  868 +/*
  869 + * This should prevent the device from being used, allowing drivers to
  870 + * recover. You may need to grab appropriate locks to flush.
  871 + */
  872 +void virtio_break_device(struct virtio_device *dev)
  873 +{
  874 + struct virtqueue *_vq;
  875 +
  876 + list_for_each_entry(_vq, &dev->vqs, list) {
  877 + struct vring_virtqueue *vq = to_vvq(_vq);
  878 + vq->broken = true;
  879 + }
  880 +}
  881 +EXPORT_SYMBOL_GPL(virtio_break_device);
  882 +
868 883 MODULE_LICENSE("GPL");
include/linux/virtio.h
... ... @@ -106,6 +106,8 @@
106 106 int register_virtio_device(struct virtio_device *dev);
107 107 void unregister_virtio_device(struct virtio_device *dev);
108 108  
  109 +void virtio_break_device(struct virtio_device *dev);
  110 +
109 111 /**
110 112 * virtio_driver - operations for a virtio I/O driver
111 113 * @driver: underlying device driver (populate name and owner).