From 30a9d5907018a578873bff2f7f1eaccfcc4d5a1f Mon Sep 17 00:00:00 2001 From: mischief Date: Sun, 20 Sep 2015 01:56:56 -0700 Subject: [PATCH] pc, pc64: fix sdvirtio descriptor count when sending flush --- sys/src/9/pc/sdvirtio.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sys/src/9/pc/sdvirtio.c b/sys/src/9/pc/sdvirtio.c index 64c43ddf3..6bb6c1162 100644 --- a/sys/src/9/pc/sdvirtio.c +++ b/sys/src/9/pc/sdvirtio.c @@ -326,7 +326,7 @@ vqio(Vqueue *q, int head) static int vioblkreq(Vdev *vd, int typ, void *a, long count, long secsize, uvlong lba) { - int free, head; + int need, free, head; Vqueue *q; Vdesc *d; @@ -337,14 +337,18 @@ vioblkreq(Vdev *vd, int typ, void *a, long count, long secsize, uvlong lba) u64int lba; } req; - status = 0; + need = 2; + if(a != nil) + need = 3; + + status = -1; req.typ = typ; req.prio = 0; req.lba = lba; q = vd->queue[0]; ilock(q); - while(q->nfree < 3){ + while(q->nfree < need){ iunlock(q); if(!waserror()) @@ -361,10 +365,12 @@ vioblkreq(Vdev *vd, int typ, void *a, long count, long secsize, uvlong lba) d->len = sizeof(req); d->flags = Next; - d = &q->desc[free]; free = d->next; - d->addr = PADDR(a); - d->len = secsize*count; - d->flags = typ ? Next : (Write|Next); + if(a != nil){ + d = &q->desc[free]; free = d->next; + d->addr = PADDR(a); + d->len = secsize*count; + d->flags = typ ? Next : (Write|Next); + } d = &q->desc[free]; free = d->next; d->addr = PADDR(&status); @@ -372,7 +378,7 @@ vioblkreq(Vdev *vd, int typ, void *a, long count, long secsize, uvlong lba) d->flags = Write; q->free = free; - q->nfree -= 3; + q->nfree -= need; /* queue io, unlock and wait for completion */ vqio(q, head);