From: sf Date: Tue, 30 May 2017 11:02:39 +0000 (+0000) Subject: virtio: Put entries in freelist in reverse order X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=109703c55fc655c1147741d8f8747ec08c1a4b3f;p=openbsd virtio: Put entries in freelist in reverse order This avoids breaking krw@'s ongoing work on improving virtio_enqueue_trim(). --- diff --git a/sys/dev/pv/virtio.c b/sys/dev/pv/virtio.c index 8d1fb468933..9dee3fbb6f3 100644 --- a/sys/dev/pv/virtio.c +++ b/sys/dev/pv/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.6 2017/05/30 08:35:32 sf Exp $ */ +/* $OpenBSD: virtio.c,v 1.7 2017/05/30 11:02:39 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -257,7 +257,11 @@ virtio_init_vq(struct virtio_softc *sc, struct virtqueue *vq, int reinit) /* free slot management */ SLIST_INIT(&vq->vq_freelist); - for (i = 0; i < vq_size; i++) { + /* + * virtio_enqueue_trim needs monotonely raising entries, therefore + * initialize in reverse order + */ + for (i = vq_size - 1; i >= 0; i--) { SLIST_INSERT_HEAD(&vq->vq_freelist, &vq->vq_entries[i], qe_list); vq->vq_entries[i].qe_index = i;