Skip to contentSkip to conversation

skge update

PATCH In review Stephen Hemminger 3 participants 9 messages Aug 28, 2006 – Aug 29, 2006

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

PATCH 1/5 skge: cleanup suspend/resume code

The code for suspend/resume needs several fixes. The hardware lock should be setup in probe only, not in resume. Interrupts should be disabled during suspend, etc.

drivers/net/skge.c +29 -20
@@ -3106,7 +3106,6 @@ static int skge_reset(struct skge_hw *hw
 	else
 		hw->ram_size = t8 * 4096;
 
-	spin_lock_init(&hw->hw_lock);
 	hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1;
 	if (hw->ports > 1)
 		hw->intr_mask |= IS_PORT_2;
@@ -3332,6 +3331,7 @@ static int __devinit skge_probe(struct p
 	hw->pdev = pdev;
 	mutex_init(&hw->phy_mutex);
 	INIT_WORK(&hw->phy_work, skge_extirq, hw);
+	spin_lock_init(&hw->hw_lock);
 
 	hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
 	if (!hw->regs) {
@@ -3449,26 +3449,25 @@ static int skge_suspend(struct pci_dev *
 	struct skge_hw *hw  = pci_get_drvdata(pdev);
 	int i, wol = 0;
 
-	for (i = 0; i < 2; i++) {
+	pci_save_state(pdev);
+	for (i = 0; i < hw->ports; i++) {
 		struct net_device *dev = hw->dev[i];
 
-		if (dev) {
+		if (netif_running(dev)) {
 			struct skge_port *skge = netdev_priv(dev);
-			if (netif_running(dev)) {
-				netif_carrier_off(dev);
-				if (skge->wol)
-					netif_stop_queue(dev);
-				else
-					skge_down(dev);
-			}
-			netif_device_detach(dev);
+
+			netif_carrier_off(dev);
+			if (skge->wol)
+				netif_stop_queue(dev);
+			else
+				skge_down(dev);
 			wol |= skge->wol;
 		}
+		netif_device_detach(dev);
 	}
 
-	pci_save_state(pdev);
+	skge_write32(hw, B0_IMSK, 0);
 	pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
-	pci_disable_device(pdev);
 	pci_set_power_state(pdev, pci_choose_state(pdev, state));
 
 	return 0;
@@ -3477,23 +3476,33 @@ static int skge_suspend(struct pci_dev *
 static int skge_resume(struct pci_dev *pdev)
 {
 	struct skge_hw *hw  = pci_get_drvdata(pdev);
-	int i;
+	int i, err;
 
 	pci_set_power_state(pdev, PCI_D0);
 	pci_restore_state(pdev);
 	pci_enable_wake(pdev, PCI_D0, 0);
 
-	skge_reset(hw);
+	err = skge_reset(hw);
+	if (err)
+		goto out;
 
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < hw->ports; i++) {
 		struct net_device *dev = hw->dev[i];
-		if (dev) {
-			netif_device_attach(dev);
-			if (netif_running(dev) && skge_up(dev))
+
+		netif_device_attach(dev);
+		if (netif_running(dev)) {
+			err = skge_up(dev);
+
+			if (err) {
+				printk(KERN_ERR PFX "%s: could not up: %d\n",
+				       dev->name, err);
 				dev_close(dev);
+				goto out;
+			}
 		}
 	}
-	return 0;
+out:
+	return err;
 }
 #endif
 

--
Stephen Hemminger <[email protected]>

#2 lore raw

Re: [PATCH 1/5] skge: cleanup suspend/resume code

applied 1-5

#3 lore raw

PATCH 2/5 skge: pci bus post fixes

In reply to Stephen Hemminger

At the end of a critical section, we need to force the PCI write to complete by doing a read.

drivers/net/skge.c +4 -1
@@ -2747,7 +2747,7 @@ static int skge_poll(struct net_device *
 	spin_lock_irq(&hw->hw_lock);
 	hw->intr_mask |= rxirqmask[skge->port];
   	skge_write32(hw, B0_IMSK, hw->intr_mask);
-	mmiowb();
+	skge_read32(hw, B0_IMSK);
 	spin_unlock_irq(&hw->hw_lock);
 
 	return 0;
@@ -2881,6 +2881,7 @@ static void skge_extirq(void *arg)
 	spin_lock_irq(&hw->hw_lock);
 	hw->intr_mask |= IS_EXT_REG;
 	skge_write32(hw, B0_IMSK, hw->intr_mask);
+	skge_read32(hw, B0_IMSK);
 	spin_unlock_irq(&hw->hw_lock);
 }
 
@@ -2955,6 +2956,7 @@ static irqreturn_t skge_intr(int irq, vo
 		skge_error_irq(hw);
 
 	skge_write32(hw, B0_IMSK, hw->intr_mask);
+	skge_read32(hw, B0_IMSK);
 	spin_unlock(&hw->hw_lock);
 
 	return IRQ_HANDLED;
@@ -3424,6 +3426,7 @@ static void __devexit skge_remove(struct
 	spin_lock_irq(&hw->hw_lock);
 	hw->intr_mask = 0;
 	skge_write32(hw, B0_IMSK, 0);
+	skge_read32(hw, B0_IMSK);
 	spin_unlock_irq(&hw->hw_lock);
 
 	skge_write16(hw, B0_LED, LED_STAT_OFF);

--
Stephen Hemminger <[email protected]>

#4 lore raw

PATCH 3/5 skge: use dev_alloc_skb

In reply to Stephen Hemminger

To avoid problems with buggy protocols that assume extra header space, use dev_alloc_skb() when allocating receive buffers.

drivers/net/skge.c +4 -3
@@ -827,7 +827,8 @@ static int skge_rx_fill(struct skge_port
 	do {
 		struct sk_buff *skb;
 
-		skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
+		skb = __dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN,
+				      GFP_KERNEL);
 		if (!skb)
 			return -ENOMEM;
 
@@ -2609,7 +2610,7 @@ static inline struct sk_buff *skge_rx_ge
 		goto error;
 
 	if (len < RX_COPY_THRESHOLD) {
-		skb = alloc_skb(len + 2, GFP_ATOMIC);
+		skb = dev_alloc_skb(len + 2);
 		if (!skb)
 			goto resubmit;
 
@@ -2624,7 +2625,7 @@ static inline struct sk_buff *skge_rx_ge
 		skge_rx_reuse(e, skge->rx_buf_size);
 	} else {
 		struct sk_buff *nskb;
-		nskb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_ATOMIC);
+		nskb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN);
 		if (!nskb)
 			goto resubmit;
 

--
Stephen Hemminger <[email protected]>

#5 lore raw

Re: [PATCH 3/5] skge: use dev_alloc_skb

Quoted 8 lines · Stephen Hemminger

To avoid problems with buggy protocols that assume extra header space, use dev_alloc_skb() when allocating receive buffers.

drivers/net/skge.c static int skge_rx_fill(struct skge_port · line 831

Quoted 6 lines
drivers/net/skge.c +2 -1
@@ -827,7 +827,8 @@ static int skge_rx_fill(struct skge_port
 	do {
 		struct sk_buff *skb;
 
-		skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
+		skb = __dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN,
+				      GFP_KERNEL);

While you're at it please use netdev_alloc_skb.

#6 lore raw

Re: [PATCH 3/5] skge: use dev_alloc_skb

Quoted 12 lines · On Tue, 29 Aug 2006 12:23:36 +0100 Christoph Hellwig <[email protected]> wrote:
Quoted 11 lines · Stephen Hemminger

To avoid problems with buggy protocols that assume extra header space, use dev_alloc_skb() when allocating receive buffers.

drivers/net/skge.c +0 -0
@@ -827,7 +827,8 @@ static int skge_rx_fill(struct skge_port
 	do {
 		struct sk_buff *skb;
 
Quoted 6 lines

drivers/net/skge.c static int skge_rx_fill(struct skge_port · line 831

Quoted 3 lines
drivers/net/skge.c +2 -1
-		skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
+		skb = __dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN,
+				      GFP_KERNEL);

While you're at it please use netdev_alloc_skb.

Okay, that will be in the next clump.

Signature · 1 line
Stephen Hemminger <[email protected]>
#7 lore raw

PATCH 4/5 skge: use ethX for irq assigments

In reply to Stephen Hemminger

The user level irq balance daemon uses "eth" as a way to distinquish ethernet devices. Also, by using device name it is possible to distinquish different boards.

drivers/net/skge.c +12 -13
@@ -3343,23 +3343,16 @@ static int __devinit skge_probe(struct p
 		goto err_out_free_hw;
 	}
 
-	err = request_irq(pdev->irq, skge_intr, IRQF_SHARED, DRV_NAME, hw);
-	if (err) {
-		printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
-		       pci_name(pdev), pdev->irq);
-		goto err_out_iounmap;
-	}
-	pci_set_drvdata(pdev, hw);
-
 	err = skge_reset(hw);
 	if (err)
-		goto err_out_free_irq;
+		goto err_out_iounmap;
 
 	printk(KERN_INFO PFX DRV_VERSION " addr 0x%llx irq %d chip %s rev %d\n",
 	       (unsigned long long)pci_resource_start(pdev, 0), pdev->irq,
 	       skge_board_name(hw), hw->chip_rev);
 
-	if ((dev = skge_devinit(hw, 0, using_dac)) == NULL)
+	dev = skge_devinit(hw, 0, using_dac);
+	if (!dev)
 		goto err_out_led_off;
 
 	if (!is_valid_ether_addr(dev->dev_addr)) {
@@ -3369,7 +3362,6 @@ static int __devinit skge_probe(struct p
 		goto err_out_free_netdev;
 	}
 
-
 	err = register_netdev(dev);
 	if (err) {
 		printk(KERN_ERR PFX "%s: cannot register net device\n",
@@ -3377,6 +3369,12 @@ static int __devinit skge_probe(struct p
 		goto err_out_free_netdev;
 	}
 
+	err = request_irq(pdev->irq, skge_intr, IRQF_SHARED, dev->name, hw);
+	if (err) {
+		printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
+		       dev->name, pdev->irq);
+		goto err_out_unregister;
+	}
 	skge_show_addr(dev);
 
 	if (hw->ports > 1 && (dev1 = skge_devinit(hw, 1, using_dac))) {
@@ -3389,15 +3387,16 @@ static int __devinit skge_probe(struct p
 			free_netdev(dev1);
 		}
 	}
+	pci_set_drvdata(pdev, hw);
 
 	return 0;
 
+err_out_unregister:
+	unregister_netdev(dev);
 err_out_free_netdev:
 	free_netdev(dev);
 err_out_led_off:
 	skge_write16(hw, B0_LED, LED_STAT_OFF);
-err_out_free_irq:
-	free_irq(pdev->irq, hw);
 err_out_iounmap:
 	iounmap(hw->regs);
 err_out_free_hw:

--
Stephen Hemminger <[email protected]>