@@ -2391,11 +2391,21 @@ void vring_del_virtqueue(struct virtqueue *_vq)
{
struct vring_virtqueue *vq = to_vvq(_vq);
- __vring_del_virtqueue(vq);
+ if (!_vq->reset)
+ __vring_del_virtqueue(vq);
kfree(vq);
}
EXPORT_SYMBOL_GPL(vring_del_virtqueue);
+void vring_reset_virtqueue(struct virtqueue *_vq)
+{
+ struct vring_virtqueue *vq = to_vvq(_vq);
+
+ __vring_del_virtqueue(vq);
+ _vq->reset = true;
+}
+EXPORT_SYMBOL_GPL(vring_reset_virtqueue);
+
/* Manipulates transport-specific feature bits. */
void vring_transport_features(struct virtio_device *vdev)
{
@@ -124,6 +124,11 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
*/
void vring_del_virtqueue(struct virtqueue *vq);
+/*
+ * Resets a virtqueue. Just frees the ring, not free vq.
+ */
+void vring_reset_virtqueue(struct virtqueue *vq);
+
/* Filter out transport-specific feature bits. */
void vring_transport_features(struct virtio_device *vdev);
Added vring_reset_virtqueue() for reset vring_virtqueue. In this process, vq is removed from the vdev->vqs queue. And the memory of the ring is released Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- drivers/virtio/virtio_ring.c | 12 +++++++++++- include/linux/virtio_ring.h | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-)