linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sungem: Make PM of PHYs more reliable
@ 2006-01-22  2:59 Benjamin Herrenschmidt
  2006-01-22  3:01 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2006-01-22  2:59 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Kernel list

On my latest laptop, I've had occasional PHY dead on wakeup from
sleep... the PHY would be totally unresponsive even to toggling the hard
reset line until the machine is powered down... Looking closely at the
code, I found some possible issues in the way we setup the MDIO lines
during suspend along with slight divergences from what Darwin does when
resetting it that may explain the problem. That patch change these and
the problem appear to be gone for me at least... I also fixed an mdelay
-> msleep while I was at it to the pmac feature code that is called
when toggling the PHY reset line since sungem doesn't call it in an
atomic context anymore.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

Dave, please send to Linus if you are ok with it.

Index: linux-work/arch/powerpc/platforms/powermac/feature.c
===================================================================
--- linux-work.orig/arch/powerpc/platforms/powermac/feature.c	2006-01-11 12:56:21.000000000 +1100
+++ linux-work/arch/powerpc/platforms/powermac/feature.c	2006-01-11 13:42:24.000000000 +1100
@@ -914,12 +914,12 @@
 	MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE);
 	(void)MACIO_IN8(KL_GPIO_ETH_PHY_RESET);
 	UNLOCK(flags);
-	mdelay(10);
+	msleep(10);
 	LOCK(flags);
 	MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, /*KEYLARGO_GPIO_OUTPUT_ENABLE | */
 		KEYLARGO_GPIO_OUTOUT_DATA);
 	UNLOCK(flags);
-	mdelay(10);
+	msleep(10);
 
 	return 0;
 }
Index: linux-work/drivers/net/sungem.c
===================================================================
--- linux-work.orig/drivers/net/sungem.c	2005-12-29 10:24:58.000000000 +1100
+++ linux-work/drivers/net/sungem.c	2006-01-11 13:50:06.000000000 +1100
@@ -1662,27 +1662,28 @@
 	
 	if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) {
 		int i;
+		u16 ctrl;
 
-		/* Those delay sucks, the HW seem to love them though, I'll
-		 * serisouly consider breaking some locks here to be able
-		 * to schedule instead
-		 */
-		for (i = 0; i < 3; i++) {
 #ifdef CONFIG_PPC_PMAC
-			pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0);
-			msleep(20);
+		pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0);
 #endif
-			/* Some PHYs used by apple have problem getting back to us,
-			 * we do an additional reset here
-			 */
-			phy_write(gp, MII_BMCR, BMCR_RESET);
-			msleep(20);
-			if (phy_read(gp, MII_BMCR) != 0xffff)
+
+		/* Some PHYs used by apple have problem getting back
+		 * to us, we do an additional reset here
+		 */
+		phy_write(gp, MII_BMCR, BMCR_RESET);
+		for (i = 0; i < 10; i++) {
+			if ((phy_read(gp, MII_BMCR) & BMCR_RESET) == 0)
 				break;
-			if (i == 2)
-				printk(KERN_WARNING "%s: GMAC PHY not responding !\n",
-				       gp->dev->name);
+			msleep(10);
 		}
+		if (i == 10)
+			printk(KERN_WARNING "%s: GMAC PHY not responding !\n",
+			       gp->dev->name);
+		/* Make sure isolate is off */
+		ctrl = phy_read(gp, MII_BMCR);
+		if (ctrl & BMCR_ISOLATE)
+			phy_write(gp, MII_BMCR, ctrl & ~BMCR_ISOLATE);
 	}
 
 	if (gp->pdev->vendor == PCI_VENDOR_ID_SUN &&



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sungem: Make PM of PHYs more reliable
  2006-01-22  2:59 [PATCH] sungem: Make PM of PHYs more reliable Benjamin Herrenschmidt
@ 2006-01-22  3:01 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2006-01-22  3:01 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Kernel list

On Sun, 2006-01-22 at 13:59 +1100, Benjamin Herrenschmidt wrote:
> On my latest laptop, I've had occasional PHY dead on wakeup from
> sleep... the PHY would be totally unresponsive even to toggling the hard
> reset line until the machine is powered down... Looking closely at the
> code, I found some possible issues in the way we setup the MDIO lines
> during suspend along with slight divergences from what Darwin does when
> resetting it that may explain the problem. That patch change these and
> the problem appear to be gone for me at least... I also fixed an mdelay
> -> msleep while I was at it to the pmac feature code that is called
> when toggling the PHY reset line since sungem doesn't call it in an
> atomic context anymore.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---

Oops, -EWRONGPATCH... Sorry, please ignore it, I'll dig the right one...

Ben.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-22  3:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-22  2:59 [PATCH] sungem: Make PM of PHYs more reliable Benjamin Herrenschmidt
2006-01-22  3:01 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).