From 354605f4e6190ac2c80be5e1a1c7c80a2f7f30a1 Mon Sep 17 00:00:00 2001 From: Amitoj Kaur Chawla Date: Sat, 20 Feb 2016 15:36:26 +0530 Subject: [PATCH] staging: rtl8192e: Remove create_workqueue() With conccurency managed workqueues, use of dedicated workqueues can be replaced by system_wq. Drop wq by using system_wq. Since there are multiple work items per rtllib but they do not need to be ordered, increase of concurrency by switching to system_wq should not break anything. All work items are sync canceled on rtllib_stop_protocol() so it is guaranteed that no work is running when rtl92e_disable/reset/restart functions are called. Signed-off-by: Amitoj Kaur Chawla Acked-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +-- drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 14 +++--- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 47 +++++++++++--------- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 0b06482c325c..18d0fe3802a9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -249,7 +249,7 @@ bool rtl92e_set_rf_state(struct net_device *dev, if (StateToSet == eRfOn) { if (bConnectBySSID && priv->blinked_ingpio) { - queue_delayed_work_rsl(ieee->wq, + schedule_delayed_work( &ieee->associate_procedure_wq, 0); priv->blinked_ingpio = false; } @@ -1327,7 +1327,7 @@ RESET_START: ieee->set_chan(ieee->dev, ieee->current_network.channel); - queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); + schedule_work(&ieee->associate_complete_wq); } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_ADHOC) { @@ -1499,7 +1499,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) if (!(ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, + schedule_delayed_work( &ieee->associate_procedure_wq, 0); priv->check_roaming_cnt = 0; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index 9a4d1bcb881d..98e4d88d0e73 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -63,9 +63,8 @@ void rtl92e_hw_wakeup(struct net_device *dev) spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_DBG, "rtl92e_hw_wakeup(): RF Change in progress!\n"); - queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq, - msecs_to_jiffies(10)); + schedule_delayed_work(&priv->rtllib->hw_wakeup_wq, + msecs_to_jiffies(10)); return; } spin_unlock_irqrestore(&priv->rf_ps_lock, flags); @@ -111,10 +110,8 @@ void rtl92e_enter_sleep(struct net_device *dev, u64 time) return; } tmp = time - jiffies; - queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq, tmp); - queue_delayed_work_rsl(priv->rtllib->wq, - (void *)&priv->rtllib->hw_sleep_wq, 0); + schedule_delayed_work(&priv->rtllib->hw_wakeup_wq, tmp); + schedule_delayed_work(&priv->rtllib->hw_sleep_wq, 0); spin_unlock_irqrestore(&priv->ps_lock, flags); } @@ -203,8 +200,7 @@ void rtl92e_rtllib_ips_leave_wq(struct net_device *dev) } netdev_info(dev, "=========>%s(): rtl92e_ips_leave\n", __func__); - queue_work_rsl(priv->rtllib->wq, - &priv->rtllib->ips_leave_wq); + schedule_work(&priv->rtllib->ips_leave_wq); } } } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index d99240ea3e46..776e179d5bfd 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1728,7 +1728,6 @@ struct rtllib_device { struct delayed_work link_change_wq; struct work_struct wx_sync_scan_wq; - struct workqueue_struct *wq; union { struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 25b5b5e31612..bbc44652769c 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -615,8 +615,8 @@ static void rtllib_softmac_scan_wq(void *data) if (ieee->active_channel_map[ieee->current_network.channel] == 1) rtllib_send_probe_requests(ieee, 0); - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, - msecs_to_jiffies(RTLLIB_SOFTMAC_SCAN_TIME)); + schedule_delayed_work(&ieee->softmac_scan_wq, + msecs_to_jiffies(RTLLIB_SOFTMAC_SCAN_TIME)); up(&ieee->scan_sem); return; @@ -689,7 +689,7 @@ static void rtllib_softmac_stop_scan(struct rtllib_device *ieee) ieee->scanning_continue = 0; ieee->actscanning = false; - cancel_delayed_work(&ieee->softmac_scan_wq); + cancel_delayed_work_sync(&ieee->softmac_scan_wq); } up(&ieee->scan_sem); @@ -745,8 +745,7 @@ static void rtllib_start_scan(struct rtllib_device *ieee) if (ieee->scanning_continue == 0) { ieee->actscanning = true; ieee->scanning_continue = 1; - queue_delayed_work_rsl(ieee->wq, - &ieee->softmac_scan_wq, 0); + schedule_delayed_work(&ieee->softmac_scan_wq, 0); } } else { if (ieee->rtllib_start_hw_scan) @@ -1428,8 +1427,8 @@ static void rtllib_associate_abort(struct rtllib_device *ieee) ieee->state = RTLLIB_ASSOCIATING_RETRY; - queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, - RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); + schedule_delayed_work(&ieee->associate_retry_wq, + RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); } @@ -1580,7 +1579,7 @@ static void rtllib_associate_complete(struct rtllib_device *ieee) ieee->state = RTLLIB_LINKED; rtllib_sta_send_associnfo(ieee); - queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); + schedule_work(&ieee->associate_complete_wq); } static void rtllib_associate_procedure_wq(void *data) @@ -1729,7 +1728,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, if (ieee->LedControlHandler != NULL) ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - queue_delayed_work_rsl(ieee->wq, + schedule_delayed_work( &ieee->associate_procedure_wq, 0); } else { if (rtllib_is_54g(&ieee->current_network) && @@ -2283,7 +2282,7 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, "Association response status code 0x%x\n", errcode); if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) - queue_delayed_work_rsl(ieee->wq, + schedule_delayed_work( &ieee->associate_procedure_wq, 0); else rtllib_associate_abort(ieee); @@ -2393,7 +2392,7 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) if (!(ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, + schedule_delayed_work( &ieee->associate_procedure_wq, 5); } return 0; @@ -2715,8 +2714,7 @@ static void rtllib_start_ibss_wq(void *data) inline void rtllib_start_ibss(struct rtllib_device *ieee) { - queue_delayed_work_rsl(ieee->wq, &ieee->start_ibss_wq, - msecs_to_jiffies(150)); + schedule_delayed_work(&ieee->start_ibss_wq, msecs_to_jiffies(150)); } /* this is called only in user context, with wx_sem held */ @@ -2770,7 +2768,7 @@ void rtllib_disassociate(struct rtllib_device *ieee) ieee->is_set_key = false; ieee->wap_set = 0; - queue_delayed_work_rsl(ieee->wq, &ieee->link_change_wq, 0); + schedule_delayed_work(&ieee->link_change_wq, 0); notify_wx_assoc_event(ieee); } @@ -2882,9 +2880,9 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) rtllib_stop_send_beacons(ieee); del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - cancel_delayed_work(&ieee->start_ibss_wq); - cancel_delayed_work(&ieee->link_change_wq); + cancel_delayed_work_sync(&ieee->associate_retry_wq); + cancel_delayed_work_sync(&ieee->start_ibss_wq); + cancel_delayed_work_sync(&ieee->link_change_wq); rtllib_stop_scan(ieee); if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED) @@ -3027,9 +3025,6 @@ void rtllib_softmac_init(struct rtllib_device *ieee) rtllib_send_beacon_cb, (unsigned long) ieee); - - ieee->wq = create_workqueue(DRV_NAME); - INIT_DELAYED_WORK_RSL(&ieee->link_change_wq, (void *)rtllib_link_change_wq, ieee); INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq, @@ -3065,8 +3060,16 @@ void rtllib_softmac_free(struct rtllib_device *ieee) ieee->pDot11dInfo = NULL; del_timer_sync(&ieee->associate_timer); - cancel_delayed_work(&ieee->associate_retry_wq); - destroy_workqueue(ieee->wq); + cancel_delayed_work_sync(&ieee->associate_retry_wq); + cancel_delayed_work_sync(&ieee->associate_procedure_wq); + cancel_delayed_work_sync(&ieee->softmac_scan_wq); + cancel_delayed_work_sync(&ieee->start_ibss_wq); + cancel_delayed_work_sync(&ieee->hw_wakeup_wq); + cancel_delayed_work_sync(&ieee->hw_sleep_wq); + cancel_delayed_work_sync(&ieee->link_change_wq); + cancel_work_sync(&ieee->associate_complete_wq); + cancel_work_sync(&ieee->ips_leave_wq); + cancel_work_sync(&ieee->wx_sync_scan_wq); up(&ieee->wx_sem); tasklet_kill(&ieee->ps_task); } diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 01a75bd21f86..61ed8b0413e4 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -429,7 +429,7 @@ int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, } if (ieee->state == RTLLIB_LINKED) { - queue_work_rsl(ieee->wq, &ieee->wx_sync_scan_wq); + schedule_work(&ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; }