Skip to content

Commit

Permalink
staging: r8188eu: make _rtw_init_queue a macro
Browse files Browse the repository at this point in the history
While testing latest updates I hit lockdep warning:

[   42.694425] ============================================
[   42.694785] WARNING: possible recursive locking detected
[   42.695120] 5.14.0+ grate-driver#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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
pskrgag authored and gregkh committed Sep 13, 2021
1 parent e4c1935 commit 590b03a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion drivers/staging/r8188eu/core/rtw_ap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/r8188eu/core/rtw_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/r8188eu/core/rtw_mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/r8188eu/core/rtw_mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions drivers/staging/r8188eu/core/rtw_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand All @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/r8188eu/core/rtw_sta_mgt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down
22 changes: 11 additions & 11 deletions drivers/staging/r8188eu/core/rtw_xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/r8188eu/hal/rtl8188eu_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion drivers/staging/r8188eu/include/osdep_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/r8188eu/os_dep/osdep_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 590b03a

Please sign in to comment.