netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Patrick McHardy <kaber@trash.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: Re: sky bugs in 2.6.22-rc5
Date: Mon, 18 Jun 2007 13:04:14 -0700	[thread overview]
Message-ID: <20070618130414.35801913@localhost.localdomain> (raw)
In-Reply-To: <4676E1DD.1060007@trash.net>

Does this fix it?  It was possible for the PHY interrupt to race
while bringing link up.


--- a/drivers/net/sky2.c	2007-06-18 12:56:29.000000000 -0700
+++ b/drivers/net/sky2.c	2007-06-18 13:02:11.000000000 -0700
@@ -652,7 +652,6 @@ static void sky2_wol_init(struct sky2_po
 
 static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 {
-	struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
 	u16 reg;
 	int i;
 	const u8 *addr = hw->dev[port]->dev_addr;
@@ -679,9 +678,7 @@ static void sky2_mac_init(struct sky2_hw
 	/* Enable Transmit FIFO Underrun */
 	sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), GMAC_DEF_MSK);
 
-	spin_lock_bh(&sky2->phy_lock);
 	sky2_phy_init(hw, port);
-	spin_unlock_bh(&sky2->phy_lock);
 
 	/* MIB clear */
 	reg = gma_read16(hw, port, GM_PHY_ADDR);
@@ -1259,6 +1256,7 @@ static int sky2_up(struct net_device *de
 	if (!sky2->rx_ring)
 		goto err_out;
 
+	spin_lock_bh(&sky2->phy_lock);
 	sky2_phy_power(hw, port, 1);
 
 	sky2_mac_init(hw, port);
@@ -1295,15 +1293,18 @@ static int sky2_up(struct net_device *de
 
 	err = sky2_rx_start(sky2);
 	if (err)
-		goto err_out;
+		goto err_out_unlock;
 
 	/* Enable interrupts from phy/mac for port */
 	imask = sky2_read32(hw, B0_IMSK);
 	imask |= portirq_msk[port];
 	sky2_write32(hw, B0_IMSK, imask);
 
+	spin_unlock_bh(&sky2->phy_lock);
 	return 0;
 
+err_out_unlock:
+	spin_unlock_bh(&sky2->phy_lock);
 err_out:
 	if (sky2->rx_le) {
 		pci_free_consistent(hw->pdev, RX_LE_BYTES,
@@ -1571,6 +1572,8 @@ static int sky2_down(struct net_device *
 	if (netif_msg_ifdown(sky2))
 		printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
 
+	spin_lock_bh(&sky2->phy_lock);
+
 	/* Stop more packets from being queued */
 	netif_stop_queue(dev);
 	netif_carrier_off(dev);
@@ -1647,6 +1650,7 @@ static int sky2_down(struct net_device *
 
 	sky2->rx_ring = NULL;
 	sky2->tx_ring = NULL;
+	spin_unlock_bh(&sky2->phy_lock);
 
 	return 0;
 }
@@ -1830,10 +1834,10 @@ static void sky2_phy_intr(struct sky2_hw
 	struct sky2_port *sky2 = netdev_priv(dev);
 	u16 istatus, phystat;
 
+	spin_lock(&sky2->phy_lock);
 	if (!netif_running(dev))
-		return;
+		goto out;
 
-	spin_lock(&sky2->phy_lock);
 	istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
 	phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
 

  parent reply	other threads:[~2007-06-18 20:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-18 19:49 sky bugs in 2.6.22-rc5 Patrick McHardy
2007-06-18 19:51 ` Stephen Hemminger
2007-06-18 20:00   ` Patrick McHardy
2007-06-18 20:04 ` Stephen Hemminger [this message]
2007-06-18 20:13   ` Patrick McHardy
2007-06-18 20:20     ` Stephen Hemminger
2007-06-18 20:43       ` Patrick McHardy
2007-06-18 20:47         ` Stephen Hemminger
2007-06-18 20:56           ` Patrick McHardy

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=20070618130414.35801913@localhost.localdomain \
    --to=shemminger@linux-foundation.org \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.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).