فهرست منبع

Skip the PCH MAC reset while the link is up

The 82577LM/ME wedges on the CTRL_RST access after GIO_MASTER_DISABLE
when the cable is connected, leaving the WM partially drawn.  Sample the
link before hw_stop() and, when it is up, keep the firmware's MAC/PHY
state: hw_stop() stops RX/TX and hw_start() reprograms the queues.  The
link-down path keeps the full reset.

Add short settle delays around the PCH D0/MAC transitions as well.
Confirmed on the X201 with and without the cable.
Johannes Zellner 2 هفته پیش
والد
کامیت
ae8b6122a3
2فایلهای تغییر یافته به همراه31 افزوده شده و 3 حذف شده
  1. 3 1
      AGENTS.md
  2. 28 2
      e1000e.c

+ 3 - 1
AGENTS.md

@@ -356,7 +356,9 @@ run area), so adding code no longer moves any address.
 - **Network**: `netdev.c/h` — NIC driver registry (`struct netdev`, first probe
   wins; drivers: `e1000e.c` Intel e1000/PCH LAN (82540EM emulated,
   82577LM/82578/82579; polled, PCI INTx disabled before MMIO, PCH D0 and
-  no BAR sizing so the ME/AMT cannot leave the BAR undecoded), `r8168.c`
+  no BAR sizing so the ME/AMT cannot leave the BAR undecoded; skips the
+  global MAC reset while the link is up, because the PCH/ME wedges on the
+  CTRL_RST access), `r8168.c`
   RTL8111/8168 (PCIe, polled, C+ mode, 64-entry RX ring) and `ne2000.c`
   RTL8029 (QEMU/ISA)). `net.c` — ARP + ICMP echo, IPv4/UDP send + parse helpers,
   shared ARP resolution (`net_arp_resolve`) and routing (`net_next_hop`), frame

+ 28 - 2
e1000e.c

@@ -400,6 +400,10 @@ static int probe_pci(void)
 						cmd | 0x0006u |
 						PCI_CMD_INT_DISABLE);
 				pci_set_d0(bus, dev, func);
+				/* Let the function settle after D0/memory enable;
+				 * the ME can still be finishing its link work when
+				 * the cable is present. */
+				delay_ms(10);
 
 				if (probe_bar0(bus, dev, func,
 					       &bar_base, &bar_size) != 0)
@@ -558,6 +562,9 @@ static void phy_autoneg(void)
  * let any in-flight DMA finish.  This is the "reset" path on PCH LAN parts. */
 static void hw_stop(void)
 {
+	/* PCH LAN: let the ME finish the current link transaction before the
+	 * first MAC write. */
+	delay_ms(5);
 	w32(REG_IMC, 0xFFFFFFFFu);
 	(void)r32(REG_ICR);
 	w32(REG_RCTL, 0);
@@ -570,8 +577,8 @@ static void hw_stop(void)
  * the network interface, otherwise it can keep the LAN - notably the TX
  * path - to itself.  e1000e's e1000e_get_hw_control() sets
  * CTRL_EXT.DRV_LOAD for parts with FLAG_HAS_CTRLEXT_ON_LOAD (the pch_info
- * used by the 82577LM/82578/82579).  Do it right after the MAC reset, before
- * the rings are programmed, exactly where e1000e calls it. */
+ * used by the 82577LM/82578/82579).  Do it after the reset/quiesce path and
+ * before the rings are programmed, exactly where e1000e calls it. */
 static void pch_claim(void)
 {
 	unsigned int ctrl_ext;
@@ -598,8 +605,20 @@ static void pch_claim(void)
 static int hw_reset(void)
 {
 	unsigned int t0, ctrl;
+	/* Sample the link before hw_stop(): the PHY link is independent of
+	 * the MAC RX/TX state. */
+	int link_up = pch_lan && (r32(REG_STATUS) & STATUS_LU);
 
 	hw_stop();
+	if (link_up) {
+		/* Do not issue CTRL_RST while the ME has the link up: on the
+		 * X201 the CTRL access after GIO_MASTER_DISABLE wedges.  The
+		 * firmware already brought the MAC/PHY up; hw_stop() stopped
+		 * RX/TX and hw_start() reprograms the queues below. */
+		dbg("MAC reset skipped (link up)");
+		return 0;
+	}
+	delay_ms(5);
 
 	/* Block new DMA requests and wait for the last TLP to finish before
 	 * hitting the MAC with a global reset (same order as e1000e). */
@@ -609,6 +628,7 @@ static int hw_reset(void)
 	while ((r32(REG_STATUS) & STATUS_GIO_MASTER_ENABLE) &&
 	       !timed_out(t0, 1000))
 		;
+	delay_ms(5);
 
 	w32(REG_CTRL, r32(REG_CTRL) | CTRL_RST);
 	t0 = get_ticks_ms();
@@ -770,6 +790,11 @@ static int e1000e_init(void)
 	}
 	dbg(buf);
 
+	/* The PCH LAN/ME needs a moment after the config-space setup before
+	 * the first MAC register access; without it the probe can wedge when
+	 * the link is up. */
+	delay_ms(10);
+
 	/* MAC-only reset: CTRL.PHY_RST is deliberately never set, so the
 	 * firmware's PHY/Kumeran setup (and the link) survives, while the MAC
 	 * registers - including whatever TX queue state the BIOS UNDI left
@@ -824,6 +849,7 @@ static int e1000e_init(void)
 	if (pch_lan && phy_addr < 0)
 		phy_addr = 1;
 	hw_start();
+	delay_ms(10);
 
 	{
 		unsigned int st = r32(REG_STATUS);