Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alban Browaeys and committed by
John W. Linville
e60d7443 ece1e3c6

+18 -6
+11 -1
net/wireless/core.c
··· 45 45 /* for debugfs */ 46 46 static struct dentry *ieee80211_debugfs_dir; 47 47 48 + /* for the cleanup, scan and event works */ 49 + struct workqueue_struct *cfg80211_wq; 50 + 48 51 /* requires cfg80211_mutex to be held! */ 49 52 struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx) 50 53 { ··· 730 727 break; 731 728 case NETDEV_DOWN: 732 729 dev_hold(dev); 733 - schedule_work(&wdev->cleanup_work); 730 + queue_work(cfg80211_wq, &wdev->cleanup_work); 734 731 break; 735 732 case NETDEV_UP: 736 733 /* ··· 848 845 if (err) 849 846 goto out_fail_reg; 850 847 848 + cfg80211_wq = create_singlethread_workqueue("cfg80211"); 849 + if (!cfg80211_wq) 850 + goto out_fail_wq; 851 + 851 852 return 0; 852 853 854 + out_fail_wq: 855 + regulatory_exit(); 853 856 out_fail_reg: 854 857 debugfs_remove(ieee80211_debugfs_dir); 855 858 out_fail_nl80211: ··· 877 868 wiphy_sysfs_exit(); 878 869 regulatory_exit(); 879 870 unregister_pernet_device(&cfg80211_pernet_ops); 871 + destroy_workqueue(cfg80211_wq); 880 872 } 881 873 module_exit(cfg80211_exit);
+2
net/wireless/core.h
··· 91 91 return (wiphy_idx >= 0); 92 92 } 93 93 94 + 95 + extern struct workqueue_struct *cfg80211_wq; 94 96 extern struct mutex cfg80211_mutex; 95 97 extern struct list_head cfg80211_rdev_list; 96 98 extern int cfg80211_rdev_list_generation;
+1 -1
net/wireless/ibss.c
··· 70 70 spin_lock_irqsave(&wdev->event_lock, flags); 71 71 list_add_tail(&ev->list, &wdev->event_list); 72 72 spin_unlock_irqrestore(&wdev->event_lock, flags); 73 - schedule_work(&rdev->event_work); 73 + queue_work(cfg80211_wq, &rdev->event_work); 74 74 } 75 75 EXPORT_SYMBOL(cfg80211_ibss_joined); 76 76
+1 -1
net/wireless/scan.c
··· 88 88 WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); 89 89 90 90 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); 92 92 } 93 93 EXPORT_SYMBOL(cfg80211_scan_done); 94 94
+3 -3
net/wireless/sme.c
··· 488 488 spin_lock_irqsave(&wdev->event_lock, flags); 489 489 list_add_tail(&ev->list, &wdev->event_list); 490 490 spin_unlock_irqrestore(&wdev->event_lock, flags); 491 - schedule_work(&rdev->event_work); 491 + queue_work(cfg80211_wq, &rdev->event_work); 492 492 } 493 493 EXPORT_SYMBOL(cfg80211_connect_result); 494 494 ··· 583 583 spin_lock_irqsave(&wdev->event_lock, flags); 584 584 list_add_tail(&ev->list, &wdev->event_list); 585 585 spin_unlock_irqrestore(&wdev->event_lock, flags); 586 - schedule_work(&rdev->event_work); 586 + queue_work(cfg80211_wq, &rdev->event_work); 587 587 } 588 588 EXPORT_SYMBOL(cfg80211_roamed); 589 589 ··· 681 681 spin_lock_irqsave(&wdev->event_lock, flags); 682 682 list_add_tail(&ev->list, &wdev->event_list); 683 683 spin_unlock_irqrestore(&wdev->event_lock, flags); 684 - schedule_work(&rdev->event_work); 684 + queue_work(cfg80211_wq, &rdev->event_work); 685 685 } 686 686 EXPORT_SYMBOL(cfg80211_disconnected); 687 687