From: Pavel Skripkin Date: Wed, 8 Sep 2021 19:43:09 +0000 (+0300) Subject: staging: r8188eu: make _rtw_init_queue a macro X-Git-Tag: v6.6.17~8914^2~447 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=590b03a8829f32e338288be036dea0207e42b4fe;p=platform%2Fkernel%2Flinux-rpi.git staging: r8188eu: make _rtw_init_queue a macro While testing latest updates I hit lockdep warning: [ 42.694425] ============================================ [ 42.694785] WARNING: possible recursive locking detected [ 42.695120] 5.14.0+ #25 Tainted: G C [ 42.695422] -------------------------------------------- [ 42.695747] RTW_CMD_THREAD/317 is trying to acquire lock: [ 42.696078] ffffc900006c90b0 (&pqueue->lock){+.-.}-{3:3}, at: _rtw_alloc_network+0x1e/0x321 [r8188eu] [ 42.696686] [ 42.696686] but task is already holding lock: [ 42.697148] ffffc900006c9100 (&pqueue->lock){+.-.}-{3:3}, at: rtw_update_scanned_network+0x31/0x76b [r8188eu] [ 42.697758] [ 42.697758] other info that might help us debug this: [ 42.698326] Possible unsafe locking scenario: [ 42.698326] [ 42.698696] CPU0 [ 42.698847] ---- [ 42.698997] lock(&pqueue->lock); [ 42.699209] lock(&pqueue->lock); [ 42.699418] [ 42.699418] *** DEADLOCK *** [ 42.699418] [ 42.699768] May be due to missing lock nesting notation It's false positive, since all queue spinlocks are initialized via private API which has pqueue as agrument. Fix it by making _rtw_init_queue a macro instead of function + removed unneeded _ prefix. Signed-off-by: Pavel Skripkin Link: https://lore.kernel.org/r/20210908194309.9086-1-paskripkin@gmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 84f853c..b265de3 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -18,7 +18,7 @@ void init_mlme_ap_info(struct adapter *padapter) spin_lock_init(&pmlmepriv->bcn_update_lock); /* for ACL */ - _rtw_init_queue(&pacl_list->acl_node_q); + rtw_init_queue(&pacl_list->acl_node_q); start_ap_mode(padapter); } diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index b3695f1..29e7119 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -25,7 +25,7 @@ static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ sema_init(&pcmdpriv->terminate_cmdthread_sema, 0); - _rtw_init_queue(&pcmdpriv->cmd_queue); + rtw_init_queue(&pcmdpriv->cmd_queue); /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 977f12b..179bddc 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -49,8 +49,8 @@ int _rtw_init_mlme_priv(struct adapter *padapter) pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ spin_lock_init(&pmlmepriv->lock); - _rtw_init_queue(&pmlmepriv->free_bss_pool); - _rtw_init_queue(&pmlmepriv->scanned_queue); + rtw_init_queue(&pmlmepriv->free_bss_pool); + rtw_init_queue(&pmlmepriv->scanned_queue); set_scanned_network_val(pmlmepriv, 0); diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 99d4350..b863d1a 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -889,7 +889,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) } /* Init xmit extension buff */ - _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index a037520..9a41ded 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -31,7 +31,7 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) spin_lock_init(&psta_recvpriv->lock); - _rtw_init_queue(&psta_recvpriv->defrag_q); + rtw_init_queue(&psta_recvpriv->defrag_q); } @@ -45,9 +45,9 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) spin_lock_init(&precvpriv->lock); - _rtw_init_queue(&precvpriv->free_recv_queue); - _rtw_init_queue(&precvpriv->recv_pending_queue); - _rtw_init_queue(&precvpriv->uc_swdec_pending_queue); + rtw_init_queue(&precvpriv->free_recv_queue); + rtw_init_queue(&precvpriv->recv_pending_queue); + rtw_init_queue(&precvpriv->uc_swdec_pending_queue); precvpriv->adapter = padapter; diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 37bd05f..a3d4d5d 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -18,7 +18,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) spin_lock_init(&psta->lock); INIT_LIST_HEAD(&psta->list); INIT_LIST_HEAD(&psta->hash_list); - _rtw_init_queue(&psta->sleep_q); + rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); @@ -61,13 +61,13 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((size_t)(pstapriv->pallocated_stainfo_buf) & 3); - _rtw_init_queue(&pstapriv->free_sta_queue); + rtw_init_queue(&pstapriv->free_sta_queue); spin_lock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; - _rtw_init_queue(&pstapriv->sleep_q); - _rtw_init_queue(&pstapriv->wakeup_q); + rtw_init_queue(&pstapriv->sleep_q); + rtw_init_queue(&pstapriv->wakeup_q); psta = (struct sta_info *)(pstapriv->pstainfo_buf); @@ -211,7 +211,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) preorder_ctrl->wend_b = 0xffff; preorder_ctrl->wsize_b = 64;/* 64; */ - _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); + rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); rtw_init_recv_timer(preorder_ctrl); } diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 3773ff9..d7f3f83 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -18,7 +18,7 @@ static void _init_txservq(struct tx_servq *ptxservq) { INIT_LIST_HEAD(&ptxservq->tx_pending); - _rtw_init_queue(&ptxservq->sta_pending); + rtw_init_queue(&ptxservq->sta_pending); ptxservq->qcnt = 0; } @@ -53,18 +53,18 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) sema_init(&pxmitpriv->terminate_xmitthread_sema, 0); /* - Please insert all the queue initializaiton using _rtw_init_queue below + Please insert all the queue initializaiton using rtw_init_queue below */ pxmitpriv->adapter = padapter; - _rtw_init_queue(&pxmitpriv->be_pending); - _rtw_init_queue(&pxmitpriv->bk_pending); - _rtw_init_queue(&pxmitpriv->vi_pending); - _rtw_init_queue(&pxmitpriv->vo_pending); - _rtw_init_queue(&pxmitpriv->bm_pending); + rtw_init_queue(&pxmitpriv->be_pending); + rtw_init_queue(&pxmitpriv->bk_pending); + rtw_init_queue(&pxmitpriv->vi_pending); + rtw_init_queue(&pxmitpriv->vo_pending); + rtw_init_queue(&pxmitpriv->bm_pending); - _rtw_init_queue(&pxmitpriv->free_xmit_queue); + rtw_init_queue(&pxmitpriv->free_xmit_queue); /* Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, @@ -106,8 +106,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; /* init xmit_buf */ - _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); - _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); + rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); + rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); @@ -148,7 +148,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; /* Init xmit extension buff */ - _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 2da7bde..9c191b7 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -39,7 +39,7 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) (unsigned long)padapter); /* init recv_buf */ - _rtw_init_queue(&precvpriv->free_recv_buf_queue); + rtw_init_queue(&precvpriv->free_recv_buf_queue); precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, GFP_KERNEL); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index b832849..86140ca 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -143,7 +143,11 @@ void *rtw_malloc2d(int h, int w, int size); u32 _rtw_down_sema(struct semaphore *sema); -void _rtw_init_queue(struct __queue *pqueue); +#define rtw_init_queue(q) \ + do { \ + INIT_LIST_HEAD(&((q)->queue)); \ + spin_lock_init(&((q)->lock)); \ + } while (0) u32 rtw_systime_to_ms(u32 systime); u32 rtw_ms_to_systime(u32 ms); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index cbe4f52..bee6d42 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -67,12 +67,6 @@ u32 _rtw_down_sema(struct semaphore *sema) return _SUCCESS; } -void _rtw_init_queue(struct __queue *pqueue) -{ - INIT_LIST_HEAD(&pqueue->queue); - spin_lock_init(&pqueue->lock); -} - inline u32 rtw_systime_to_ms(u32 systime) { return systime * 1000 / HZ;