Commit 501d857e authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

[IEEE80211]: Fix softmac lockdep reports.

It seems I was actually able to hit this deadlock, on my quad G5 softmac
locks up more often than not. This fixes it by using an own workqueue
that can safely be flushed under RTNL.

Not sure if the patch is correct with the workqueue naming. And don't
think with the patch it doesn't continually lock up. It still does, just
doesn't invoke lockdep warnings all the time.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 05155c83
...@@ -229,6 +229,8 @@ struct ieee80211softmac_device { ...@@ -229,6 +229,8 @@ struct ieee80211softmac_device {
/* this lock protects this structure */ /* this lock protects this structure */
spinlock_t lock; spinlock_t lock;
struct workqueue_struct *wq;
u8 running; /* SoftMAC started? */ u8 running; /* SoftMAC started? */
u8 scanning; u8 scanning;
......
...@@ -53,7 +53,7 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft ...@@ -53,7 +53,7 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft
/* Set a timer for timeout */ /* Set a timer for timeout */
/* FIXME: make timeout configurable */ /* FIXME: make timeout configurable */
if (likely(mac->running)) if (likely(mac->running))
schedule_delayed_work(&mac->associnfo.timeout, 5 * HZ); queue_delayed_work(mac->wq, &mac->associnfo.timeout, 5 * HZ);
spin_unlock_irqrestore(&mac->lock, flags); spin_unlock_irqrestore(&mac->lock, flags);
} }
...@@ -419,7 +419,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev, ...@@ -419,7 +419,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
network->authenticated = 0; network->authenticated = 0;
/* we don't want to do this more than once ... */ /* we don't want to do this more than once ... */
network->auth_desynced_once = 1; network->auth_desynced_once = 1;
schedule_delayed_work(&mac->associnfo.work, 0); queue_delayed_work(mac->wq, &mac->associnfo.work, 0);
break; break;
} }
default: default:
...@@ -441,7 +441,7 @@ ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac) ...@@ -441,7 +441,7 @@ ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac)
spin_lock_irqsave(&mac->lock, flags); spin_lock_irqsave(&mac->lock, flags);
mac->associnfo.associating = 1; mac->associnfo.associating = 1;
schedule_delayed_work(&mac->associnfo.work, 0); queue_delayed_work(mac->wq, &mac->associnfo.work, 0);
spin_unlock_irqrestore(&mac->lock, flags); spin_unlock_irqrestore(&mac->lock, flags);
} }
...@@ -483,7 +483,7 @@ ieee80211softmac_handle_reassoc_req(struct net_device * dev, ...@@ -483,7 +483,7 @@ ieee80211softmac_handle_reassoc_req(struct net_device * dev,
dprintkl(KERN_INFO PFX "reassoc request from unknown network\n"); dprintkl(KERN_INFO PFX "reassoc request from unknown network\n");
return 0; return 0;
} }
schedule_delayed_work(&mac->associnfo.work, 0); queue_delayed_work(mac->wq, &mac->associnfo.work, 0);
return 0; return 0;
} }
...@@ -62,7 +62,7 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, ...@@ -62,7 +62,7 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
/* add to list */ /* add to list */
list_add_tail(&auth->list, &mac->auth_queue); list_add_tail(&auth->list, &mac->auth_queue);
schedule_delayed_work(&auth->work, 0); queue_delayed_work(mac->wq, &auth->work, 0);
spin_unlock_irqrestore(&mac->lock, flags); spin_unlock_irqrestore(&mac->lock, flags);
return 0; return 0;
...@@ -97,7 +97,7 @@ ieee80211softmac_auth_queue(struct work_struct *work) ...@@ -97,7 +97,7 @@ ieee80211softmac_auth_queue(struct work_struct *work)
} }
net->authenticated = 0; net->authenticated = 0;
/* add a timeout call so we eventually give up waiting for an auth reply */ /* add a timeout call so we eventually give up waiting for an auth reply */
schedule_delayed_work(&auth->work, IEEE80211SOFTMAC_AUTH_TIMEOUT); queue_delayed_work(mac->wq, &auth->work, IEEE80211SOFTMAC_AUTH_TIMEOUT);
auth->retry--; auth->retry--;
spin_unlock_irqrestore(&mac->lock, flags); spin_unlock_irqrestore(&mac->lock, flags);
if (ieee80211softmac_send_mgt_frame(mac, auth->net, IEEE80211_STYPE_AUTH, auth->state)) if (ieee80211softmac_send_mgt_frame(mac, auth->net, IEEE80211_STYPE_AUTH, auth->state))
...@@ -242,7 +242,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth) ...@@ -242,7 +242,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
* request. */ * request. */
cancel_delayed_work(&aq->work); cancel_delayed_work(&aq->work);
INIT_DELAYED_WORK(&aq->work, &ieee80211softmac_auth_challenge_response); INIT_DELAYED_WORK(&aq->work, &ieee80211softmac_auth_challenge_response);
schedule_delayed_work(&aq->work, 0); queue_delayed_work(mac->wq, &aq->work, 0);
spin_unlock_irqrestore(&mac->lock, flags); spin_unlock_irqrestore(&mac->lock, flags);
return 0; return 0;
case IEEE80211SOFTMAC_AUTH_SHARED_PASS: case IEEE80211SOFTMAC_AUTH_SHARED_PASS:
...@@ -408,6 +408,6 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de ...@@ -408,6 +408,6 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de
ieee80211softmac_deauth_from_net(mac, net); ieee80211softmac_deauth_from_net(mac, net);
/* let's try to re-associate */ /* let's try to re-associate */
schedule_delayed_work(&mac->associnfo.work, 0); queue_delayed_work(mac->wq, &mac->associnfo.work, 0);
return 0; return 0;
} }
...@@ -172,7 +172,7 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve ...@@ -172,7 +172,7 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
/* User may have subscribed to ANY event, so /* User may have subscribed to ANY event, so
* we tell them which event triggered it. */ * we tell them which event triggered it. */
eventptr->event_type = event; eventptr->event_type = event;
schedule_delayed_work(&eventptr->work, 0); queue_delayed_work(mac->wq, &eventptr->work, 0);
} }
} }
} }
......
...@@ -36,8 +36,13 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv) ...@@ -36,8 +36,13 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
dev = alloc_ieee80211(sizeof(*softmac) + sizeof_priv); dev = alloc_ieee80211(sizeof(*softmac) + sizeof_priv);
if (!dev) if (!dev)
return NULL; return NULL;
softmac = ieee80211_priv(dev); softmac = ieee80211_priv(dev);
softmac->wq = create_freezeable_workqueue("softmac");
if (!softmac->wq) {
free_ieee80211(dev);
return NULL;
}
softmac->dev = dev; softmac->dev = dev;
softmac->ieee = netdev_priv(dev); softmac->ieee = netdev_priv(dev);
spin_lock_init(&softmac->lock); spin_lock_init(&softmac->lock);
...@@ -105,7 +110,7 @@ ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm) ...@@ -105,7 +110,7 @@ ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm)
cancel_delayed_work(&eventptr->work); cancel_delayed_work(&eventptr->work);
spin_unlock_irqrestore(&sm->lock, flags); spin_unlock_irqrestore(&sm->lock, flags);
flush_scheduled_work(); flush_workqueue(sm->wq);
/* now we should be save and no longer need locking... */ /* now we should be save and no longer need locking... */
spin_lock_irqsave(&sm->lock, flags); spin_lock_irqsave(&sm->lock, flags);
...@@ -139,6 +144,7 @@ void free_ieee80211softmac(struct net_device *dev) ...@@ -139,6 +144,7 @@ void free_ieee80211softmac(struct net_device *dev)
ieee80211softmac_clear_pending_work(sm); ieee80211softmac_clear_pending_work(sm);
kfree(sm->scaninfo); kfree(sm->scaninfo);
kfree(sm->wpa.IE); kfree(sm->wpa.IE);
destroy_workqueue(sm->wq);
free_ieee80211(dev); free_ieee80211(dev);
} }
EXPORT_SYMBOL_GPL(free_ieee80211softmac); EXPORT_SYMBOL_GPL(free_ieee80211softmac);
......
...@@ -123,7 +123,7 @@ void ieee80211softmac_scan(struct work_struct *work) ...@@ -123,7 +123,7 @@ void ieee80211softmac_scan(struct work_struct *work)
spin_unlock_irqrestore(&sm->lock, flags); spin_unlock_irqrestore(&sm->lock, flags);
break; break;
} }
schedule_delayed_work(&si->softmac_scan, IEEE80211SOFTMAC_PROBE_DELAY); queue_delayed_work(sm->wq, &si->softmac_scan, IEEE80211SOFTMAC_PROBE_DELAY);
spin_unlock_irqrestore(&sm->lock, flags); spin_unlock_irqrestore(&sm->lock, flags);
return; return;
} else { } else {
...@@ -190,7 +190,7 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev) ...@@ -190,7 +190,7 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev)
sm->scaninfo->started = 1; sm->scaninfo->started = 1;
sm->scaninfo->stop = 0; sm->scaninfo->stop = 0;
INIT_COMPLETION(sm->scaninfo->finished); INIT_COMPLETION(sm->scaninfo->finished);
schedule_delayed_work(&sm->scaninfo->softmac_scan, 0); queue_delayed_work(sm->wq, &sm->scaninfo->softmac_scan, 0);
spin_unlock_irqrestore(&sm->lock, flags); spin_unlock_irqrestore(&sm->lock, flags);
return 0; return 0;
} }
......
...@@ -91,7 +91,7 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev, ...@@ -91,7 +91,7 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
/* We must unlock to avoid deadlocks with the assoc workqueue /* We must unlock to avoid deadlocks with the assoc workqueue
* on the associnfo.mutex */ * on the associnfo.mutex */
mutex_unlock(&sm->associnfo.mutex); mutex_unlock(&sm->associnfo.mutex);
flush_scheduled_work(); flush_workqueue(sm->wq);
/* Avoid race! Check assoc status again. Maybe someone started an /* Avoid race! Check assoc status again. Maybe someone started an
* association while we flushed. */ * association while we flushed. */
goto check_assoc_again; goto check_assoc_again;
...@@ -114,7 +114,7 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev, ...@@ -114,7 +114,7 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
sm->associnfo.associating = 1; sm->associnfo.associating = 1;
/* queue lower level code to do work (if necessary) */ /* queue lower level code to do work (if necessary) */
schedule_delayed_work(&sm->associnfo.work, 0); queue_delayed_work(sm->wq, &sm->associnfo.work, 0);
mutex_unlock(&sm->associnfo.mutex); mutex_unlock(&sm->associnfo.mutex);
...@@ -349,7 +349,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev, ...@@ -349,7 +349,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
/* force reassociation */ /* force reassociation */
mac->associnfo.bssvalid = 0; mac->associnfo.bssvalid = 0;
if (mac->associnfo.associated) if (mac->associnfo.associated)
schedule_delayed_work(&mac->associnfo.work, 0); queue_delayed_work(mac->wq, &mac->associnfo.work, 0);
} else if (is_zero_ether_addr(data->ap_addr.sa_data)) { } else if (is_zero_ether_addr(data->ap_addr.sa_data)) {
/* the bssid we have is no longer fixed */ /* the bssid we have is no longer fixed */
mac->associnfo.bssfixed = 0; mac->associnfo.bssfixed = 0;
...@@ -366,7 +366,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev, ...@@ -366,7 +366,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
/* tell the other code that this bssid should be used no matter what */ /* tell the other code that this bssid should be used no matter what */
mac->associnfo.bssfixed = 1; mac->associnfo.bssfixed = 1;
/* queue associate if new bssid or (old one again and not associated) */ /* queue associate if new bssid or (old one again and not associated) */
schedule_delayed_work(&mac->associnfo.work, 0); queue_delayed_work(mac->wq, &mac->associnfo.work, 0);
} }
out: out:
......
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