linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: <linuxppc-dev@ozlabs.org>
Subject: [PATCH 4/6] ibm_newemac: Workaround reset timeout when no link
Date: Thu, 08 Nov 2007 19:06:59 +1100	[thread overview]
Message-ID: <20071108080731.2E40DDDDFC@ozlabs.org> (raw)
In-Reply-To: <1194509217.421165.545980042680.qpush@grosgo>

With some PHYs, when the link goes away, the EMAC reset fails due
to the loss of the RX clock I believe.

The old EMAC driver worked around that using some internal chip-specific
clock force bits that are different on various 44x implementations.

This is an attempt at doing it differently, by avoiding the reset when
there is no link, but forcing loopback mode instead. It seems to work
on my Taishan 440GX based board so far.

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

 drivers/net/ibm_newemac/core.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Index: linux-work/drivers/net/ibm_newemac/core.c
===================================================================
--- linux-work.orig/drivers/net/ibm_newemac/core.c	2007-11-08 17:38:44.000000000 +1100
+++ linux-work/drivers/net/ibm_newemac/core.c	2007-11-08 18:03:44.000000000 +1100
@@ -464,26 +464,34 @@ static int emac_configure(struct emac_in
 {
 	struct emac_regs __iomem *p = dev->emacp;
 	struct net_device *ndev = dev->ndev;
-	int tx_size, rx_size;
+	int tx_size, rx_size, link = netif_carrier_ok(dev->ndev);
 	u32 r, mr1 = 0;
 
 	DBG(dev, "configure" NL);
 
-	if (emac_reset(dev) < 0)
+	if (!link) {
+		out_be32(&p->mr1, in_be32(&p->mr1)
+			 | EMAC_MR1_FDE | EMAC_MR1_ILE);
+		udelay(100);
+	} else if (emac_reset(dev) < 0)
 		return -ETIMEDOUT;
 
 	if (emac_has_feature(dev, EMAC_FTR_HAS_TAH))
 		tah_reset(dev->tah_dev);
 
-	DBG(dev, " duplex = %d, pause = %d, asym_pause = %d\n",
-	    dev->phy.duplex, dev->phy.pause, dev->phy.asym_pause);
+	DBG(dev, " link = %d duplex = %d, pause = %d, asym_pause = %d\n",
+	    link, dev->phy.duplex, dev->phy.pause, dev->phy.asym_pause);
 
 	/* Default fifo sizes */
 	tx_size = dev->tx_fifo_size;
 	rx_size = dev->rx_fifo_size;
 
+	/* No link, force loopback */
+	if (!link)
+		mr1 = EMAC_MR1_FDE | EMAC_MR1_ILE;
+
 	/* Check for full duplex */
-	if (dev->phy.duplex == DUPLEX_FULL)
+	else if (dev->phy.duplex == DUPLEX_FULL)
 		mr1 |= EMAC_MR1_FDE | EMAC_MR1_MWSW_001;
 
 	/* Adjust fifo sizes, mr1 and timeouts based on link speed */
@@ -1162,9 +1170,9 @@ static void emac_link_timer(struct work_
 		link_poll_interval = PHY_POLL_LINK_ON;
 	} else {
 		if (netif_carrier_ok(dev->ndev)) {
-			emac_reinitialize(dev);
 			netif_carrier_off(dev->ndev);
 			netif_tx_disable(dev->ndev);
+			emac_reinitialize(dev);
 			emac_print_link_status(dev);
 		}
 		link_poll_interval = PHY_POLL_LINK_OFF;

  parent reply	other threads:[~2007-11-08  8:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08  8:06 [PATCH 0/6] ibm_newemac: Pending patches for review Benjamin Herrenschmidt
2007-11-08  8:06 ` [PATCH 1/6] ibm_newemac: Add BCM5248 and Marvell 88E1111 PHY support Benjamin Herrenschmidt
2007-11-08  8:06 ` [PATCH 2/6] ibm_newemac: Add ET1011c " Benjamin Herrenschmidt
2007-11-08  8:41   ` Stefan Roese
2007-11-08  8:42     ` Benjamin Herrenschmidt
2007-11-08 12:08       ` Josh Boyer
2007-11-08 20:55         ` Benjamin Herrenschmidt
2007-11-09  5:44           ` Stefan Roese
2007-11-08  8:06 ` [PATCH 3/6] ibm_newemac: Fix ZMII refcounting bug Benjamin Herrenschmidt
2007-11-08  8:43   ` Stefan Roese
2007-11-08  8:06 ` Benjamin Herrenschmidt [this message]
2007-11-08  8:44   ` [PATCH 4/6] ibm_newemac: Workaround reset timeout when no link Stefan Roese
2007-11-08  8:07 ` [PATCH 5/6] ibm_newemac: Cleanup/Fix RGMII MDIO support detection Benjamin Herrenschmidt
2007-11-08  9:24   ` Stefan Roese
2007-11-08  8:07 ` [PATCH 6/6] ibm_newemac: Cleanup/fix support for STACR register variants Benjamin Herrenschmidt
2007-11-08  9:38   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071108080731.2E40DDDDFC@ozlabs.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).