From: Steffen Dirkwinkel <[email protected]>

On the Beckhoff CB7268 (Cannon Point-LP PCH) and CB3067 (Q370 PCH)
boards with an I219-LM (8086:15b7), Tx sometimes hangs for good right
after boot: "Detected Hardware Unit Hang" with TDH 0 and TDT 1. This
was observed in the field and reproduced in CI, where about one in 140
cold boots hung.

e1000_reset_hw_ich8lan() sets CTRL.GIO_MASTER_DISABLE through
e1000e_disable_pcie_master() and relies on the global reset to clear
it. On these boards the MAC occasionally ignores the reset: 20 ms
later CTRL still holds its old value, GIO_MASTER_DISABLE included.
A debug kernel that resets the MAC in a loop lost up to 7% of back-to-back
resets and still some with 20 ms between them.

Check GIO_MASTER_DISABLE after the reset and issue the reset up to two more
times. In 122 lost resets the first retry always took.

Tested by power cycling affected devices: 13 of 1816 boots hung without
this change and 0 of 2830 with it, where 19 lost resets were retried.

Fixes: 79849ebc0e06 ("e1000e: initial support for i219")
Cc: [email protected]
Signed-off-by: Steffen Dirkwinkel <[email protected]>
---
 drivers/net/ethernet/intel/e1000e/ich8lan.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c 
b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index aa90e0ce8aca..4d4bc262ae85 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -4834,9 +4834,11 @@ static s32 e1000_get_bus_info_ich8lan(struct e1000_hw 
*hw)
 static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
 {
        struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
+       struct e1000_adapter *adapter = hw->adapter;
        u16 kum_cfg;
        u32 ctrl, reg;
        s32 ret_val;
+       int tries;
 
        /* Prevent the PCI-E bus from sticking if there is no TLP connection
         * on the last TLP read/write transaction when MAC is reset.
@@ -4895,10 +4897,27 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
                        e1000_gate_hw_phy_config_ich8lan(hw, true);
        }
        ret_val = e1000_acquire_swflag_ich8lan(hw);
-       e_dbg("Issuing a global reset to ich8lan\n");
-       ew32(CTRL, (ctrl | E1000_CTRL_RST));
-       /* cannot issue a flush here because it hangs the hardware */
-       msleep(20);
+       for (tries = 0; ; tries++) {
+               e_dbg("Issuing a global reset to ich8lan\n");
+               ew32(CTRL, (ctrl | E1000_CTRL_RST));
+               /* cannot issue a flush here because it hangs the hardware */
+               msleep(20);
+
+               /* Some I219 occasionally ignore the reset of the MAC, mostly
+                * right after a previous reset, and CTRL keeps its value.
+                * GIO_MASTER_DISABLE then stays set from
+                * e1000e_disable_pcie_master() above, so the MAC can't fetch
+                * descriptors and Tx hangs. Issue the reset again.
+                */
+               reg = er32(CTRL);
+               if (!(reg & E1000_CTRL_GIO_MASTER_DISABLE) || tries >= 2)
+                       break;
+               e_warn("Global reset not applied (CTRL 0x%08x), retrying\n",
+                      reg);
+       }
+       if (reg & E1000_CTRL_GIO_MASTER_DISABLE)
+               e_err("Global reset not applied after %d tries (CTRL 0x%08x)\n",
+                     tries + 1, reg);
 
        /* Set Phy Config Counter to 50msec */
        if (hw->mac.type == e1000_pch2lan) {

-- 
2.56.1

Reply via email to