Skip to content

Commit

Permalink
IB/ipoib: replace local_irq_disable() with proper locking
Browse files Browse the repository at this point in the history
In ipoib_mcast_restart_task() the netif_addr_lock() is invoked prior
local_irq_save(). netif_addr_lock() should not be invoked in interrupt disabled
section, only in BH disabled sections.
The priv->lock is always acquired with disabled interrupts. The only place
where netif_addr_lock() and priv->lock nest ist ipoib_mcast_restart_task().

Drop the local_irq_save() and acquire priv->lock with spin_lock_irq() inside
the netif_addr locked section. It's safe to do so because the caller is either
a worker function or __ipoib_ib_dev_flush() which are both calling with
interrupts enabled (and since BH is enabled here, too so
netif_addr_lock_bh() needs to be used).

Cc: Doug Ledford <dledford@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Sebastian Andrzej Siewior authored and Jason Gunthorpe committed May 17, 2018
1 parent e818e25 commit 112f5c8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions drivers/infiniband/ulp/ipoib/ipoib_multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,6 @@ void ipoib_mcast_restart_task(struct work_struct *work)
struct netdev_hw_addr *ha;
struct ipoib_mcast *mcast, *tmcast;
LIST_HEAD(remove_list);
unsigned long flags;
struct ib_sa_mcmember_rec rec;

if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags))
Expand All @@ -898,9 +897,8 @@ void ipoib_mcast_restart_task(struct work_struct *work)

ipoib_dbg_mcast(priv, "restarting multicast task\n");

local_irq_save(flags);
netif_addr_lock(dev);
spin_lock(&priv->lock);
netif_addr_lock_bh(dev);
spin_lock_irq(&priv->lock);

/*
* Unfortunately, the networking core only gives us a list of all of
Expand Down Expand Up @@ -978,19 +976,18 @@ void ipoib_mcast_restart_task(struct work_struct *work)
}
}

spin_unlock(&priv->lock);
netif_addr_unlock(dev);
local_irq_restore(flags);
spin_unlock_irq(&priv->lock);
netif_addr_unlock_bh(dev);

ipoib_mcast_remove_list(&remove_list);

/*
* Double check that we are still up
*/
if (test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) {
spin_lock_irqsave(&priv->lock, flags);
spin_lock_irq(&priv->lock);
__ipoib_mcast_schedule_join_thread(priv, NULL, 0);
spin_unlock_irqrestore(&priv->lock, flags);
spin_unlock_irq(&priv->lock);
}
}

Expand Down

0 comments on commit 112f5c8

Please sign in to comment.