Skip to contentSkip to conversation

BMC Tigon 3 (tg3) problem with powering down PHY (tentative PATCH)

PATCH Greg Alexander 1 participant 1 message Feb 9, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all -

My new Lenovo U150 has a BMC57780 in it. It uses mdio with phylib to access the PHY. I am using x86-64 SMP kernel 2.6.32.7.

The device initializes successfully the first time but after ifconfig down, it will not not re-initialize. It looks like the phy layer is attempting to autonegotiate while MII_BMCR is BMCR_PDOWN.

drivers/net/tg3.c:tg3_set_power_state() calls tg3_power_down_phy() which sets BMCR_PDOWN directly. But I could not find anything which is responsible for powering it back up. tg3_mdio_init() has a comment indicating that it uses tg3_bmcr_reset() to turn the phy on. So I basically cut and pasted that code into tg3_set_power_state(), conditional on using phylib (because I'm ignorant about other cases).

And that fixed my problem. Hack-patch below. I'm ignorant as all get out about this, so hopefully someone else can take this the rest of the way?

Red herrings: genphy_suspend()/genphy_resume() never get called, (genphy_resume() does not work in this context even if called). Also, the PHY_RESUMING state is never processed because the tg3.c code calls into phy_start_aneg() setting it directly to PHY_AN...which also seems to be a non-issue but maybe it matters to someone in some cases?

Anyways, thanks! This chip is pretty new but it is already 99% supported in Linux! My hat's off to all of you!

- Greg

------------------patch--------------------------

tg3.c +6 -0
@@ -2432,6 +2432,12 @@
 		/* Switch out of Vaux if it is a NIC */
 		if (tp->tg3_flags2 & TG3_FLG2_IS_NIC)
 			tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
+		if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) {
+			u32 reg;
+			if (tg3_readphy(tp, MII_BMCR, &reg) || (reg & BMCR_PDOWN)) {
+				tg3_bmcr_reset(tp);
+			}
+		}
 
 		return 0;