Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b3ea082 authored by Jack Morgenstein's avatar Jack Morgenstein Committed by Roland Dreier
Browse files

IPoIB: Move ipoib_ib_dev_flush() to ipoib workqueue



Move ipoib_ib_dev_flush() to ipoib's workqueue.  This keeps it ordered
with respect to other work scheduled by the ipoib driver.  This fixes
problems with races, for example:
 - ipoib_ib_dev_flush() has started running because of an IB event
 - user does ifconfig ib0 down
 - ipoib_mcast_stop_thread() gets called twice and waits for the same
   completion twice

Signed-off-by: default avatarJack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: default avatarMichael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 8b9ab02b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev);

int ipoib_ib_dev_open(struct net_device *dev);
int ipoib_ib_dev_up(struct net_device *dev);
int ipoib_ib_dev_down(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 ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
+5 −4
Original line number Diff line number Diff line
@@ -435,7 +435,7 @@ int ipoib_ib_dev_up(struct net_device *dev)
	return ipoib_mcast_start_thread(dev);
}

int ipoib_ib_dev_down(struct net_device *dev)
int ipoib_ib_dev_down(struct net_device *dev, int flush)
{
	struct ipoib_dev_priv *priv = netdev_priv(dev);

@@ -450,10 +450,11 @@ int ipoib_ib_dev_down(struct net_device *dev)
		set_bit(IPOIB_PKEY_STOP, &priv->flags);
		cancel_delayed_work(&priv->pkey_task);
		mutex_unlock(&pkey_mutex);
		if (flush)
			flush_workqueue(ipoib_workqueue);
	}

	ipoib_mcast_stop_thread(dev, 1);
	ipoib_mcast_stop_thread(dev, flush);
	ipoib_mcast_dev_flush(dev);

	ipoib_flush_paths(dev);
@@ -591,7 +592,7 @@ void ipoib_ib_dev_flush(void *_dev)

	ipoib_dbg(priv, "flushing\n");

	ipoib_ib_dev_down(dev);
	ipoib_ib_dev_down(dev, 0);

	/*
	 * The device could have been brought down between the start and when
+7 −1
Original line number Diff line number Diff line
@@ -133,7 +133,13 @@ static int ipoib_stop(struct net_device *dev)

	netif_stop_queue(dev);

	ipoib_ib_dev_down(dev);
	/*
	 * Now flush workqueue to make sure a scheduled task doesn't
	 * bring our internal state back up.
	 */
	flush_workqueue(ipoib_workqueue);

	ipoib_ib_dev_down(dev, 1);
	ipoib_ib_dev_stop(dev);

	if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
+1 −1
Original line number Diff line number Diff line
@@ -255,6 +255,6 @@ void ipoib_event(struct ib_event_handler *handler,
	    record->event == IB_EVENT_LID_CHANGE  ||
	    record->event == IB_EVENT_SM_CHANGE) {
		ipoib_dbg(priv, "Port active event\n");
		schedule_work(&priv->flush_task);
		queue_work(ipoib_workqueue, &priv->flush_task);
	}
}