Skip to contentSkip to conversation

e1000e: move force SMBUS near the end of enable_ulp function

PATCH Superseded Hui Wang 4 participants 7 messages May 8, 2024 – May 17, 2024

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hui Wang

author
#0 lore raw

PATCH v2 1/1 e1000e: move force SMBUS near the end of enable_ulp function

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the longest settling time as possible for interface in this function and doesn't change the original code logic.

Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")

---
In the v2:
Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero

 drivers/net/ethernet/intel/e1000e/ich8lan.c | 22 +++++++++++++++++++++
 drivers/net/ethernet/intel/e1000e/netdev.c  | 18 -----------------
 2 files changed, 22 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +22 -0
index f9e94be36e97..2e98a2a0bead 100644
@@ -1225,6 +1225,28 @@ s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
 	}
 
 release:
+	/* Switching PHY interface always returns MDI error
+	 * so disable retry mechanism to avoid wasting time
+	 */
+	e1000e_disable_phy_retry(hw);
+
+	/* Force SMBus mode in PHY */
+	ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
+	if (ret_val) {
+		e1000e_enable_phy_retry(hw);
+		hw->phy.ops.release(hw);
+		goto out;
+	}
+	phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
+	e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
+
+	e1000e_enable_phy_retry(hw);
+
+	/* Force SMBus mode in MAC */
+	mac_reg = er32(CTRL_EXT);
+	mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
+	ew32(CTRL_EXT, mac_reg);
+
 	hw->phy.ops.release(hw);
 out:
 	if (ret_val)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -18
index 3692fce20195..cc8c531ec3df 100644
@@ -6623,7 +6623,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 	struct e1000_hw *hw = &adapter->hw;
 	u32 ctrl, ctrl_ext, rctl, status, wufc;
 	int retval = 0;
-	u16 smb_ctrl;
 
 	/* Runtime suspend should only enable wakeup for link changes */
 	if (runtime)
@@ -6697,23 +6696,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 			if (retval)
 				return retval;
 		}
-
-		/* Force SMBUS to allow WOL */
-		/* Switching PHY interface always returns MDI error
-		 * so disable retry mechanism to avoid wasting time
-		 */
-		e1000e_disable_phy_retry(hw);
-
-		e1e_rphy(hw, CV_SMB_CTRL, &smb_ctrl);
-		smb_ctrl |= CV_SMB_CTRL_FORCE_SMBUS;
-		e1e_wphy(hw, CV_SMB_CTRL, smb_ctrl);
-
-		e1000e_enable_phy_retry(hw);
-
-		/* Force SMBus mode in MAC */
-		ctrl_ext = er32(CTRL_EXT);
-		ctrl_ext |= E1000_CTRL_EXT_FORCE_SMBUS;
-		ew32(CTRL_EXT, ctrl_ext);
 	}
 
 	/* Ensure that the appropriate bits are set in LPI_CTRL
Signature · 1 line
2.34.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 23 lines · Hui Wang

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the longest settling time as possible for interface in this function and doesn't change the original code logic.

Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")
Quoted 4 lines

---
In the v2:
Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero

#2 lore raw
In reply to Hui Wang
Quoted 18 lines · Hui Wang

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the longest settling time as possible for interface in this function and doesn't change the original code logic.

Quoted 6 lines
Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")

---

You didn't add a tag for which tree to target, typically for patches picked up through Intel Wired LAN, this would be "iwl-net" or "iwl-next". I presume since this is a fix that this should go to iwl-net and will apply it as appropriate.

Thanks,
Jake

Quoted 77 lines

In the v2:
Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero

 drivers/net/ethernet/intel/e1000e/ich8lan.c | 22 +++++++++++++++++++++
 drivers/net/ethernet/intel/e1000e/netdev.c  | 18 -----------------
 2 files changed, 22 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +22 -0
index f9e94be36e97..2e98a2a0bead 100644
@@ -1225,6 +1225,28 @@ s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
 	}
 
 release:
+	/* Switching PHY interface always returns MDI error
+	 * so disable retry mechanism to avoid wasting time
+	 */
+	e1000e_disable_phy_retry(hw);
+
+	/* Force SMBus mode in PHY */
+	ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
+	if (ret_val) {
+		e1000e_enable_phy_retry(hw);
+		hw->phy.ops.release(hw);
+		goto out;
+	}
+	phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
+	e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
+
+	e1000e_enable_phy_retry(hw);
+
+	/* Force SMBus mode in MAC */
+	mac_reg = er32(CTRL_EXT);
+	mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
+	ew32(CTRL_EXT, mac_reg);
+
 	hw->phy.ops.release(hw);
 out:
 	if (ret_val)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -18
index 3692fce20195..cc8c531ec3df 100644
@@ -6623,7 +6623,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 	struct e1000_hw *hw = &adapter->hw;
 	u32 ctrl, ctrl_ext, rctl, status, wufc;
 	int retval = 0;
-	u16 smb_ctrl;
 
 	/* Runtime suspend should only enable wakeup for link changes */
 	if (runtime)
@@ -6697,23 +6696,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 			if (retval)
 				return retval;
 		}
-
-		/* Force SMBUS to allow WOL */
-		/* Switching PHY interface always returns MDI error
-		 * so disable retry mechanism to avoid wasting time
-		 */
-		e1000e_disable_phy_retry(hw);
-
-		e1e_rphy(hw, CV_SMB_CTRL, &smb_ctrl);
-		smb_ctrl |= CV_SMB_CTRL_FORCE_SMBUS;
-		e1e_wphy(hw, CV_SMB_CTRL, smb_ctrl);
-
-		e1000e_enable_phy_retry(hw);
-
-		/* Force SMBus mode in MAC */
-		ctrl_ext = er32(CTRL_EXT);
-		ctrl_ext |= E1000_CTRL_EXT_FORCE_SMBUS;
-		ew32(CTRL_EXT, ctrl_ext);
 	}
 
 	/* Ensure that the appropriate bits are set in LPI_CTRL
#3 lore raw
In reply to Hui Wang

Dear Hui,

Thank you for your patch.

Am 08.05.24 um 14:06 schrieb Hui Wang:

Quoted 3 lines

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the

*P*CH

Quoted 3 lines

ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

1.  s/Link/link/
2.  “couldn’t work” means the reduced bandwidth?
3.  Please add a blank line and maybe indent the past with four spaces.
Quoted 9 lines
[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the

immediate*l*?

Quoted 2 lines

longest settling time as possible for interface in this function and doesn't change the original code logic.

Re-ordering code to achieve some waiting time sounds like, it’s not 100 % sure, that the problem won’t occur again?

Could you please document your test system?

Just a side note: Booting Linux 6.9-rc5+ *with kexec* on Supermicro Super Server/X13SAE, BIOS 2.0 10/17/2022 with the network device below, it also came up only with 10 Mbps and Ethernet did not work, for example ping. I conjectured though, that the non-working part was due to the switch configuration not allowing 10 Mbps.

00:1f.6 Ethernet controller [0200]: Intel Corporation Ethernet
Connection (17) I219-LM [8086:1a1c] (rev 11)

I didn’t find the time to further analyze and report the issue.

Also could this also be related to the regression reported by the kernel test robot [1]?

00:19.0 Ethernet controller: Intel Corporation Ethernet Connection
(3) I218-V (rev 03)

Quoted 73 lines
Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")

---
In the v2:
Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero

  drivers/net/ethernet/intel/e1000e/ich8lan.c | 22 +++++++++++++++++++++
  drivers/net/ethernet/intel/e1000e/netdev.c  | 18 -----------------
  2 files changed, 22 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +22 -0
index f9e94be36e97..2e98a2a0bead 100644
@@ -1225,6 +1225,28 @@ s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
  	}
 
  release:
+	/* Switching PHY interface always returns MDI error
+	 * so disable retry mechanism to avoid wasting time
+	 */
+	e1000e_disable_phy_retry(hw);
+
+	/* Force SMBus mode in PHY */
+	ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
+	if (ret_val) {
+		e1000e_enable_phy_retry(hw);
+		hw->phy.ops.release(hw);
+		goto out;
+	}
+	phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
+	e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
+
+	e1000e_enable_phy_retry(hw);
+
+	/* Force SMBus mode in MAC */
+	mac_reg = er32(CTRL_EXT);
+	mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
+	ew32(CTRL_EXT, mac_reg);
+
  	hw->phy.ops.release(hw);
  out:
  	if (ret_val)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -11
index 3692fce20195..cc8c531ec3df 100644
@@ -6623,7 +6623,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
  	struct e1000_hw *hw = &adapter->hw;
  	u32 ctrl, ctrl_ext, rctl, status, wufc;
  	int retval = 0;
-	u16 smb_ctrl;
 
  	/* Runtime suspend should only enable wakeup for link changes */
  	if (runtime)
@@ -6697,23 +6696,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
  			if (retval)
  				return retval;
  		}
-
-		/* Force SMBUS to allow WOL */
-		/* Switching PHY interface always returns MDI error
-		 * so disable retry mechanism to avoid wasting time
-		 */
-		e1000e_disable_phy_retry(hw);
-
-		e1e_rphy(hw, CV_SMB_CTRL, &smb_ctrl);
-		smb_ctrl |= CV_SMB_CTRL_FORCE_SMBUS;
-		e1e_wphy(hw, CV_SMB_CTRL, smb_ctrl);

drivers/net/ethernet/intel/e1000e/netdev.c static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) · line 6701

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/netdev.c +0 -7
-
-		e1000e_enable_phy_retry(hw);
-
-		/* Force SMBus mode in MAC */
-		ctrl_ext = er32(CTRL_EXT);
-		ctrl_ext |= E1000_CTRL_EXT_FORCE_SMBUS;
-		ew32(CTRL_EXT, ctrl_ext);
  	}
 
  	/* Ensure that the appropriate bits are set in LPI_CTRL

Kind regards,

Paul

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/

author
#4 lore raw
Quoted 10 lines · Paul Menzel

Dear Hui,

Thank you for your patch.

Am 08.05.24 um 14:06 schrieb Hui Wang:

Quoted 3 lines

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the

Quoted 8 lines

*P*CH

Quoted 3 lines

ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

1.  s/Link/link/
2.  “couldn’t work” means the reduced bandwidth?

On my side, once the link changes to 10Mbps, I couldn't ping the machine anymore. And as you said, it probably has sth to do with switch/router configuration.

Quoted 12 lines

3. Please add a blank line and maybe indent the past with four spaces.

Quoted 9 lines

[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the

Quoted 6 lines

immediate*l*?

Quoted 2 lines

longest settling time as possible for interface in this function and doesn't change the original code logic.

Re-ordering code to achieve some waiting time sounds like, it’s not 100 % sure, that the problem won’t occur again?

Actually this patch not only adds the waiting time, but also restore the original code logic:

 original: On a machine with the CSME, the SMBUS will not be forced, accordingly the SMBUS will not be unforced after resume.

 wrong: On a machine with the CSME, the SMBUS is forced, but the SMBUS is not unforced after resume, there is an unbalance. My patch could fix this case.

Quoted 2 lines

Could you please document your test system?

Lenovo Thinkpad P16Gen2 with ethernet card:

00:1f.6 Ethernet controller [0200]: Intel Corporation Device [8086:550a] (rev 20)

Quoted 5 lines

Just a side note: Booting Linux 6.9-rc5+ *with kexec* on Supermicro Super Server/X13SAE, BIOS 2.0 10/17/2022 with the network device below, it also came up only with 10 Mbps and Ethernet did not work, for example ping. I conjectured though, that the non-working part was due to the switch configuration not allowing 10 Mbps.

    00:1f.6 Ethernet controller [0200]: Intel Corporation Ethernet Connection (17) I219-LM [8086:1a1c] (rev 11)

My test and result are same as yours.

Thanks.

Quoted 98 lines

I didn’t find the time to further analyze and report the issue.

Also could this also be related to the regression reported by the kernel test robot [1]?

    00:19.0 Ethernet controller: Intel Corporation Ethernet Connection (3) I218-V (rev 03)

Quoted 73 lines
Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")

---
In the v2:
  Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero drivers/net/ethernet/intel/e1000e/ich8lan.c | 22
+++++++++++++++++++++
  drivers/net/ethernet/intel/e1000e/netdev.c  | 18 -----------------

  2 files changed, 22 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index f9e94be36e97..2e98a2a0bead 100644
@@ -1225,6 +1225,28 @@ s32 e1000_enable_ulp_lpt_lp(struct e1000_hw 
 *hw, bool to_sx)
       }

    release:
+    /* Switching PHY interface always returns MDI error +     * so disable retry mechanism to avoid wasting time +     */
+    e1000e_disable_phy_retry(hw);

drivers/net/ethernet/intel/e1000e/ich8lan.c +18 -0
+
+    /* Force SMBus mode in PHY */
+    ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
+    if (ret_val) {
+        e1000e_enable_phy_retry(hw);
+        hw->phy.ops.release(hw);
+        goto out;
+    }
+    phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
+    e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
+
+    e1000e_enable_phy_retry(hw);
+
+    /* Force SMBus mode in MAC */
+    mac_reg = er32(CTRL_EXT);
+    mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
+    ew32(CTRL_EXT, mac_reg);
+

      hw->phy.ops.release(hw);
  out:
      if (ret_val)

drivers/net/ethernet/intel/e1000e/netdev.c +0 -10
index 3692fce20195..cc8c531ec3df 100644
@@ -6623,7 +6623,6 @@ static int __e1000_shutdown(struct pci_dev 
 *pdev, bool runtime)
       struct e1000_hw *hw = &adapter->hw;
       u32 ctrl, ctrl_ext, rctl, status, wufc;
       int retval = 0;
-    u16 smb_ctrl;
         /* Runtime suspend should only enable wakeup for link changes */
       if (runtime)
@@ -6697,23 +6696,6 @@ static int __e1000_shutdown(struct pci_dev 
 *pdev, bool runtime)
               if (retval)
                   return retval;
           }
-
-        /* Force SMBUS to allow WOL */
-        /* Switching PHY interface always returns MDI error
-         * so disable retry mechanism to avoid wasting time
-         */
-        e1000e_disable_phy_retry(hw);
-
-        e1e_rphy(hw, CV_SMB_CTRL, &smb_ctrl);
-        smb_ctrl |= CV_SMB_CTRL_FORCE_SMBUS;

drivers/net/ethernet/intel/e1000e/netdev.c static int __e1000_shutdown(struct pci_dev · line 6701

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/netdev.c +0 -8
-        e1e_wphy(hw, CV_SMB_CTRL, smb_ctrl);
-
-        e1000e_enable_phy_retry(hw);
-
-        /* Force SMBus mode in MAC */
-        ctrl_ext = er32(CTRL_EXT);
-        ctrl_ext |= E1000_CTRL_EXT_FORCE_SMBUS;
-        ew32(CTRL_EXT, ctrl_ext);
       }
         /* Ensure that the appropriate bits are set in LPI_CTRL

Kind regards,

Paul

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/

#5 lore raw

Dear Hui,

Thank you for your response.

Am 17.05.24 um 11:45 schrieb Hui Wang:

Quoted 10 lines · Paul Menzel
Quoted 8 lines

Am 08.05.24 um 14:06 schrieb Hui Wang:

Quoted 3 lines

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the

*P*CH

Quoted 22 lines
Quoted 6 lines
Quoted 3 lines

ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

1.  s/Link/link/
2.  “couldn’t work” means the reduced bandwidth?

On my side, once the link changes to 10Mbps, I couldn't ping the machine anymore. And as you said, it probably has sth to do with switch/router configuration.

Quoted 13 lines

3. Please add a blank line and maybe indent the past with four spaces.

Quoted 9 lines

[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the

immediate*l*?

Sorry, I meant immediate*ly*.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

longest settling time as possible for interface in this function and doesn't change the original code logic.

Re-ordering code to achieve some waiting time sounds like, it’s not 100 % sure, that the problem won’t occur again?

Quoted 7 lines

Actually this patch not only adds the waiting time, but also restore the original code logic:

 original: On a machine with the CSME, the SMBUS will not be forced,
accordingly the SMBUS will not be unforced after resume.

 wrong: On a machine with the CSME, the SMBUS is forced, but the SMBUS
is not unforced after resume, there is an unbalance. My patch could fix this case.

Thank you for elaborating. In my opinion, then two commits would be better. One revert with a description of the problem and documentation of the test systems. Then the second patch with the fix.

Quoted 5 lines
Quoted 1 line

Could you please document your test system?

Lenovo Thinkpad P16Gen2 with ethernet card:

00:1f.6 Ethernet controller [0200]: Intel Corporation Device [8086:550a] (rev 20)

Quoted 7 lines
Quoted 4 lines

Just a side note: Booting Linux 6.9-rc5+ *with kexec* on Supermicro Super Server/X13SAE, BIOS 2.0 10/17/2022 with the network device below, it also came up only with 10 Mbps and Ethernet did not work, for example ping. I conjectured though, that the non-working part was due to the switch configuration not allowing 10 Mbps.

    00:1f.6 Ethernet controller [0200]: Intel Corporation Ethernet Connection (17) I219-LM [8086:1a1c] (rev 11)

My test and result are same as yours.

Thanks.

Thank you for the confirmation.

Quoted 80 lines
Quoted 80 lines

I didn’t find the time to further analyze and report the issue.

Also could this also be related to the regression reported by the kernel test robot [1]?

    00:19.0 Ethernet controller: Intel Corporation Ethernet Connection (3) I218-V (rev 03)

Quoted 74 lines
Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")

---
In the v2:
  Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero drivers/net/ethernet/intel/e1000e/ich8lan.c | 22 +++++++++++++++++++++ drivers/net/ethernet/intel/e1000e/netdev.c  | 18 -----------------

  2 files changed, 22 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index f9e94be36e97..2e98a2a0bead 100644
@@ -1225,6 +1225,28 @@ s32 e1000_enable_ulp_lpt_lp(struct e1000_hw 
 *hw, bool to_sx)
       }

    release:
+    /* Switching PHY interface always returns MDI error +     * so disable retry mechanism to avoid wasting time +     */
+    e1000e_disable_phy_retry(hw);

drivers/net/ethernet/intel/e1000e/ich8lan.c +18 -0
+
+    /* Force SMBus mode in PHY */
+    ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
+    if (ret_val) {
+        e1000e_enable_phy_retry(hw);
+        hw->phy.ops.release(hw);
+        goto out;
+    }
+    phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
+    e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
+
+    e1000e_enable_phy_retry(hw);
+
+    /* Force SMBus mode in MAC */
+    mac_reg = er32(CTRL_EXT);
+    mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
+    ew32(CTRL_EXT, mac_reg);
+

      hw->phy.ops.release(hw);
  out:
      if (ret_val)

drivers/net/ethernet/intel/e1000e/netdev.c +0 -12
index 3692fce20195..cc8c531ec3df 100644
@@ -6623,7 +6623,6 @@ static int __e1000_shutdown(struct pci_dev 
 *pdev, bool runtime)
       struct e1000_hw *hw = &adapter->hw;
       u32 ctrl, ctrl_ext, rctl, status, wufc;
       int retval = 0;
-    u16 smb_ctrl;
         /* Runtime suspend should only enable wakeup for link changes */
       if (runtime)
@@ -6697,23 +6696,6 @@ static int __e1000_shutdown(struct pci_dev 
 *pdev, bool runtime)
               if (retval)
                   return retval;
           }
-
-        /* Force SMBUS to allow WOL */
-        /* Switching PHY interface always returns MDI error
-         * so disable retry mechanism to avoid wasting time
-         */
-        e1000e_disable_phy_retry(hw);
-
-        e1e_rphy(hw, CV_SMB_CTRL, &smb_ctrl);
-        smb_ctrl |= CV_SMB_CTRL_FORCE_SMBUS;
-        e1e_wphy(hw, CV_SMB_CTRL, smb_ctrl);
-
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/e1000e/netdev.c static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) · line 6701

Quoted 8 lines
drivers/net/ethernet/intel/e1000e/netdev.c +0 -6
-        e1000e_enable_phy_retry(hw);
-
-        /* Force SMBus mode in MAC */
-        ctrl_ext = er32(CTRL_EXT);
-        ctrl_ext |= E1000_CTRL_EXT_FORCE_SMBUS;
-        ew32(CTRL_EXT, ctrl_ext);
       }
         /* Ensure that the appropriate bits are set in LPI_CTRL

Kind regards,

Paul

Quoted 1 line
Quoted 1 line

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/

author
#6 lore raw
Quoted 35 lines · Paul Menzel

Dear Hui,

Thank you for your response.

Am 17.05.24 um 11:45 schrieb Hui Wang:

Quoted 28 lines · Paul Menzel
Quoted 6 lines

Am 08.05.24 um 14:06 schrieb Hui Wang:

Quoted 3 lines

The commit 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue") introduces a regression on CH_MTP_I219_LM18 (PCIID: 0x8086550A). Without the referred commit, the

Quoted 8 lines

*P*CH

Quoted 3 lines

ethernet works well after suspend and resume, but after applying the commit, the ethernet couldn't work anymore after the resume and the dmesg shows that the NIC Link changes to 10Mbps (1000Mbps originally):

1.  s/Link/link/
2.  “couldn’t work” means the reduced bandwidth?

On my side, once the link changes to 10Mbps, I couldn't ping the machine anymore. And as you said, it probably has sth to do with switch/router configuration.

Quoted 9 lines

3. Please add a blank line and maybe indent the past with four spaces.

Quoted 7 lines

[   43.305084] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 10 Mbps Full Duplex, Flow Control: Rx/Tx

Without the commit, the force SMBUS code will not be executed if "return 0" or "goto out" is executed in the enable_ulp(), and in my case, the "goto out" is executed since FWSM_FW_VALID is set. But after applying the commit, the force SMBUS code will be ran unconditionally.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Here move the force SMBUS code back to enable_ulp() and put it immediate ahead of hw->phy.ops.release(hw), this could allow the

immediate*l*?

Sorry, I meant immediate*ly*.

Got it.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

longest settling time as possible for interface in this function and doesn't change the original code logic.

Re-ordering code to achieve some waiting time sounds like, it’s not 100 % sure, that the problem won’t occur again?

Quoted 7 lines
Quoted 5 lines

Actually this patch not only adds the waiting time, but also restore the original code logic:

  original: On a machine with the CSME, the SMBUS will not be forced, accordingly the SMBUS will not be unforced after resume.

  wrong: On a machine with the CSME, the SMBUS is forced, but the SMBUS is not unforced after resume, there is an unbalance. My patch could fix this case.

Thank you for elaborating. In my opinion, then two commits would be better. One revert with a description of the problem and documentation of the test systems. Then the second patch with the fix.

What you said makes sense. But for this particular case, I think it is not necessary since the patch is not that complicated and explanation is already in the commit header.

Anyway, I will address the rest comment of you and send a v3 patch.

Thanks,

Hui.

Quoted 114 lines
Quoted 6 lines
Quoted 2 lines

Could you please document your test system?

Lenovo Thinkpad P16Gen2 with ethernet card:

00:1f.6 Ethernet controller [0200]: Intel Corporation Device [8086:550a] (rev 20)

Quoted 7 lines
Quoted 4 lines

Just a side note: Booting Linux 6.9-rc5+ *with kexec* on Supermicro Super Server/X13SAE, BIOS 2.0 10/17/2022 with the network device below, it also came up only with 10 Mbps and Ethernet did not work, for example ping. I conjectured though, that the non-working part was due to the switch configuration not allowing 10 Mbps.

    00:1f.6 Ethernet controller [0200]: Intel Corporation Ethernet Connection (17) I219-LM [8086:1a1c] (rev 11)

My test and result are same as yours.

Thanks.

Thank you for the confirmation.

Quoted 82 lines
Quoted 82 lines

I didn’t find the time to further analyze and report the issue.

Also could this also be related to the regression reported by the kernel test robot [1]?

    00:19.0 Ethernet controller: Intel Corporation Ethernet Connection (3) I218-V (rev 03)

Quoted 76 lines
Fixes 861e8086029e ("e1000e: move force SMBUS from enable ulp function to avoid PHY loss issue")

---
In the v2:
  Change "this commit" to "the referred commit" in the commit header Fix a potential infinite loop if ret_val is not zero drivers/net/ethernet/intel/e1000e/ich8lan.c | 22
+++++++++++++++++++++
  drivers/net/ethernet/intel/e1000e/netdev.c  | 18 -----------------

  2 files changed, 22 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index f9e94be36e97..2e98a2a0bead 100644
@@ -1225,6 +1225,28 @@ s32 e1000_enable_ulp_lpt_lp(struct e1000_hw 
 *hw, bool to_sx)
       }

    release:
+    /* Switching PHY interface always returns MDI error +     * so disable retry mechanism to avoid wasting time +     */
+    e1000e_disable_phy_retry(hw);
+
+    /* Force SMBus mode in PHY */
+    ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
+    if (ret_val) {
+        e1000e_enable_phy_retry(hw);
+        hw->phy.ops.release(hw);
+        goto out;
+    }
+    phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
+    e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);

drivers/net/ethernet/intel/e1000e/ich8lan.c +8 -0
+
+    e1000e_enable_phy_retry(hw);
+
+    /* Force SMBus mode in MAC */
+    mac_reg = er32(CTRL_EXT);
+    mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
+    ew32(CTRL_EXT, mac_reg);
+

      hw->phy.ops.release(hw);
  out:
      if (ret_val)

drivers/net/ethernet/intel/e1000e/netdev.c +0 -12
index 3692fce20195..cc8c531ec3df 100644
@@ -6623,7 +6623,6 @@ static int __e1000_shutdown(struct pci_dev 
 *pdev, bool runtime)
       struct e1000_hw *hw = &adapter->hw;
       u32 ctrl, ctrl_ext, rctl, status, wufc;
       int retval = 0;
-    u16 smb_ctrl;
         /* Runtime suspend should only enable wakeup for link changes */
       if (runtime)
@@ -6697,23 +6696,6 @@ static int __e1000_shutdown(struct pci_dev 
 *pdev, bool runtime)
               if (retval)
                   return retval;
           }
-
-        /* Force SMBUS to allow WOL */
-        /* Switching PHY interface always returns MDI error
-         * so disable retry mechanism to avoid wasting time
-         */
-        e1000e_disable_phy_retry(hw);
-
-        e1e_rphy(hw, CV_SMB_CTRL, &smb_ctrl);
-        smb_ctrl |= CV_SMB_CTRL_FORCE_SMBUS;
-        e1e_wphy(hw, CV_SMB_CTRL, smb_ctrl);
-
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/e1000e/netdev.c static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) · line 6701

Quoted 8 lines
drivers/net/ethernet/intel/e1000e/netdev.c +0 -6
-        e1000e_enable_phy_retry(hw);
-
-        /* Force SMBus mode in MAC */
-        ctrl_ext = er32(CTRL_EXT);
-        ctrl_ext |= E1000_CTRL_EXT_FORCE_SMBUS;
-        ew32(CTRL_EXT, ctrl_ext);
       }
         /* Ensure that the appropriate bits are set in LPI_CTRL

Kind regards,

Paul

Quoted 1 line
Quoted 1 line

[1]: https://lore.kernel.org/intel-wired-lan/[email protected]/