From: Jes Sorensen Date: Fri, 9 May 2014 13:03:48 +0000 (+0200) Subject: staging: rtl8723au: Use kernel memory allocator for sta_priv allocations X-Git-Tag: firefly_0821_release~176^2~3465^2~39^2~973 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2ad7c3d940015ec00b9772ff1f1f4f9a24b1f682;p=firefly-linux-kernel-4.4.55.git staging: rtl8723au: Use kernel memory allocator for sta_priv allocations The kernel has a great memory allocator, use it instead of hacking up something in the driver. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index e032d77d6e5d..317c10a74569 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -50,29 +50,15 @@ static void _rtw_init_stainfo(struct sta_info *psta) u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) { - struct sta_info *psta; - s32 i; - - pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA+ 4); - - if (!pstapriv->pallocated_stainfo_buf) - return _FAIL; + int i; - pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - - ((unsigned long)(pstapriv->pallocated_stainfo_buf) & 3); - _rtw_init_queue23a(&pstapriv->free_sta_queue); spin_lock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; _rtw_init_queue23a(&pstapriv->sleep_q); _rtw_init_queue23a(&pstapriv->wakeup_q); - psta = (struct sta_info *)(pstapriv->pstainfo_buf); - - for (i = 0; i < NUM_STA; i++) { - _rtw_init_stainfo(psta); + for (i = 0; i < NUM_STA; i++) INIT_LIST_HEAD(&pstapriv->sta_hash[i]); - list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); - psta++; - } + #ifdef CONFIG_8723AU_AP_MODE pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; @@ -92,27 +78,6 @@ u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) return _SUCCESS; } -/* this function is used to free the memory of lock || sema for all stainfos */ -static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) -{ - struct list_head *plist, *phead; - struct sta_info *psta; - - spin_lock_bh(&pstapriv->sta_hash_lock); - - phead = get_list_head(&pstapriv->free_sta_queue); - - /* we really achieve a lot in this loop .... */ - list_for_each(plist, phead) - psta = container_of(plist, struct sta_info, list); - spin_unlock_bh(&pstapriv->sta_hash_lock); -} - -static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) -{ - rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ -} - u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv) { struct list_head *phead, *plist, *ptmp; @@ -138,11 +103,6 @@ u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv) } spin_unlock_bh(&pstapriv->sta_hash_lock); /*===============================*/ - - rtw_mfree_sta_priv_lock(pstapriv); - - if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); } return _SUCCESS; } @@ -151,23 +111,16 @@ struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) { struct list_head *phash_list; struct sta_info *psta; - struct rtw_queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; s32 index; int i = 0; u16 wRxSeqInitialValue = 0xffff; - pfree_sta_queue = &pstapriv->free_sta_queue; - - spin_lock_bh(&pstapriv->sta_hash_lock); - - if (_rtw_queue_empty23a(pfree_sta_queue)) { - spin_unlock_bh(&pstapriv->sta_hash_lock); + psta = (struct sta_info *)kmalloc(sizeof(struct sta_info), GFP_ATOMIC); + if (!psta) return NULL; - } - psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list); - list_del_init(&psta->list); + spin_lock_bh(&pstapriv->sta_hash_lock); _rtw_init_stainfo(psta); @@ -233,9 +186,8 @@ exit: } /* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) +u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) { - struct rtw_queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; struct sta_xmit_priv *pstaxmitpriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -250,8 +202,6 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->state &= ~_FW_LINKED; spin_unlock_bh(&psta->lock); - pfree_sta_queue = &pstapriv->free_sta_queue; - pstaxmitpriv = &psta->sta_xmitpriv; spin_lock_bh(&pxmitpriv->lock); @@ -355,7 +305,8 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->aid = 0; } #endif /* CONFIG_8723AU_AP_MODE */ - list_add_tail(&psta->list, get_list_head(pfree_sta_queue)); + + kfree(psta); exit: return _SUCCESS; } diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 3a490d6dcbcc..27a604e7b5cb 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -310,13 +310,9 @@ struct sta_info { #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)" -struct sta_priv { - u8 *pallocated_stainfo_buf; - u8 *pstainfo_buf; - struct rtw_queue free_sta_queue; - +struct sta_priv { spinlock_t sta_hash_lock; - struct list_head sta_hash[NUM_STA]; + struct list_head sta_hash[NUM_STA]; int asoc_sta_count; struct rtw_queue sleep_q; struct rtw_queue wakeup_q;