e1000e: fix nic not boot after rebooting
Subsystems (2)
v2 cover e1000e: fix nic not boot after rebooting
With kernel 2.6.x, e1000e with 82577/8/9 sometimes will not boot after rebooting.
If a kernel 2.6.x board with 82577/8/9 e1000e nic is rebooted for 100 times, there are 7~8 times that 82577/8/9 e1000e nic will not boot normally.
V2:
Follow the advice from Willy, the wrong upstream commit IDs in these 5 patches commit messages are fixed.
Zhu Yanjun (5):
e1000e: reset MAC-PHY interconnect on 82577/82578
e1000e: workaround EEPROM configuration change on 82579 on kernel
2.6.x
e1000e: do not toggle LANPHYPC value bit when PHY reset is blocked
e1000e: update workaround for 82579 intermittently disabled during
S0->Sx e1000e: cleanup use of check_reset_block function pointer
drivers/net/e1000e/defines.h | 2 ++ drivers/net/e1000e/hw.h | 1 + drivers/net/e1000e/ich8lan.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+)
Signature · 1 line
1.9.1
PATCH v2 1/5 e1000e: reset MAC-PHY interconnect on 82577/82578
2.6.x kernels require a similar logic change as commit 6dfaa76 [e1000e: reset MAC-PHY interconnect on 82577/82578] introduces for newer kernels.
During Sx->S0 transitions, the interconnect between the MAC and PHY on 82577/82578 can remain in SMBus mode instead of transitioning to the PCIe-like mode required during normal operation. Toggling the LANPHYPC Value bit essentially resets the interconnect forcing it to the correct mode.
after review of all intel drivers, found several instances where drivers had the incorrect pattern of:
memory mapped write();delay();
which should always be:
memory mapped write();
write flush(); /* aka memory mapped read */delay();
explanation:
The reason for including the flush is that writes can be held (posted) in PCI/PCIe bridges, but the read always has to complete synchronously and therefore has to flush all pending writes to a device. If a write is held and followed by a delay, the delay means nothing because the write may not have reached hardware (maybe even not until the next read)
--- drivers/net/e1000e/defines.h | 2 ++ drivers/net/e1000e/ich8lan.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+)
drivers/net/e1000e/defines.h +2 -0
@@ -214,6 +214,8 @@#define E1000_CTRL_SPD_1000 0x00000200/* Force 1Gb */ #define E1000_CTRL_FRCSPD 0x00000800/* Force Speed */ #define E1000_CTRL_FRCDPX 0x00001000/* Force Duplex */ +#define E1000_CTRL_LANPHYPC_OVERRIDE 0x00010000/* SW control of LANPHYPC */ +#define E1000_CTRL_LANPHYPC_VALUE 0x00020000/* SW value of LANPHYPC */ #define E1000_CTRL_SWDPIN0 0x00040000/* SWDPIN 0 value */ #define E1000_CTRL_SWDPIN1 0x00080000/* SWDPIN 1 value */ #define E1000_CTRL_SWDPIO0 0x00400000/* SWDPIN 0 Input or output */
drivers/net/e1000e/ich8lan.c +20 -0
@@ -88,6 +88,8 @@#define E1000_ICH_FWSM_RSPCIPHY 0x00000040/* Reset PHY on PCI Reset */ +/* FW established a valid mode */ +#define E1000_ICH_FWSM_FW_VALID 0x00008000#define E1000_ICH_MNG_IAMT_MODE 0x2
@@ -260,6 +262,7 @@ static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)static s32 e1000_init_phy_params_pchlan (struct e1000_hw *hw) {struct e1000_phy_info *phy = &hw->phy; +u32 ctrl;s32 ret_val =0 ; phy->addr =1 ;
@@ -274,6 +277,23 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->ops.write_phy_reg_locked = e1000_write_phy_reg_hv_locked; phy->autoneg_mask =AUTONEG_ADVERTISE_SPEED_DEFAULT ; +if (!(er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID )) { +/* +* The MAC-PHY interconnect may still be in SMBus mode +* after Sx->S0. Toggle the LANPHYPC Value bit to force +* the interconnect to PCIe mode, but only if there is no +* firmware present otherwise firmware will have done it. +*/ + ctrl =er32 (CTRL ); + ctrl |=E1000_CTRL_LANPHYPC_OVERRIDE ; + ctrl &= ~E1000_CTRL_LANPHYPC_VALUE ; +ew32 (CTRL , ctrl); +e1e_flush (); +udelay (10 ); + ctrl &= ~E1000_CTRL_LANPHYPC_OVERRIDE ; +ew32 (CTRL , ctrl); +msleep (50 ); + }/* * Reset the PHY before any acccess to it. Doing so, ensures that * the PHY is in a known good state before we read/write PHY registers.
Signature · 1 line
1.9.1
PATCH v2 2/5 e1000e: workaround EEPROM configuration change on 82579 on kernel 2.6.x
In reply to Zhu Yanjun2.6.x kernels require a similar logic change as commit 62bc813 [e1000e: workaround EEPROM configuration change on 82579] introduces for newer kernels.
An update to the EEPROM on 82579 will extend a delay in hardware to fix an issue with WoL not working after a G3->S5 transition which is unrelated to the driver. However, this extended delay conflicts with nominal operation of the device when it is initialized by the driver and after every reset of the hardware (i.e. the driver starts configuring the device before the hardware is done with it's own configuration work). The workaround for when the driver is in control of the device is to tell the hardware after every reset the configuration delay should be the original shorter one.
Some pre-existing variables are renamed generically to be re-used with new register accesses.
[e1000_toggle_lanphypc_value_ich8lan does not exist. Its implementations exist in e1000_init_phy_params_pchlan. Renamed variables remain unchanged]
--- drivers/net/e1000e/hw.h | 1 + drivers/net/e1000e/ich8lan.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
drivers/net/e1000e/hw.h +1 -0
@@ -60,6 +60,7 @@ enum e1e_registers {E1000_FEXTNVM =0x00028 ,/* Future Extended NVM - RW */ E1000_FCT =0x00030 ,/* Flow Control Type - RW */ E1000_VET =0x00038 ,/* VLAN Ether Type - RW */ +E1000_FEXTNVM3 =0x0003C ,/* Future Extended NVM 3 - RW */ E1000_ICR =0x000C0 ,/* Interrupt Cause Read - R/clr */ E1000_ITR =0x000C4 ,/* Interrupt Throttling Rate - RW */ E1000_ICS = 0x000C8, /* Interrupt Cause Set - WO */
drivers/net/e1000e/ich8lan.c +17 -0
@@ -108,6 +108,9 @@#define E1000_FEXTNVM_SW_CONFIG 1#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27)/* Bit redefined for ICH8M :/ */ +#define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK 0x0C000000 +#define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC 0x08000000 +#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL#define E1000_ICH_RAR_ENTRIES 7
@@ -278,6 +281,12 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->autoneg_mask =AUTONEG_ADVERTISE_SPEED_DEFAULT ;if (!(er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID )) { +/*Set Phy Config Counter to 50msec */ + ctrl =er32 (FEXTNVM3 ); + ctrl &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK ; + ctrl |=E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC ; +ew32 (FEXTNVM3 , ctrl); +/* * The MAC-PHY interconnect may still be in SMBus mode * after Sx->S0. Toggle the LANPHYPC Value bit to force
@@ -2685,6 +2694,14 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)ew32 (CTRL , (ctrl |E1000_CTRL_RST ));msleep (20 ); +/* Set Phy Config Counter to 50msec */ +if (hw->mac.type == e1000_pch2lan) { +u32 phycc_reg =er32 (FEXTNVM3 ); + phycc_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK ; + phycc_reg |=E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC ; +ew32 (FEXTNVM3 , phycc_reg); + } +if (!ret_val)e1000_release_swflag_ich8lan (hw);
Signature · 1 line
1.9.1
PATCH v2 3/5 e1000e: do not toggle LANPHYPC value bit when PHY reset is blocked
In reply to Zhu Yanjun2.6.x kernels require a similar logic change as commit 6cc7aae [e1000e: do not toggle LANPHYPC value bit when PHY reset is blocked] introduces for newer kernels.
When PHY reset is intentionally blocked on 82577/8/9, do not toggle the LANPHYPC value bit (essentially performing a hard power reset of the device) otherwise the PHY can be put into an unknown state.
Cleanup whitespace in the same function.
[yanjun.zhu: whitespace remains unchanged]
--- drivers/net/e1000e/ich8lan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/e1000e/ich8lan.c +2 -1
@@ -280,7 +280,8 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->ops.write_phy_reg_locked = e1000_write_phy_reg_hv_locked; phy->autoneg_mask =AUTONEG_ADVERTISE_SPEED_DEFAULT ; -if (!(er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID )) { +if (!(er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID ) && + !e1000_check_reset_block (hw)) {/*Set Phy Config Counter to 50msec */ ctrl =er32 (FEXTNVM3 ); ctrl &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK ;
Signature · 1 line
1.9.1
PATCH v2 4/5 e1000e: update workaround for 82579 intermittently disabled during S0->Sx
In reply to Zhu Yanjun2.6.x kernels require a similar logic change as commit 90b8298 [e1000e: update workaround for 82579 intermittently disabled during S0->Sx] introduces for newer kernels.
The workaround which toggles the LANPHYPC (LAN PHY Power Control) value bit to force the MAC-Phy interconnect into PCIe mode from SMBus mode during driver load and resume should always be done except if PHY resets are blocked by the Manageability Engine (ME). Previously, the toggle was done only if PHY resets are blocked and the ME was disabled.
The rest of the patch is just indentation changes as a consequence of the updated workaround.
[yanjun.zhu: indentation changes are removed. function e1000_init_phy_workarounds_pchlan does not exist]
--- drivers/net/e1000e/ich8lan.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/e1000e/ich8lan.c +1 -2
@@ -280,8 +280,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->ops.write_phy_reg_locked = e1000_write_phy_reg_hv_locked; phy->autoneg_mask =AUTONEG_ADVERTISE_SPEED_DEFAULT ; -if (!(er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID ) && - !e1000_check_reset_block (hw)) { +if (!e1000_check_reset_block (hw)) {/*Set Phy Config Counter to 50msec */ ctrl =er32 (FEXTNVM3 ); ctrl &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK ;
Signature · 1 line
1.9.1
PATCH v2 5/5 e1000e: cleanup use of check_reset_block function pointer
In reply to Zhu Yanjun2.6.x kernels require a similar logic change as commit 44abd5c [e1000e: cleanup use of check_reset_block function pointer] introduces for newer kernels.
Replace e1000_check_reset_block() inline function with calls to the PHY ops check_reset_block function pointer.
[yanjun.zhu: only modifications in function e1000_init_phy_params_pchlan will be backported. Others remain unchanged]
--- drivers/net/e1000e/ich8lan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/e1000e/ich8lan.c +1 -1
@@ -280,7 +280,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->ops.write_phy_reg_locked = e1000_write_phy_reg_hv_locked; phy->autoneg_mask =AUTONEG_ADVERTISE_SPEED_DEFAULT ; -if (!e1000_check_reset_block (hw)) { +if (!hw->phy.ops.check_reset_block (hw)) {/*Set Phy Config Counter to 50msec */ ctrl =er32 (FEXTNVM3 ); ctrl &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK ;
Signature · 1 line
1.9.1
RE: [PATCH 1/5] e1000e: reset MAC-PHY interconnect on 82577/82578
In reply to Zhu YanjunFrom: Zhu Yanjun
Quoted 15 lines
2.6.x kernels require a similar logic change as commit 6dfaa76 [e1000e: reset MAC-PHY interconnect on 82577/82578] introduces for newer kernels.
During
Sx->S0transitions, the interconnect between the MAC and PHY on 82577/82578 can remain in SMBus mode instead of transitioning to the PCIe-like mode required during normal operation. Toggling the LANPHYPC Value bit essentially resets the interconnect forcing it to the correct mode.after review of all intel drivers, found several instances where drivers had the incorrect pattern of:
memory mappedwrite();delay();
Quoted 4 lines
which should always be:
memory mappedwrite();
writeflush(); /* aka memory mapped read */delay();
Probably not only the intel drivers.
I'd bet that a lot of the delay() calls are wrong.
Quoted 7 lines
explanation:
The reason for including the flush is that writes can be held (posted) in PCI/PCIe bridges, but the read always has to complete synchronously and therefore has to flush all pending writes to a device. If a write is held and followed by a delay, the delay means nothing because the write may not have reached hardware (maybe even not until the next read)
It might even be that the 'write flush' (ie a read) guarantees to generates a long enough delay that the delay() itself isn't needed.
David
Re: [PATCH 1/5] e1000e: reset MAC-PHY interconnect on 82577/82578
In reply to Zhu YanjunQuoted 30 lines · Zhu Yanjun
2.6.x kernels require a similar logic change as commit 6dfaa76 [e1000e: reset MAC-PHY interconnect on 82577/82578] introduces for newer kernels.
During
Sx->S0transitions, the interconnect between the MAC and PHY on 82577/82578 can remain in SMBus mode instead of transitioning to the PCIe-like mode required during normal operation. Toggling the LANPHYPC
Value bit essentially resets the interconnect forcing it to the correct
mode.after review of all intel drivers, found several instances where drivers had the incorrect pattern of:
memory mappedwrite();delay();which should always be:
memory mappedwrite();
writeflush(); /* aka memory mapped read */delay();explanation:
The reason for including the flush is that writes can be held (posted) in PCI/PCIe bridges, but the read always has to complete synchronously and therefore has to flush all pending writes to a device. If a write is held and followed by a delay, the delay means nothing because the write may not have reached hardware (maybe even not until the next read)
Quoted 8 lines
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Zhu Yanjun <[email protected]>--- drivers/net/e1000e/defines.h | 2 ++ drivers/net/e1000e/ich8lan.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+)
To be clear, Zhu is wanting this applied to stable trees (yet did not CC [email protected] ).
Willy- I am fine with this series being applied to stable.
Re: [PATCH 1/5] e1000e: reset MAC-PHY interconnect on 82577/82578
Quoted 40 lines · Jeff Kirsher
Quoted 30 lines · Zhu Yanjun
2.6.x kernels require a similar logic change as commit 6dfaa76 [e1000e: reset MAC-PHY interconnect on 82577/82578] introduces for newer kernels.
During
Sx->S0transitions, the interconnect between the MAC and PHY on 82577/82578 can remain in SMBus mode instead of transitioning to the PCIe-like mode required during normal operation. Toggling the LANPHYPC
Value bit essentially resets the interconnect forcing it to the correct
mode.after review of all intel drivers, found several instances where drivers had the incorrect pattern of:
memory mappedwrite();delay();which should always be:
memory mappedwrite();
writeflush(); /* aka memory mapped read */delay();explanation:
The reason for including the flush is that writes can be held (posted) in PCI/PCIe bridges, but the read always has to complete synchronously and therefore has to flush all pending writes to a device. If a write is held and followed by a delay, the delay means nothing because the write may not have reached hardware (maybe even not until the next read)Quoted 8 lines
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Zhu Yanjun <[email protected]>--- drivers/net/e1000e/defines.h | 2 ++ drivers/net/e1000e/ich8lan.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+)
Quoted 4 lines
To be clear, Zhu is wanting this applied to stable trees (yet did not CC [email protected] ).
Willy- I am fine with this series being applied to stable.
OK, thanks Jeff! I'm queuing the patches now.
Best regards,
Willy
Hi,
Quoted 11 lines · Zhu Yanjun
With kernel 2.6.x, e1000e with 82577/8/9 sometimes will not boot after rebooting.
If a kernel 2.6.x board with 82577/8/9 e1000e nic is rebooted for 100 times, there are 7~8 times that 82577/8/9 e1000e nic will not boot normally.
V2:
Follow the advice from Willy, the wrong upstream commit IDs in these 5 patches commit messages are fixed.
Quoted 8 lines
Zhu Yanjun (5):
e1000e: reset MAC-PHY interconnect on 82577/82578
e1000e: workaround EEPROM configuration change on 82579 on kernel2.6.x e1000e: do not toggle LANPHYPC value bit when PHY reset is blocked e1000e: update workaround for 82579 intermittently disabled during S0->Sxe1000e: cleanup use of
check_reset_blockfunction pointer
I queued this series for 2.6.32.66 but found that it doesn't build because patch 2 adds this test :
@@ -2685,6 +2694,14 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
ew32(CTRL, (ctrl | E1000_CTRL_RST));
msleep(20);+ /* Set Phy Config Counter to 50msec */
+ if (hw->mac.type == e1000_pch2lan) {
+ u32 phycc_reg = er32(FEXTNVM3); + phycc_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK; + phycc_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC; + ew32(FEXTNVM3, phycc_reg);
+ }
+
And e1000_pch2lan doesn't appear in the enum in 2.6.32 hence this type is never assigned. Thus I'm wondering if I should just drop this test (trivial) or if there are other parts that may not be relevant to this kernel version.
Any hint will be greatly appreciated.
Thanks!
Willy