From: Erez Shitrit Date: Tue, 8 Jul 2014 09:45:12 +0000 (+0300) Subject: IB/ipoib: Avoid flushing the workqueue from worker context X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=4eae374845affc3ebf8ccfc38d554a86adc95003;p=linux-beck.git IB/ipoib: Avoid flushing the workqueue from worker context The error flow of ipoib_ib_dev_open() invokes ipoib_ib_dev_stop() with workqueue flushing enabled, which deadlocks if the open procedure itself was called by a worker thread. Fix this by adding a flush enabled flag to ipoib_ib_dev_open() and set it accordingly from the locations where such a call is made. The call trace was the following: [] ? flush_workqueue+0x54/0x80 [] ? ipoib_ib_dev_stop+0x447/0x650 [ib_ipoib] [] ? ipoib_ib_dev_open+0x284/0x430 [ib_ipoib] [] ? ipoib_open+0x78/0x1d0 [ib_ipoib] [] ? ipoib_pkey_open+0x38/0x40 [ib_ipoib] [] ? __ipoib_ib_dev_flush+0x15c/0x2c0 [ib_ipoib] [] ? __ipoib_ib_dev_flush+0x76/0x2c0 [ib_ipoib] [] ? ipoib_ib_dev_flush_heavy+0x0/0x20 [ib_ipoib] [] ? ipoib_ib_dev_flush_heavy+0x1a/0x20 [ib_ipoib] [] ? worker_thread+0x170/0x2a0 [] ? autoremove_wake_function+0x0/0x40 Signed-off-by: Erez Shitrit Signed-off-by: Or Gerlitz Acked-by: Alex Estrin Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index 683d23ac7cbf..3edce617c31b 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h @@ -471,7 +471,7 @@ void ipoib_ib_dev_flush_heavy(struct work_struct *work); void ipoib_pkey_event(struct work_struct *work); void ipoib_ib_dev_cleanup(struct net_device *dev); -int ipoib_ib_dev_open(struct net_device *dev); +int ipoib_ib_dev_open(struct net_device *dev, int flush); int ipoib_ib_dev_up(struct net_device *dev); int ipoib_ib_dev_down(struct net_device *dev, int flush); int ipoib_ib_dev_stop(struct net_device *dev, int flush); diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index be8f971edbec..9dcb2c9e758a 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -664,7 +664,7 @@ static void ipoib_ib_tx_timer_func(unsigned long ctx) drain_tx_cq((struct net_device *)ctx); } -int ipoib_ib_dev_open(struct net_device *dev) +int ipoib_ib_dev_open(struct net_device *dev, int flush) { struct ipoib_dev_priv *priv = netdev_priv(dev); int ret; @@ -705,7 +705,7 @@ int ipoib_ib_dev_open(struct net_device *dev) dev_stop: if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) napi_enable(&priv->napi); - ipoib_ib_dev_stop(dev, 1); + ipoib_ib_dev_stop(dev, flush); return -1; } @@ -916,7 +916,7 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port) (unsigned long) dev); if (dev->flags & IFF_UP) { - if (ipoib_ib_dev_open(dev)) { + if (ipoib_ib_dev_open(dev, 1)) { ipoib_transport_dev_cleanup(dev); return -ENODEV; } @@ -1033,7 +1033,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, if (level == IPOIB_FLUSH_HEAVY) { ipoib_ib_dev_stop(dev, 0); - ipoib_ib_dev_open(dev); + ipoib_ib_dev_open(dev, 0); } /* diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 35acbd41a5f7..1bf994a96860 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -114,7 +114,7 @@ int ipoib_open(struct net_device *dev) if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) return 0; - if (ipoib_ib_dev_open(dev)) + if (ipoib_ib_dev_open(dev, 1)) goto err_disable; if (ipoib_ib_dev_up(dev))