]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] skge: fix SMP race
authorStephen Hemminger <shemminger@osdl.org>
Wed, 22 Feb 2006 21:52:35 +0000 (13:52 -0800)
committerChris Wright <chrisw@sous-sol.org>
Wed, 1 Mar 2006 22:36:37 +0000 (14:36 -0800)
If skge is attached to a bad cable, that goes up/down.
It exposes an SMP race with the management of IRQ mask

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
drivers/net/skge.c
drivers/net/skge.h

index f3294d00290c49c81f86a0bd6c4e1bd684095bee..6a4e055a3cb609468e9b5118e044cd9e4ce23231 100644 (file)
@@ -2182,8 +2182,10 @@ static int skge_up(struct net_device *dev)
        skge->tx_avail = skge->tx_ring.count - 1;
 
        /* Enable IRQ from port */
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask |= portirqmask[port];
        skge_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock_irq(&hw->hw_lock);
 
        /* Initialize MAC */
        spin_lock_bh(&hw->phy_lock);
@@ -2241,8 +2243,10 @@ static int skge_down(struct net_device *dev)
        else
                yukon_stop(skge);
 
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask &= ~portirqmask[skge->port];
        skge_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock_irq(&hw->hw_lock);
 
        /* Stop transmitter */
        skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP);
@@ -2698,10 +2702,11 @@ static int skge_poll(struct net_device *dev, int *budget)
        if (work_done >=  to_do)
                return 1; /* not done */
 
-       netif_rx_complete(dev);
-       hw->intr_mask |= portirqmask[skge->port];
-       skge_write32(hw, B0_IMSK, hw->intr_mask);
-       skge_read32(hw, B0_IMSK);
+       spin_lock_irq(&hw->hw_lock);
+       __netif_rx_complete(dev);
+       hw->intr_mask |= portirqmask[skge->port];
+       skge_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock_irq(&hw->hw_lock);
 
        return 0;
 }
@@ -2861,10 +2866,10 @@ static void skge_extirq(unsigned long data)
        }
        spin_unlock(&hw->phy_lock);
 
-       local_irq_disable();
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask |= IS_EXT_REG;
        skge_write32(hw, B0_IMSK, hw->intr_mask);
-       local_irq_enable();
+       spin_unlock_irq(&hw->hw_lock);
 }
 
 static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
@@ -2875,7 +2880,7 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
        if (status == 0 || status == ~0) /* hotplug or shared irq */
                return IRQ_NONE;
 
-       status &= hw->intr_mask;
+       spin_lock(&hw->hw_lock);
        if (status & IS_R1_F) {
                skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F);
                hw->intr_mask &= ~IS_R1_F;
@@ -2927,6 +2932,7 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
        }
 
        skge_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock(&hw->hw_lock);
 
        return IRQ_HANDLED;
 }
@@ -3285,6 +3291,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 
        hw->pdev = pdev;
        spin_lock_init(&hw->phy_lock);
+       spin_lock_init(&hw->hw_lock);
        tasklet_init(&hw->ext_tasklet, skge_extirq, (unsigned long) hw);
 
        hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
index ee123c15f5450947f874bcd3b5963ba61f1dc98f..29d9ecbf625198a2d63e14731792a972d03d2c86 100644 (file)
@@ -2473,6 +2473,7 @@ struct skge_hw {
 
        struct tasklet_struct ext_tasklet;
        spinlock_t           phy_lock;
+       spinlock_t           hw_lock;
 };
 
 enum {