Skip to content

Commit

Permalink
sky2: fix hang in napi_disable
Browse files Browse the repository at this point in the history
If IRQ was never initialized, then calling napi_disable() would hang.
Add more bookkeeping to track whether IRQ was ever initialized.

Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
stephen hemminger authored and davem330 committed Nov 18, 2011
1 parent 738a849 commit 282edce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions drivers/net/ethernet/marvell/sky2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,8 @@ static int sky2_setup_irq(struct sky2_hw *hw, const char *name)
if (err)
dev_err(&pdev->dev, "cannot assign irq %d\n", pdev->irq);
else {
hw->flags |= SKY2_HW_IRQ_SETUP;

napi_enable(&hw->napi);
sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
sky2_read32(hw, B0_IMSK);
Expand Down Expand Up @@ -2120,6 +2122,7 @@ static int sky2_close(struct net_device *dev)

napi_disable(&hw->napi);
free_irq(hw->pdev->irq, hw);
hw->flags &= ~SKY2_HW_IRQ_SETUP;
} else {
u32 imask;

Expand Down Expand Up @@ -3423,12 +3426,13 @@ static void sky2_all_down(struct sky2_hw *hw)
{
int i;

sky2_read32(hw, B0_IMSK);
sky2_write32(hw, B0_IMSK, 0);
if (hw->flags & SKY2_HW_IRQ_SETUP) {
sky2_read32(hw, B0_IMSK);
sky2_write32(hw, B0_IMSK, 0);

if (hw->ports > 1 || netif_running(hw->dev[0]))
synchronize_irq(hw->pdev->irq);
napi_disable(&hw->napi);
napi_disable(&hw->napi);
}

for (i = 0; i < hw->ports; i++) {
struct net_device *dev = hw->dev[i];
Expand All @@ -3445,7 +3449,7 @@ static void sky2_all_down(struct sky2_hw *hw)

static void sky2_all_up(struct sky2_hw *hw)
{
u32 imask = 0;
u32 imask = Y2_IS_BASE;
int i;

for (i = 0; i < hw->ports; i++) {
Expand All @@ -3461,8 +3465,7 @@ static void sky2_all_up(struct sky2_hw *hw)
netif_wake_queue(dev);
}

if (imask || hw->ports > 1) {
imask |= Y2_IS_BASE;
if (hw->flags & SKY2_HW_IRQ_SETUP) {
sky2_write32(hw, B0_IMSK, imask);
sky2_read32(hw, B0_IMSK);
sky2_read32(hw, B0_Y2_SP_LISR);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/marvell/sky2.h
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,7 @@ struct sky2_hw {
#define SKY2_HW_RSS_BROKEN 0x00000100
#define SKY2_HW_VLAN_BROKEN 0x00000200
#define SKY2_HW_RSS_CHKSUM 0x00000400 /* RSS requires chksum */
#define SKY2_HW_IRQ_SETUP 0x00000800

u8 chip_id;
u8 chip_rev;
Expand Down

0 comments on commit 282edce

Please sign in to comment.