From 1dbd8bc927ac37dc09d1057b35d6a75a9fcd7aa7 Mon Sep 17 00:00:00 2001 From: Peter Grehan Date: Thu, 11 Oct 2012 23:03:42 +0000 Subject: [PATCH] Patch from Bryan to fix a virtqueue issue: virtqueue: Fix non-indirect virtqueues We really must walk the entire descriptor chain in order to append the to be free'd chain to the existing free chain. Submitted by: Bryan Venteicher (bryanv@daemoninthecloset.org) Reported by: cognet --- sys/dev/virtio/virtqueue.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index 0511609b2f3..1553afaa643 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -780,8 +780,8 @@ vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) VQ_RING_ASSERT_CHAIN_TERM(vq); vq->vq_free_cnt += dxp->ndescs; + dxp->ndescs--; -#ifdef INVARIANTS if ((dp->flags & VRING_DESC_F_INDIRECT) == 0) { while (dp->flags & VRING_DESC_F_NEXT) { VQ_RING_ASSERT_VALID_IDX(vq, dp->next); @@ -789,10 +789,9 @@ vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) dxp->ndescs--; } } - VQASSERT(vq, dxp->ndescs == 1, + + VQASSERT(vq, dxp->ndescs == 0, "failed to free entire desc chain, remaining: %d", dxp->ndescs); -#endif - dxp->ndescs = 0; /* * We must append the existing free chain, if any, to the end of