Skip to content

Commit e60d744

Browse files
prahallinvjw
authored andcommitted
wireless : use a dedicated workqueue for cfg80211.
This patch moves the works cleanup, scan and events to a cfg80211 dedicated workqueue. Platform driver like eeepc-laptop ought to use works to rfkill (as new rfkill does lock in rfkill_unregister and the platform driver is called from rfkill_switch_all which also lock the same mutex). This raise a new issue in itself that the work scheduled by the platform driver to the global worqueue calls wiphy_unregister which flush_work scan and event works (which thus flush works on the global workqueue inside a work on the global workqueue) and also put on hold the wdev_cleanup_work (which prevents the dev_put on netdev thus indefinite Usage count error on wifi device). Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Alban Browaeys <prahal@yahoo.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent ece1e3c commit e60d744

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎net/wireless/core.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ DEFINE_MUTEX(cfg80211_mutex);
4545
/* for debugfs */
4646
static struct dentry *ieee80211_debugfs_dir;
4747

48+
/* for the cleanup, scan and event works */
49+
struct workqueue_struct *cfg80211_wq;
50+
4851
/* requires cfg80211_mutex to be held! */
4952
struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx)
5053
{
@@ -727,7 +730,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
727730
break;
728731
case NETDEV_DOWN:
729732
dev_hold(dev);
730-
schedule_work(&wdev->cleanup_work);
733+
queue_work(cfg80211_wq, &wdev->cleanup_work);
731734
break;
732735
case NETDEV_UP:
733736
/*
@@ -845,8 +848,14 @@ static int __init cfg80211_init(void)
845848
if (err)
846849
goto out_fail_reg;
847850

851+
cfg80211_wq = create_singlethread_workqueue("cfg80211");
852+
if (!cfg80211_wq)
853+
goto out_fail_wq;
854+
848855
return 0;
849856

857+
out_fail_wq:
858+
regulatory_exit();
850859
out_fail_reg:
851860
debugfs_remove(ieee80211_debugfs_dir);
852861
out_fail_nl80211:
@@ -868,5 +877,6 @@ static void cfg80211_exit(void)
868877
wiphy_sysfs_exit();
869878
regulatory_exit();
870879
unregister_pernet_device(&cfg80211_pernet_ops);
880+
destroy_workqueue(cfg80211_wq);
871881
}
872882
module_exit(cfg80211_exit);

‎net/wireless/core.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ bool wiphy_idx_valid(int wiphy_idx)
9191
return (wiphy_idx >= 0);
9292
}
9393

94+
95+
extern struct workqueue_struct *cfg80211_wq;
9496
extern struct mutex cfg80211_mutex;
9597
extern struct list_head cfg80211_rdev_list;
9698
extern int cfg80211_rdev_list_generation;

‎net/wireless/ibss.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
7070
spin_lock_irqsave(&wdev->event_lock, flags);
7171
list_add_tail(&ev->list, &wdev->event_list);
7272
spin_unlock_irqrestore(&wdev->event_lock, flags);
73-
schedule_work(&rdev->event_work);
73+
queue_work(cfg80211_wq, &rdev->event_work);
7474
}
7575
EXPORT_SYMBOL(cfg80211_ibss_joined);
7676

‎net/wireless/scan.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted)
8888
WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req);
8989

9090
request->aborted = aborted;
91-
schedule_work(&wiphy_to_dev(request->wiphy)->scan_done_wk);
91+
queue_work(cfg80211_wq, &wiphy_to_dev(request->wiphy)->scan_done_wk);
9292
}
9393
EXPORT_SYMBOL(cfg80211_scan_done);
9494

‎net/wireless/sme.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
488488
spin_lock_irqsave(&wdev->event_lock, flags);
489489
list_add_tail(&ev->list, &wdev->event_list);
490490
spin_unlock_irqrestore(&wdev->event_lock, flags);
491-
schedule_work(&rdev->event_work);
491+
queue_work(cfg80211_wq, &rdev->event_work);
492492
}
493493
EXPORT_SYMBOL(cfg80211_connect_result);
494494

@@ -583,7 +583,7 @@ void cfg80211_roamed(struct net_device *dev, const u8 *bssid,
583583
spin_lock_irqsave(&wdev->event_lock, flags);
584584
list_add_tail(&ev->list, &wdev->event_list);
585585
spin_unlock_irqrestore(&wdev->event_lock, flags);
586-
schedule_work(&rdev->event_work);
586+
queue_work(cfg80211_wq, &rdev->event_work);
587587
}
588588
EXPORT_SYMBOL(cfg80211_roamed);
589589

@@ -681,7 +681,7 @@ void cfg80211_disconnected(struct net_device *dev, u16 reason,
681681
spin_lock_irqsave(&wdev->event_lock, flags);
682682
list_add_tail(&ev->list, &wdev->event_list);
683683
spin_unlock_irqrestore(&wdev->event_lock, flags);
684-
schedule_work(&rdev->event_work);
684+
queue_work(cfg80211_wq, &rdev->event_work);
685685
}
686686
EXPORT_SYMBOL(cfg80211_disconnected);
687687

0 commit comments

Comments
 (0)