shithub: plan9front

Download patch

ref: e8259861da3a55c03491904e4d11c5c15b7577c5
parent: ad37339a1c39c90f51d273abe60f552d3900f752
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jul 11 17:49:15 EDT 2021

virtio: set FeaturesOk flag after feature negotiation, and enable queues before DriverOk flag

--- a/sys/src/9/pc/ethervirtio10.c	Sun Jul 11 08:12:51 2021
+++ b/sys/src/9/pc/ethervirtio10.c	Sun Jul 11 17:49:15 2021
@@ -40,7 +40,7 @@
 	Sacknowledge = 1,
 	Sdriver = 2,
 	Sdriverok = 4,
-	Sfeatureok = 8,
+	Sfeaturesok = 8,
 	Sfailed = 128,
 
 	/* flags in Qnetstatus */
@@ -466,14 +466,15 @@
 	}
 	ctlr->attached = 1;
 
-	/* driver is ready */
-	ctlr->cfg->status |= Sdriverok;
-
 	/* enable the queues */
 	for(i = 0; i < ctlr->nqueue; i++){
 		ctlr->cfg->queuesel = i;
 		ctlr->cfg->queueenable = 1;
 	}
+
+	/* driver is ready */
+	ctlr->cfg->status |= Sdriverok;
+
 	iunlock(ctlr);
 
 	/* start kprocs */
@@ -691,6 +692,8 @@
 
 		cfg->drvfeatsel = 0;
 		cfg->drvfeat = c->feat[0] & (Fmac|Fctrlvq|Fctrlrx);
+
+		cfg->status |= Sfeaturesok;
 
 		for(i=0; i<nelem(c->queue); i++){
 			cfg->queuesel = i;
--- a/sys/src/9/pc/sdvirtio10.c	Sun Jul 11 08:12:51 2021
+++ b/sys/src/9/pc/sdvirtio10.c	Sun Jul 11 17:49:15 2021
@@ -46,6 +46,7 @@
 enum {
 	Acknowledge = 1,
 	Driver = 2,
+	FeaturesOk = 8,
 	DriverOk = 4,
 	Failed = 0x80,
 };
@@ -335,6 +336,7 @@
 		cfg->drvfeat = vd->feat[1] & 1;
 		cfg->drvfeatsel = 0;
 		cfg->drvfeat = 0;
+		cfg->status |= FeaturesOk;
 
 		for(i=0; i<nelem(vd->queue); i++){
 			cfg->queuesel = i;
@@ -698,11 +700,11 @@
 	intrenable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
 	coherence();
 
-	vd->cfg->status |= DriverOk;
 	for(i = 0; i < vd->nqueue; i++){
 		vd->cfg->queuesel = i;
 		vd->cfg->queueenable = 1;
 	}
+	vd->cfg->status |= DriverOk;
 
 	return 1;
 }