Skip to content

Commit e2dcdfe

Browse files
committed
virtio: virtio_break_device() to mark all virtqueues broken.
Good for post-apocalyptic scenarios, like S/390 hotplug. Signed-off-by: Rusty Russell <[email protected]>
1 parent ec6931b commit e2dcdfe

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/virtio/virtio_ring.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,4 +865,19 @@ bool virtqueue_is_broken(struct virtqueue *_vq)
865865
}
866866
EXPORT_SYMBOL_GPL(virtqueue_is_broken);
867867

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+
868883
MODULE_LICENSE("GPL");

include/linux/virtio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ static inline struct virtio_device *dev_to_virtio(struct device *_dev)
106106
int register_virtio_device(struct virtio_device *dev);
107107
void unregister_virtio_device(struct virtio_device *dev);
108108

109+
void virtio_break_device(struct virtio_device *dev);
110+
109111
/**
110112
* virtio_driver - operations for a virtio I/O driver
111113
* @driver: underlying device driver (populate name and owner).

0 commit comments

Comments
 (0)