git: 9front

Download patch

ref: c725122a471acff0f24b9bb337a9e80e662a4b8b
parent: 62612f92fb7cc773c41096d50e02abaf2b22a37e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Mar 15 14:07:04 EDT 2026

ether82563: fix "phy wedged" for i219, inhibit transmission until link-up (thanks hiro)

Empirically, i219 gets stuck in transmission when we
enqueue packets before the phy signals link-up and
even a full device reset does not recover from that.

Devether inhibits transmission when link is down,
so we set it down by calling ethersetlink(edev, 0)
to avoid the issue.

Also, it appears theres a 1.5s delay required after
the mac signals Link-Up status before touching the
phy registers.

--- a/sys/src/9/pc/ether82563.c
+++ b/sys/src/9/pc/ether82563.c
@@ -1245,6 +1245,11 @@
 	while(waserror())
 		procerror(c, &c->lproc);
 
+	/* wait 1.5s after first link up to avoid wedged phy */
+	while((csr32r(c, Status) & Lu) == 0)
+		lsleep(c, Lsc);
+	tsleep(&up->sleep, return0, 0, 1500);
+
 	while((phyno = phyprobe(c, 3<<1)) == ~0)
 		lsleep(c, Lsc);
 
@@ -1496,6 +1501,9 @@
 	r = csr32r(ctlr, Ctrl);
 	r &= ~(Frcspd|Frcdplx);	/* dont force */
 	csr32w(ctlr, Ctrl, Slu|r);
+
+	/* link is down until linkproc sets it up */
+	ethersetlink(edev, 0);
 
 	snprint(name, sizeof name, "#l%dl", edev->ctlrno);
 	if(csr32r(ctlr, Status) & Tbimode)
--