Skip to contentSkip to conversation

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

PATCH Applied Heiner Kallweit 2 participants 2 messages Oct 7, 2020 – Oct 8, 2020

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 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")
---
 drivers/net/ethernet/realtek/r8169_main.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +7 -0
index 0fa99298a..9afd1ef57 100644
@@ -2055,11 +2055,18 @@ static void rtl_release_firmware(struct rtl8169_private *tp)
 
 void r8169_apply_firmware(struct rtl8169_private *tp)
 {
+	int val;
+
 	/* TODO: release firmware if rtl_fw_write_firmware signals failure. */
 	if (tp->rtl_fw) {
 		rtl_fw_write_firmware(tp, tp->rtl_fw);
 		/* At least one firmware doesn't reset tp->ocp_base. */
 		tp->ocp_base = OCP_STD_PHY_BASE;
+
+		/* PHY soft reset may still be in progress */
+		phy_read_poll_timeout(tp->phydev, MII_BMCR, val,
+				      !(val & BMCR_RESET),
+				      50000, 600000, true);
 	}
 }
 
Signature · 1 line
2.28.0
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 9 lines · On Wed, 7 Oct 2020 13:34:51 +0200 you wrote:

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.

[...]

Here is the summary with links:
- [net] r8169: consider that PHY reset may still be in progress after applying firmware

    https://git.kernel.org/netdev/net/c/47dda78671a3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html