diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-07-11 12:12:51 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-07-11 12:12:51 +0000 |
commit | ad37339a1c39c90f51d273abe60f552d3900f752 (patch) | |
tree | 28f44d5f2d92a807e4003d4ff0fdbef8444a7816 | |
parent | f58d99aa7a97ba5f79af89f38b78d5924d4e35a2 (diff) | |
download | plan9front-ad37339a1c39c90f51d273abe60f552d3900f752.tar.xz |
vmx: reset virtio queue state on device reset
when a virtio device gets reset, we have to also reset the device
shadow indices: availableidx and usedidx. for extra safetly,
we also reset the buffer descriptor table addresses.
this is accomplished by adding a vioqreset(VIOQueue*) function
that brings the queue to its initial reset state.
this fixes non functional ethernet after reboot(8).
-rw-r--r-- | sys/src/cmd/vmx/virtio.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/src/cmd/vmx/virtio.c b/sys/src/cmd/vmx/virtio.c index 6451eeef5..da0558320 100644 --- a/sys/src/cmd/vmx/virtio.c +++ b/sys/src/cmd/vmx/virtio.c @@ -311,6 +311,17 @@ vioqaddrset(VIOQueue *q, u64int addr) } static void +vioqreset(VIOQueue *q) +{ + q->desc = nil; + q->avail = nil; + q->used = nil; + q->addr = 0; + q->availidx = 0; + q->usedidx = 0; +} + +static void viodevstatset(VIODev *v, u32int val) { int i; @@ -325,6 +336,7 @@ viodevstatset(VIODev *v, u32int val) qlock(&v->qu[i]); while(v->qu[i].livebuf > 0) rsleep(&v->qu[i].livebufrend); + vioqreset(&v->qu[i]); qunlock(&v->qu[i]); } }else{ @@ -396,6 +408,7 @@ mkvioqueue(VIODev *d, int sz, void (*fn)(VIOQueue*)) q->size = sz; q->d = d; q->notify = fn; + vioqreset(q); return q; } |