netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: netdev@vger.kernel.org
Cc: "Shawn Guo" <shawn.guo@freescale.com>,
	"Wolfram Sang" <w.sang@pengutronix.de>,
	"Lothar Waßmann" <LW@KARO-electronics.de>
Subject: net/fec on i.MX28: failure after network cable unplug or device down
Date: Mon, 10 Oct 2011 15:17:05 +0200	[thread overview]
Message-ID: <20111010131705.GA25293@pengutronix.de> (raw)

Hello,

I currently see the problem on two different i.MX28 based system
(Freescale's mx28evk and a Karo TX28) that after unplugging and
reconnection of the network cable or ifconfig down; ifconfig up; the
network is dead. That means nothing is sent or received anymore.

ifconfig up dies with:

	[   32.120000] FEC: MDIO read timeout
	[   32.120000] eth0: could not attach to PHY
	ifconfig: SIOCSIFFLAGS: Connection timed out

after unplugging the network cable I get:

	[   25.520000] PHY: 1:00 - Link is Down
	[   26.530000] FEC: MDIO read timeout

In both cases the mdio read operation doesn't fire the mii irq, though
the FEC_MII_DATA contains data that looks right and the interrupt
register (FEC_IEVENT) has the mii bit set and according to the mask
register (FEC_IMASK) the irq isn't masked.

When commenting out

	writel(1, fep->hwp + FEC_ECNTRL);

(i.e. don't reset the network unit) in fec_stop it works (but Wolfram
seems to remember that doing so breaks e.g. i.MX35. We have not checked
yet).

Strange enough with the reset commented out in fec_stop, fec_restart
resets the fec (when the cable is reconnected) but without breaking it.

I tried to restore more registers in fec_stop (most notably FEC_R_CNTRL
that has some mii fields) but without success.

Do you see this problem, too? Maybe do you have an idea to fix it?
Currently I use the following patch:

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 5b631fe..8c1330f 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -458,6 +458,8 @@ static void
 fec_stop(struct net_device *ndev)
 {
 	struct fec_enet_private *fep = netdev_priv(ndev);
+	const struct platform_device_id *id_entry =
+				platform_get_device_id(fep->pdev);
 
 	/* We cannot expect a graceful transmit stop without link !!! */
 	if (fep->link) {
@@ -467,11 +469,13 @@ fec_stop(struct net_device *ndev)
 			printk("fec_stop : Graceful transmit stop did not complete !\n");
 	}
 
-	/* Whack a reset.  We should wait for this. */
-	writel(1, fep->hwp + FEC_ECNTRL);
-	udelay(10);
-	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
-	writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
+	if (!(id_entry->driver_data & FEC_QUIRK_ENET_MAC)) {
+		/* Whack a reset.  We should wait for this. */
+		writel(1, fep->hwp + FEC_ECNTRL);
+		udelay(10);
+		writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
+		writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
+	}
 }
 
but this feels wrong because sending and receiving isn't disabled in
hardware without link then.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

             reply	other threads:[~2011-10-10 13:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 13:17 Uwe Kleine-König [this message]
2011-10-10 13:52 ` net/fec on i.MX28: failure after network cable unplug or device down Lothar Waßmann

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=20111010131705.GA25293@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=LW@KARO-electronics.de \
    --cc=netdev@vger.kernel.org \
    --cc=shawn.guo@freescale.com \
    --cc=w.sang@pengutronix.de \
    /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).