ref: a32d11dff358f60d6184fe8c9a0521cf878c6a4f
parent: 55373a649820a952ca26f5f315a8a2c60997a480
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Feb 20 17:01:54 EST 2017
ether82563: work arround phyprobe() failing on 82579LM without cable plugged in (thanks mischief) on 82579LM, the phy status is inaccessible without a cable plugged, so we wait and retry phyprobe() once the link status changes.
--- a/sys/src/9/pc/ether82563.c
+++ b/sys/src/9/pc/ether82563.c
@@ -1180,6 +1180,15 @@
}
static void
+lsleep(Ctlr *c, uint m)
+{
+ c->lim = 0;
+ i82563im(c, m);
+ c->lsleep++;
+ sleep(&c->lrendez, i82563lim, c);
+}
+
+static void
phyl79proc(void *v)
{
uint a, i, r, phy, phyno;
@@ -1188,15 +1197,12 @@
e = v;
c = e->ctlr;
-
- phyno = phyprobe(c, 3<<1);
- if(phyno == ~0){
- print("%s: no phy, exiting\n", up->text);
- pexit("no phy", 1);
- }
-
while(waserror())
;
+
+ while((phyno = phyprobe(c, 3<<1)) == ~0)
+ lsleep(c, Lsc);
+
for(;;){
phy = phyread(c, phyno, Phystat);
if(phy == ~0){
@@ -1216,10 +1222,7 @@
i = 3;
c->speeds[i]++;
e->mbps = speedtab[i];
- c->lim = 0;
- i82563im(c, Lsc);
- c->lsleep++;
- sleep(&c->lrendez, i82563lim, c);
+ lsleep(c, Lsc);
}
}
@@ -1232,18 +1235,15 @@
e = v;
c = e->ctlr;
+ while(waserror())
+ ;
- phyno = phyprobe(c, 3<<1);
- if(phyno == ~0){
- print("%s: no phy, exiting\n", up->text);
- pexit("no phy", 1);
- }
+ while((phyno = phyprobe(c, 3<<1)) == ~0)
+ lsleep(c, Lsc);
if(c->type == i82573 && (phy = phyread(c, phyno, Phyier)) != ~0)
phywrite(c, phyno, Phyier, phy | Lscie | Ancie | Spdie | Panie);
- while(waserror())
- ;
for(;;){
phy = phyread(c, phyno, Physsr);
if(phy == ~0){
@@ -1280,10 +1280,7 @@
e->mbps = speedtab[i];
if(c->type == i82563)
phyerrata(e, c, phyno);
- c->lim = 0;
- i82563im(c, Lsc);
- c->lsleep++;
- sleep(&c->lrendez, i82563lim, c);
+ lsleep(c, Lsc);
}
}
@@ -1296,11 +1293,11 @@
e = v;
c = e->ctlr;
+ while(waserror())
+ ;
if(c->type == i82575 || c->type == i82576)
csr32w(c, Connsw, Enrgirq);
- while(waserror())
- ;
for(;;){
phy = csr32r(c, Pcsstat);
e->link = phy & Linkok;
@@ -1311,10 +1308,7 @@
csr32w(c, Pcsctl, csr32r(c, Pcsctl) | Pan | Prestart);
c->speeds[i]++;
e->mbps = speedtab[i];
- c->lim = 0;
- i82563im(c, Lsc | Omed);
- c->lsleep++;
- sleep(&c->lrendez, i82563lim, c);
+ lsleep(c, Lsc | Omed);
}
}
@@ -1327,7 +1321,6 @@
e = v;
c = e->ctlr;
-
while(waserror())
;
for(;;){
@@ -1341,10 +1334,7 @@
i = 2;
c->speeds[i]++;
e->mbps = speedtab[i];
- c->lim = 0;
- i82563im(c, Lsc);
- c->lsleep++;
- sleep(&c->lrendez, i82563lim, c);
+ lsleep(c, Lsc);
}
}