Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

r8169: consider that PHY reset may still be in progress after applying firmware

Some firmware files trigger a PHY soft reset and don't wait for it to
be finished. PHY register writes directly after applying the firmware
may fail or provide unexpected results therefore. Fix this by waiting
for bit BMCR_RESET to be cleared after applying firmware.

There's nothing wrong with the referenced change, it's just that the
fix will apply cleanly only after this change.

Fixes: 89fbd26cca7e ("r8169: fix firmware not resetting tp->ocp_base")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
47dda786 8aa7b526

+7
+7
drivers/net/ethernet/realtek/r8169_main.c
··· 2058 2058 2059 2059 void r8169_apply_firmware(struct rtl8169_private *tp) 2060 2060 { 2061 + int val; 2062 + 2061 2063 /* TODO: release firmware if rtl_fw_write_firmware signals failure. */ 2062 2064 if (tp->rtl_fw) { 2063 2065 rtl_fw_write_firmware(tp, tp->rtl_fw); 2064 2066 /* At least one firmware doesn't reset tp->ocp_base. */ 2065 2067 tp->ocp_base = OCP_STD_PHY_BASE; 2068 + 2069 + /* PHY soft reset may still be in progress */ 2070 + phy_read_poll_timeout(tp->phydev, MII_BMCR, val, 2071 + !(val & BMCR_RESET), 2072 + 50000, 600000, true); 2066 2073 } 2067 2074 } 2068 2075