Skip to contentSkip to conversation

sky2: update

PATCH In review Stephen Hemminger 2 participants 10 messages May 13, 2010 – May 17, 2010

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

cover sky2: update

Bunch of patches from Mike, with some additional comments.

#1 lore raw

PATCH 1/6 sky2: Restore multicast after restart

From: Mike McCormack <[email protected]>

Multicast settings will be lost on reset, so restore them.

---
This regression was introduced in 2.6.34 by
commit 8a0c9228f110218f443d9ef8f9ab629251959733
sky2: Avoid down and up during sky2_reset

So please apply to -net as well.

 drivers/net/sky2.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/sky2.c +1 -0
@@ -3347,6 +3347,7 @@ static void sky2_restart(struct work_str
 			continue;
 
 		sky2_hw_up(sky2);
+		sky2_set_multicast(dev);
 		netif_wake_queue(dev);
 	}
 
#2 lore raw

PATCH 2/6 sky2: Avoid race in sky2_change_mtu

In reply to Stephen Hemminger

From: Mike McCormack <[email protected]>

netif_stop_queue does not ensure all in-progress transmits are complete,
so use netif_tx_disable() instead.

Secondly, make sure NAPI polls are disabled before stopping the tx queue,
otherwise sky2_status_intr might trigger a TX queue wakeup between when we stop the queue and NAPI is disabled.

---
This is not a regression, so only apply to -next

drivers/net/sky2.c +1 -1
@@ -2275,8 +2275,8 @@ static int sky2_change_mtu(struct net_de
 	sky2_write32(hw, B0_IMSK, 0);
 
 	dev->trans_start = jiffies;	/* prevent tx timeout */
-	netif_stop_queue(dev);
 	napi_disable(&hw->napi);
+	netif_tx_disable(dev);
 
 	synchronize_irq(hw->pdev->irq);
 
#3 lore raw

PATCH 3/6 sky2: Shut off interrupts before NAPI

In reply to Stephen Hemminger

From: Mike McCormack <[email protected]>

Interrupts should be masked, then synchronized, and finally NAPI should be disabled.

---
Not a regression, only apply to -next

drivers/net/sky2.c +2 -2
@@ -3320,10 +3320,10 @@ static void sky2_restart(struct work_str
 
 	rtnl_lock();
 
-	napi_disable(&hw->napi);
-	synchronize_irq(hw->pdev->irq);
 	imask = sky2_read32(hw, B0_IMSK);
 	sky2_write32(hw, B0_IMSK, 0);
+	synchronize_irq(hw->pdev->irq);
+	napi_disable(&hw->napi);
 
 	for (i = 0; i < hw->ports; i++) {
 		struct net_device *dev = hw->dev[i];
#4 lore raw

PATCH 4/6 sky2: Refactor down/up code out of sky2_restart()

In reply to Stephen Hemminger

From: Mike McCormack <[email protected]>

Code to bring down all sky2 interfaces and bring it up again can be reused in sky2_suspend and sky2_resume.

Factor the code to bring the interfaces down into sky2_all_down and the up code into sky2_all_up.

---
Not a regression.

 drivers/net/sky2.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
drivers/net/sky2.c +19 -7
@@ -3312,15 +3312,11 @@ static int sky2_reattach(struct net_devi
 	return err;
 }
 
-static void sky2_restart(struct work_struct *work)
+static void sky2_all_down(struct sky2_hw *hw)
 {
-	struct sky2_hw *hw = container_of(work, struct sky2_hw, restart_work);
-	u32 imask;
 	int i;
 
-	rtnl_lock();
-
-	imask = sky2_read32(hw, B0_IMSK);
+	sky2_read32(hw, B0_IMSK);
 	sky2_write32(hw, B0_IMSK, 0);
 	synchronize_irq(hw->pdev->irq);
 	napi_disable(&hw->napi);
@@ -3336,8 +3332,12 @@ static void sky2_restart(struct work_str
 		netif_tx_disable(dev);
 		sky2_hw_down(sky2);
 	}
+}
 
-	sky2_reset(hw);
+static void sky2_all_up(struct sky2_hw *hw)
+{
+	u32 imask = Y2_IS_BASE;
+	int i;
 
 	for (i = 0; i < hw->ports; i++) {
 		struct net_device *dev = hw->dev[i];
@@ -3348,6 +3348,7 @@ static void sky2_restart(struct work_str
 
 		sky2_hw_up(sky2);
 		sky2_set_multicast(dev);
+		imask |= portirq_msk[i];
 		netif_wake_queue(dev);
 	}
 
@@ -3356,6 +3357,17 @@ static void sky2_restart(struct work_str
 
 	sky2_read32(hw, B0_Y2_SP_LISR);
 	napi_enable(&hw->napi);
+}
+
+static void sky2_restart(struct work_struct *work)
+{
+	struct sky2_hw *hw = container_of(work, struct sky2_hw, restart_work);
+
+	rtnl_lock();
+
+	sky2_all_down(hw);
+	sky2_reset(hw);
+	sky2_all_up(hw);
 
 	rtnl_unlock();
 }
#5 lore raw

PATCH 5/6 sky2: Avoid allocating memory in sky2_resume

In reply to Stephen Hemminger

From: Mike McCormack <[email protected]>

Allocating memory can fail, and since we have the memory we need in sky2_resume when sky2_suspend is called, just stop the hardware without freeing the memory it's using.

This avoids the possibility of failing because we can't allocate memory in sky2_resume(), and allows sharing code with sky2_restart().

---
Not a regression

 drivers/net/sky2.c |   20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)
drivers/net/sky2.c +5 -15
@@ -4926,12 +4926,12 @@ static int sky2_suspend(struct pci_dev *
 	cancel_work_sync(&hw->restart_work);
 
 	rtnl_lock();
+
+	sky2_all_down(hw);
 	for (i = 0; i < hw->ports; i++) {
 		struct net_device *dev = hw->dev[i];
 		struct sky2_port *sky2 = netdev_priv(dev);
 
-		sky2_detach(dev);
-
 		if (sky2->wol)
 			sky2_wol_init(sky2);
 
@@ -4940,8 +4940,6 @@ static int sky2_suspend(struct pci_dev *
 
 	device_set_wakeup_enable(&pdev->dev, wol != 0);
 
-	sky2_write32(hw, B0_IMSK, 0);
-	napi_disable(&hw->napi);
 	sky2_power_aux(hw);
 	rtnl_unlock();
 
@@ -4956,12 +4954,11 @@ static int sky2_suspend(struct pci_dev *
 static int sky2_resume(struct pci_dev *pdev)
 {
 	struct sky2_hw *hw = pci_get_drvdata(pdev);
-	int i, err;
+	int err;
 
 	if (!hw)
 		return 0;
 
-	rtnl_lock();
 	err = pci_set_power_state(pdev, PCI_D0);
 	if (err)
 		goto out;
@@ -4979,20 +4976,13 @@ static int sky2_resume(struct pci_dev *p
 		goto out;
 	}
 
+	rtnl_lock();
 	sky2_reset(hw);
-	sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
-	napi_enable(&hw->napi);
-
-	for (i = 0; i < hw->ports; i++) {
-		err = sky2_reattach(hw->dev[i]);
-		if (err)
-			goto out;
-	}
+	sky2_all_up(hw);
 	rtnl_unlock();
 
 	return 0;
 out:
-	rtnl_unlock();
 
 	dev_err(&pdev->dev, "resume failed (%d)\n", err);
 	pci_disable_device(pdev);
#8 lore raw
Quoted 6 lines · On Fri, 14 May 2010 03:15:01 -0700 (PDT) David Miller <[email protected]>…

From: Stephen Hemminger <[email protected]>
Date: Thu, 13 May 2010 09:12:47 -0700

Quoted 1 line

Bunch of patches from Mike, with some additional comments.

All applied to net-next-2.6, thanks.

The first one needs to go to net-2.6 because it a regression:
Current code will lose multicast addresses when the automatic recovery from stuck chip happens. Auto recovery happens a lot under load on some configurations.

maintainer
#9 lore raw

From: Stephen Hemminger <[email protected]>
Date: Fri, 14 May 2010 08:19:57 -0700

Quoted 6 lines
Quoted 3 lines · On Fri, 14 May 2010 03:15:01 -0700 (PDT) David Miller <[email protected]>…

From: Stephen Hemminger <[email protected]>
Date: Thu, 13 May 2010 09:12:47 -0700

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Bunch of patches from Mike, with some additional comments.

All applied to net-next-2.6, thanks.

The first one needs to go to net-2.6 because it a regression:
Current code will lose multicast addresses when the automatic recovery from stuck chip happens. Auto recovery happens a lot under load on some configurations.

2.6.34 got released yesterday, so it is a moot point.

Just submit it to -stable.