Skip to content

Commit bb03451

Browse files
bwallanJeff Kirsher
authored andcommitted
e1000e: additional error handling on PHY register accesses
PHY reads/writes via the MDIC register could potentially return results from a previous PHY register access. If that happens, the offset in the returned results will be that of the previous access and if that is different from the expected offset, log a debug message and error out. Signed-off-by: Bruce Allan <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 8b49a4c commit bb03451

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/net/ethernet/intel/e1000e/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@
788788
GG82563_REG(194, 18) /* Inband Control */
789789

790790
/* MDI Control */
791+
#define E1000_MDIC_REG_MASK 0x001F0000
791792
#define E1000_MDIC_REG_SHIFT 16
792793
#define E1000_MDIC_PHY_SHIFT 21
793794
#define E1000_MDIC_OP_WRITE 0x04000000

drivers/net/ethernet/intel/e1000e/phy.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
178178
e_dbg("MDI Error\n");
179179
return -E1000_ERR_PHY;
180180
}
181+
if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) {
182+
e_dbg("MDI Read offset error - requested %d, returned %d\n",
183+
offset,
184+
(mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT);
185+
return -E1000_ERR_PHY;
186+
}
181187
*data = (u16)mdic;
182188

183189
/* Allow some time after each MDIC transaction to avoid
@@ -236,6 +242,12 @@ s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
236242
e_dbg("MDI Error\n");
237243
return -E1000_ERR_PHY;
238244
}
245+
if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) {
246+
e_dbg("MDI Write offset error - requested %d, returned %d\n",
247+
offset,
248+
(mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT);
249+
return -E1000_ERR_PHY;
250+
}
239251

240252
/* Allow some time after each MDIC transaction to avoid
241253
* reading duplicate data in the next MDIC transaction.

0 commit comments

Comments
 (0)