+ /*
+ * make sure the in-flight joins have finished before we attempt
+ * to leave
+ */
+ list_for_each_entry_safe(mcast, tmcast, &remove_list, list)
+ if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
+ wait_for_completion(&mcast->done);
+
+ /*
+ * We have to cancel outside of the spinlock, but we have to
+ * take the rtnl lock or else we race with the removal of
+ * entries from the remove list in mcast_dev_flush as part
+ * of ipoib_stop() which will call mcast_stop_thread with
+ * flush == 1 while holding the rtnl lock, and the
+ * flush_workqueue won't complete until this restart_mcast_task
+ * completes. So do like the carrier on task and attempt to
+ * take the rtnl lock, but if we can't before the ADMIN_UP flag
+ * goes away, then just return and know that the remove list will
+ * get flushed later by mcast_dev_flush.
+ */
+ while (!rtnl_trylock()) {
+ if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
+ return;
+ else
+ msleep(20);
+ }