Commit efc82eee authored by Doug Ledford's avatar Doug Ledford

IB/ipoib: No longer use flush as a parameter

Various places in the IPoIB code had a deadlock related to flushing
the ipoib workqueue.  Now that we have per device workqueues and a
specific flush workqueue, there is no longer a deadlock issue with
flushing the device specific workqueues and we can do so unilaterally.
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 0b39578b
...@@ -478,10 +478,10 @@ void ipoib_ib_dev_flush_heavy(struct work_struct *work); ...@@ -478,10 +478,10 @@ void ipoib_ib_dev_flush_heavy(struct work_struct *work);
void ipoib_pkey_event(struct work_struct *work); void ipoib_pkey_event(struct work_struct *work);
void ipoib_ib_dev_cleanup(struct net_device *dev); void ipoib_ib_dev_cleanup(struct net_device *dev);
int ipoib_ib_dev_open(struct net_device *dev, int flush); int ipoib_ib_dev_open(struct net_device *dev);
int ipoib_ib_dev_up(struct net_device *dev); int ipoib_ib_dev_up(struct net_device *dev);
int ipoib_ib_dev_down(struct net_device *dev, int flush); int ipoib_ib_dev_down(struct net_device *dev);
int ipoib_ib_dev_stop(struct net_device *dev, int flush); int ipoib_ib_dev_stop(struct net_device *dev);
void ipoib_pkey_dev_check_presence(struct net_device *dev); void ipoib_pkey_dev_check_presence(struct net_device *dev);
int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
...@@ -493,7 +493,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb); ...@@ -493,7 +493,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb);
void ipoib_mcast_restart_task(struct work_struct *work); void ipoib_mcast_restart_task(struct work_struct *work);
int ipoib_mcast_start_thread(struct net_device *dev); int ipoib_mcast_start_thread(struct net_device *dev);
int ipoib_mcast_stop_thread(struct net_device *dev, int flush); int ipoib_mcast_stop_thread(struct net_device *dev);
void ipoib_mcast_dev_down(struct net_device *dev); void ipoib_mcast_dev_down(struct net_device *dev);
void ipoib_mcast_dev_flush(struct net_device *dev); void ipoib_mcast_dev_flush(struct net_device *dev);
......
...@@ -659,22 +659,21 @@ void ipoib_reap_ah(struct work_struct *work) ...@@ -659,22 +659,21 @@ void ipoib_reap_ah(struct work_struct *work)
round_jiffies_relative(HZ)); round_jiffies_relative(HZ));
} }
static void ipoib_flush_ah(struct net_device *dev, int flush) static void ipoib_flush_ah(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
cancel_delayed_work(&priv->ah_reap_task); cancel_delayed_work(&priv->ah_reap_task);
if (flush) flush_workqueue(priv->wq);
flush_workqueue(priv->wq);
ipoib_reap_ah(&priv->ah_reap_task.work); ipoib_reap_ah(&priv->ah_reap_task.work);
} }
static void ipoib_stop_ah(struct net_device *dev, int flush) static void ipoib_stop_ah(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
set_bit(IPOIB_STOP_REAPER, &priv->flags); set_bit(IPOIB_STOP_REAPER, &priv->flags);
ipoib_flush_ah(dev, flush); ipoib_flush_ah(dev);
} }
static void ipoib_ib_tx_timer_func(unsigned long ctx) static void ipoib_ib_tx_timer_func(unsigned long ctx)
...@@ -682,7 +681,7 @@ static void ipoib_ib_tx_timer_func(unsigned long ctx) ...@@ -682,7 +681,7 @@ static void ipoib_ib_tx_timer_func(unsigned long ctx)
drain_tx_cq((struct net_device *)ctx); drain_tx_cq((struct net_device *)ctx);
} }
int ipoib_ib_dev_open(struct net_device *dev, int flush) int ipoib_ib_dev_open(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
int ret; int ret;
...@@ -724,7 +723,7 @@ int ipoib_ib_dev_open(struct net_device *dev, int flush) ...@@ -724,7 +723,7 @@ int ipoib_ib_dev_open(struct net_device *dev, int flush)
dev_stop: dev_stop:
if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
napi_enable(&priv->napi); napi_enable(&priv->napi);
ipoib_ib_dev_stop(dev, flush); ipoib_ib_dev_stop(dev);
return -1; return -1;
} }
...@@ -756,7 +755,7 @@ int ipoib_ib_dev_up(struct net_device *dev) ...@@ -756,7 +755,7 @@ int ipoib_ib_dev_up(struct net_device *dev)
return ipoib_mcast_start_thread(dev); return ipoib_mcast_start_thread(dev);
} }
int ipoib_ib_dev_down(struct net_device *dev, int flush) int ipoib_ib_dev_down(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
...@@ -765,7 +764,7 @@ int ipoib_ib_dev_down(struct net_device *dev, int flush) ...@@ -765,7 +764,7 @@ int ipoib_ib_dev_down(struct net_device *dev, int flush)
clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags); clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
netif_carrier_off(dev); netif_carrier_off(dev);
ipoib_mcast_stop_thread(dev, flush); ipoib_mcast_stop_thread(dev);
ipoib_mcast_dev_flush(dev); ipoib_mcast_dev_flush(dev);
ipoib_flush_paths(dev); ipoib_flush_paths(dev);
...@@ -825,7 +824,7 @@ void ipoib_drain_cq(struct net_device *dev) ...@@ -825,7 +824,7 @@ void ipoib_drain_cq(struct net_device *dev)
local_bh_enable(); local_bh_enable();
} }
int ipoib_ib_dev_stop(struct net_device *dev, int flush) int ipoib_ib_dev_stop(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
struct ib_qp_attr qp_attr; struct ib_qp_attr qp_attr;
...@@ -895,7 +894,7 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush) ...@@ -895,7 +894,7 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush)
if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
ipoib_warn(priv, "Failed to modify QP to RESET state\n"); ipoib_warn(priv, "Failed to modify QP to RESET state\n");
ipoib_flush_ah(dev, flush); ipoib_flush_ah(dev);
ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP); ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP);
...@@ -919,7 +918,7 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port) ...@@ -919,7 +918,7 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
(unsigned long) dev); (unsigned long) dev);
if (dev->flags & IFF_UP) { if (dev->flags & IFF_UP) {
if (ipoib_ib_dev_open(dev, 1)) { if (ipoib_ib_dev_open(dev)) {
ipoib_transport_dev_cleanup(dev); ipoib_transport_dev_cleanup(dev);
return -ENODEV; return -ENODEV;
} }
...@@ -1038,16 +1037,16 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, ...@@ -1038,16 +1037,16 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
if (level == IPOIB_FLUSH_LIGHT) { if (level == IPOIB_FLUSH_LIGHT) {
ipoib_mark_paths_invalid(dev); ipoib_mark_paths_invalid(dev);
ipoib_mcast_dev_flush(dev); ipoib_mcast_dev_flush(dev);
ipoib_flush_ah(dev, 0); ipoib_flush_ah(dev);
} }
if (level >= IPOIB_FLUSH_NORMAL) if (level >= IPOIB_FLUSH_NORMAL)
ipoib_ib_dev_down(dev, 0); ipoib_ib_dev_down(dev);
if (level == IPOIB_FLUSH_HEAVY) { if (level == IPOIB_FLUSH_HEAVY) {
if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
ipoib_ib_dev_stop(dev, 0); ipoib_ib_dev_stop(dev);
if (ipoib_ib_dev_open(dev, 0) != 0) if (ipoib_ib_dev_open(dev) != 0)
return; return;
if (netif_queue_stopped(dev)) if (netif_queue_stopped(dev))
netif_start_queue(dev); netif_start_queue(dev);
...@@ -1099,7 +1098,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev) ...@@ -1099,7 +1098,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
*/ */
ipoib_flush_paths(dev); ipoib_flush_paths(dev);
ipoib_mcast_stop_thread(dev, 1); ipoib_mcast_stop_thread(dev);
ipoib_mcast_dev_flush(dev); ipoib_mcast_dev_flush(dev);
/* /*
...@@ -1108,7 +1107,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev) ...@@ -1108,7 +1107,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
* the neighbor garbage collection is stopped and reaped. * the neighbor garbage collection is stopped and reaped.
* That should all be done now, so make a final ah flush. * That should all be done now, so make a final ah flush.
*/ */
ipoib_stop_ah(dev, 1); ipoib_stop_ah(dev);
ipoib_transport_dev_cleanup(dev); ipoib_transport_dev_cleanup(dev);
} }
......
...@@ -108,7 +108,7 @@ int ipoib_open(struct net_device *dev) ...@@ -108,7 +108,7 @@ int ipoib_open(struct net_device *dev)
set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
if (ipoib_ib_dev_open(dev, 1)) { if (ipoib_ib_dev_open(dev)) {
if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags))
return 0; return 0;
goto err_disable; goto err_disable;
...@@ -139,7 +139,7 @@ int ipoib_open(struct net_device *dev) ...@@ -139,7 +139,7 @@ int ipoib_open(struct net_device *dev)
return 0; return 0;
err_stop: err_stop:
ipoib_ib_dev_stop(dev, 1); ipoib_ib_dev_stop(dev);
err_disable: err_disable:
clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
...@@ -157,8 +157,8 @@ static int ipoib_stop(struct net_device *dev) ...@@ -157,8 +157,8 @@ static int ipoib_stop(struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
ipoib_ib_dev_down(dev, 1); ipoib_ib_dev_down(dev);
ipoib_ib_dev_stop(dev, 0); ipoib_ib_dev_stop(dev);
if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
struct ipoib_dev_priv *cpriv; struct ipoib_dev_priv *cpriv;
......
...@@ -613,7 +613,7 @@ int ipoib_mcast_start_thread(struct net_device *dev) ...@@ -613,7 +613,7 @@ int ipoib_mcast_start_thread(struct net_device *dev)
return 0; return 0;
} }
int ipoib_mcast_stop_thread(struct net_device *dev, int flush) int ipoib_mcast_stop_thread(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
...@@ -624,8 +624,7 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush) ...@@ -624,8 +624,7 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
cancel_delayed_work(&priv->mcast_task); cancel_delayed_work(&priv->mcast_task);
mutex_unlock(&mcast_mutex); mutex_unlock(&mcast_mutex);
if (flush) flush_workqueue(priv->wq);
flush_workqueue(priv->wq);
return 0; return 0;
} }
...@@ -797,7 +796,18 @@ void ipoib_mcast_restart_task(struct work_struct *work) ...@@ -797,7 +796,18 @@ void ipoib_mcast_restart_task(struct work_struct *work)
ipoib_dbg_mcast(priv, "restarting multicast task\n"); ipoib_dbg_mcast(priv, "restarting multicast task\n");
ipoib_mcast_stop_thread(dev, 0); /*
* We're running on the priv->wq right now, so we can't call
* mcast_stop_thread as it wants to flush the wq and that
* will deadlock. We don't actually *need* to stop the
* thread here anyway, so just clear the run flag, cancel
* any delayed work, do our work, remove the old entries,
* then restart the thread.
*/
mutex_lock(&mcast_mutex);
clear_bit(IPOIB_MCAST_RUN, &priv->flags);
cancel_delayed_work(&priv->mcast_task);
mutex_unlock(&mcast_mutex);
local_irq_save(flags); local_irq_save(flags);
netif_addr_lock(dev); netif_addr_lock(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment