Skip to contentSkip to conversation

e1000e: PCIm function state support

PATCH New Vitaly Lifshits 2 participants 2 messages Aug 7, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 e1000e: PCIm function state support

Due to commit: 5d8682588605 ("[misc] mei: me: allow runtime pm for platform with D0i3"), when the cable is disconnect and reconnected, the NIC can enter a DMoff state. The DMoff state will cause incorrect link indication and duplex setting mismatch.

To resolve this, we need to check the PCIm function state and perform a PHY reset after exiting the DMoff state in our watchdog service task.

Fixes 5d8682588605 ("[misc] mei: me: allow runtime pm for platform with D0i3")

---

V2: Fix typos in commit message
V3: Fix minor typo
V4: Address community comments
V5: Address community comments

---
 drivers/net/ethernet/intel/e1000e/defines.h |  4 ++++
 drivers/net/ethernet/intel/e1000e/netdev.c  | 20 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/defines.h +4 -0
index fd550dee4982..11452eaac233 100644
@@ -222,6 +222,10 @@
 #define E1000_STATUS_PHYRA      0x00000400      /* PHY Reset Asserted */
 #define E1000_STATUS_GIO_MASTER_ENABLE	0x00080000	/* Master Req status */
 
+/* PCIm function state */
+#define E1000_STATUS_PCIM_STATE	0x40000000
+#define PCIM_DMOFF_EXIT_TIMEOUT	100
+
 #define HALF_DUPLEX 1
 #define FULL_DUPLEX 2
 
drivers/net/ethernet/intel/e1000e/netdev.c +19 -1
index b5fed6177ad6..639266485c15 100644
@@ -5162,7 +5162,7 @@ static void e1000_watchdog_task(struct work_struct *work)
 	struct e1000_phy_info *phy = &adapter->hw.phy;
 	struct e1000_ring *tx_ring = adapter->tx_ring;
 	struct e1000_hw *hw = &adapter->hw;
-	u32 link, tctl;
+	u32 link, tctl, pcim_state, tries = 0;
 
 	if (test_bit(__E1000_DOWN, &adapter->state))
 		return;
@@ -5187,6 +5187,24 @@ static void e1000_watchdog_task(struct work_struct *work)
 			/* Cancel scheduled suspend requests. */
 			pm_runtime_resume(netdev->dev.parent);
 
+			/* Check if MAC is in DMoff state */
+			pcim_state = er32(STATUS);
+			while (pcim_state & E1000_STATUS_PCIM_STATE) {
+				if (tries++ == PCIM_DMOFF_EXIT_TIMEOUT) {
+					e_dbg("Error in exiting dmoff\n");
+					e_err("PCIm DMoff timeout expired\n");
+					break;
+				}
+				usleep_range(10000, 20000);
+				pcim_state = er32(STATUS);
+
+				/* If MAC entered DMoff state, PHY reset is
+				 * needed after exiting it
+				 */
+				if (!(pcim_state & E1000_STATUS_PCIM_STATE))
+					e1000_phy_hw_reset(&adapter->hw);
+			}
+
 			/* update snapshot of PHY registers on LSC */
 			e1000_phy_read_status(adapter);
 			mac->ops.get_link_up_info(&adapter->hw,
Signature · 1 line
2.11.0
#1 lore raw

PATCH v5 1/1 e1000e: PCIm function state support

Quoted 66 lines · Vitaly Lifshits

Due to commit: 5d8682588605 ("[misc] mei: me: allow runtime pm for platform with D0i3"), when the cable is disconnect and reconnected, the NIC can enter a DMoff state. The DMoff state will cause incorrect link indication and duplex setting mismatch.

To resolve this, we need to check the PCIm function state and perform a PHY reset after exiting the DMoff state in our watchdog service task.

Fixes 5d8682588605 ("[misc] mei: me: allow runtime pm for platform with D0i3")

---

V2: Fix typos in commit message
V3: Fix minor typo
V4: Address community comments
V5: Address community comments

---
  drivers/net/ethernet/intel/e1000e/defines.h |  4 ++++
  drivers/net/ethernet/intel/e1000e/netdev.c  | 20 +++++++++++++++++++-
  2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/defines.h +4 -0
index fd550dee4982..11452eaac233 100644
@@ -222,6 +222,10 @@
  #define E1000_STATUS_PHYRA      0x00000400      /* PHY Reset Asserted */
  #define E1000_STATUS_GIO_MASTER_ENABLE	0x00080000	/* Master Req status */
 
+/* PCIm function state */
+#define E1000_STATUS_PCIM_STATE	0x40000000
+#define PCIM_DMOFF_EXIT_TIMEOUT	100
+
  #define HALF_DUPLEX 1
  #define FULL_DUPLEX 2
 
drivers/net/ethernet/intel/e1000e/netdev.c +12 -1
index b5fed6177ad6..639266485c15 100644
@@ -5162,7 +5162,7 @@ static void e1000_watchdog_task(struct work_struct *work)
  	struct e1000_phy_info *phy = &adapter->hw.phy;
  	struct e1000_ring *tx_ring = adapter->tx_ring;
  	struct e1000_hw *hw = &adapter->hw;
-	u32 link, tctl;
+	u32 link, tctl, pcim_state, tries = 0;
 
  	if (test_bit(__E1000_DOWN, &adapter->state))
  		return;
@@ -5187,6 +5187,24 @@ static void e1000_watchdog_task(struct work_struct *work)
  			/* Cancel scheduled suspend requests. */
  			pm_runtime_resume(netdev->dev.parent);
 
+			/* Check if MAC is in DMoff state */
+			pcim_state = er32(STATUS);
+			while (pcim_state & E1000_STATUS_PCIM_STATE) {
+				if (tries++ == PCIM_DMOFF_EXIT_TIMEOUT) {
+					e_dbg("Error in exiting dmoff\n");
+					e_err("PCIm DMoff timeout expired\n");
+					break;
+				}
+				usleep_range(10000, 20000);
+				pcim_state = er32(STATUS);
+

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000_watchdog_task(struct work_struct *work) · line 5210

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
+				/* If MAC entered DMoff state, PHY reset is
+				 * needed after exiting it
+				 */
+				if (!(pcim_state & E1000_STATUS_PCIM_STATE))
+					e1000_phy_hw_reset(&adapter->hw);
+			}
+
  			/* update snapshot of PHY registers on LSC */
  			e1000_phy_read_status(adapter);
  			mac->ops.get_link_up_info(&adapter->hw,