Skip to content

Commit

Permalink
skge: protect interrupt mask
Browse files Browse the repository at this point in the history
There is a race between updating the irq mask and setting it
which can be triggered on SMP with a bad cable.
Similar patch from Ingo Molnar and Thomas Gleixner

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
  • Loading branch information
Stephen Hemminger authored and Francois Romieu committed Feb 23, 2006
1 parent 0781191 commit 80dd857
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions drivers/net/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,8 +2185,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);
Expand Down Expand Up @@ -2244,8 +2246,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);
Expand Down Expand Up @@ -2701,10 +2705,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;
}
Expand Down Expand Up @@ -2864,10 +2869,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)
Expand All @@ -2878,7 +2883,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;
Expand Down Expand Up @@ -2930,6 +2935,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;
}
Expand Down Expand Up @@ -3298,6 +3304,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);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/skge.h
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,7 @@ struct skge_hw {

struct tasklet_struct ext_tasklet;
spinlock_t phy_lock;
spinlock_t hw_lock;
};

enum {
Expand Down

0 comments on commit 80dd857

Please sign in to comment.