staging: rtl8723bs: protect sleepq_len access by sleep_q.lock
PATCH 1/1 staging: rtl8723bs: protect sleepq_len access by sleep_q.lock
protect sleepq_len access by sleep_q.lock and move pxmitpriv->lock after sleep_q.lock release.
This fixes and completes a lockdep warning silencing done in a prevoius commit where accesses to sleep_q related fields were protected by sleep_q.lock instead of pxmitpriv->lock.
Note that sleep_q.lock is already taken inside rtw_free_xmitframe_queue so we just wrap sleepq_len access.
Moved pxmitpriv->lock after sleep_q.lock release to avoid locks nesting.
--- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +4 -2
@@ -294,10 +294,12 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)/* list_del_init(&psta->wakeup_list); */ -spin_lock_bh (&pxmitpriv->lock); -rtw_free_xmitframe_queue (pxmitpriv, &psta->sleep_q); +spin_lock_bh (&psta->sleep_q.lock); psta->sleepq_len =0 ; +spin_unlock_bh (&psta->sleep_q.lock); + +spin_lock_bh (&pxmitpriv->lock);/* vo */ /* spin_lock_bh(&(pxmitpriv->vo_pending.lock)); */
Signature · 1 line
2.20.1
Hi Fabio,
Quoted 28 lines · Fabio Aiuto
protect
sleepq_lenaccess by sleep_q.lock and movepxmitpriv->lockafter sleep_q.lock release.This fixes and completes a lockdep warning silencing done in a prevoius commit where accesses to
sleep_qrelated fields were protected by sleep_q.lock instead ofpxmitpriv->lock.Note that sleep_q.lock is already taken inside
rtw_free_xmitframe_queueso we just wrapsleepq_lenaccess.Moved
pxmitpriv->lockafter sleep_q.lock release to avoid locks nesting.Fixes 78a1614a81f0 ("staging: rtl8723bs: remove possible deadlock when disconnect")Reported-by Hans de Goede <[email protected]>Tested-by Fabio Aiuto <[email protected]>Signed-off-by Fabio Aiuto <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +0
-0
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) · line 298
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +1
-2@@ -294,10 +294,12 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)/* list_del_init(&psta->wakeup_list); */ -spin_lock_bh (&pxmitpriv->lock); -rtw_free_xmitframe_queue (pxmitpriv, &psta->sleep_q); +spin_lock_bh (&psta->sleep_q.lock);
AFAICT this needs to be above the rtw_free_xmitframe_queue() ?
Regards,
Hans
Quoted 8 lines
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +3
-0psta->sleepq_len =0 ; +spin_unlock_bh (&psta->sleep_q.lock); + +spin_lock_bh (&pxmitpriv->lock);/* vo */ /* spin_lock_bh(&(pxmitpriv->vo_pending.lock)); */
Hello Hans,
Quoted 7 lines · Hans de Goede
Hi Fabio,
Quoted 4 lines
Note that sleep_q.lock is already taken inside
rtw_free_xmitframe_queueso we just wrapsleepq_lenaccess.
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) · line 298
Quoted 5 lines
Moved
pxmitpriv->lockafter sleep_q.lock release to avoid locks nesting.drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +1
-0rtw_free_xmitframe_queue (pxmitpriv, &psta->sleep_q); +spin_lock_bh (&psta->sleep_q.lock);AFAICT this needs to be above the
rtw_free_xmitframe_queue()?
as I wrote on the changelog, the sleep_q.lock is already taken inside rtw_free_xmitframe_queue. If I put the sleep_q.lock above that function a soft lock occurs when I disconnect.
So I put it just below rtw_free_xmitframe_queue.
Things works fine this way.
Please tell me if there's a best way to do it.
Quoted 4 lines
Regards,
Hans
thank you,
fabio
Hi Fabio,
Quoted 23 lines · Fabio Aiuto
Hello Hans,
Quoted 7 lines · Hans de Goede
Hi Fabio,
Quoted 4 lines
Note that sleep_q.lock is already taken inside
rtw_free_xmitframe_queueso we just wrapsleepq_lenaccess.Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) · line 298
Quoted 5 lines
Moved
pxmitpriv->lockafter sleep_q.lock release to avoid locks nesting.drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +1
-0rtw_free_xmitframe_queue (pxmitpriv, &psta->sleep_q); +spin_lock_bh (&psta->sleep_q.lock);AFAICT this needs to be above the
rtw_free_xmitframe_queue()?as I wrote on the changelog, the sleep_q.lock is already taken inside
rtw_free_xmitframe_queue. If I put the sleep_q.lock above that function a soft lock occurs when I disconnect.
Quoted 5 lines
So I put it just below
rtw_free_xmitframe_queue.Things works fine this way.
Please tell me if there's a best way to do it.
Hmm I see, this may work, but the sleepq_len access really should be protected by the same lock as the freeing of the queue is without dropping it in between.
That rtw_free_xmitframe_queue() takes the sleep_q.lock then to me that signals that other (higher-level) functions should not take sleep_q.lock at all, since this is then private to the functions operating on the sleep_q.
I've an idea how we we can possibly tackle this, but I'm not sure yet I will try to make some time to look into this tomorrow or the day after.
Regards,
Hans
Greg KH
maintainerQuoted 36 lines · Hans de Goede
Hi Fabio,
Quoted 23 lines · Fabio Aiuto
Hello Hans,
Quoted 7 lines · Hans de Goede
Hi Fabio,
Quoted 4 lines
Note that sleep_q.lock is already taken inside
rtw_free_xmitframe_queueso we just wrapsleepq_lenaccess.Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) · line 298
Quoted 5 lines
Moved
pxmitpriv->lockafter sleep_q.lock release to avoid locks nesting.drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +1
-0rtw_free_xmitframe_queue (pxmitpriv, &psta->sleep_q); +spin_lock_bh (&psta->sleep_q.lock);AFAICT this needs to be above the
rtw_free_xmitframe_queue()?as I wrote on the changelog, the sleep_q.lock is already taken inside
rtw_free_xmitframe_queue. If I put the sleep_q.lock above that function a soft lock occurs when I disconnect.Quoted 5 lines
So I put it just below
rtw_free_xmitframe_queue.Things works fine this way.
Please tell me if there's a best way to do it.
Hmm I see, this may work, but the
sleepq_lenaccess really should be protected by the same lock as the freeing of the queue is without dropping it in between.
Quoted 8 lines
That
rtw_free_xmitframe_queue()takes the sleep_q.lock then to me that signals that other (higher-level) functions should not take sleep_q.lock at all, since this is then private to the functions operating on thesleep_q.I've an idea how we we can possibly tackle this, but I'm not sure yet I will try to make some time to look into this tomorrow or the day after.
I'm just going to go and revert the original change here until you all can sort it out :)
thanks,
greg k-h
Hi Greg,
Quoted 42 lines · Greg KH
Quoted 41 lines · Hans de Goede
Hi Fabio,
Quoted 23 lines · Fabio Aiuto
Hello Hans,
Quoted 7 lines · Hans de Goede
Hi Fabio,
Quoted 4 lines
Note that sleep_q.lock is already taken inside
rtw_free_xmitframe_queueso we just wrapsleepq_lenaccess.Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) · line 298
Quoted 5 lines
Moved
pxmitpriv->lockafter sleep_q.lock release to avoid locks nesting.drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +1
-0rtw_free_xmitframe_queue (pxmitpriv, &psta->sleep_q); +spin_lock_bh (&psta->sleep_q.lock);AFAICT this needs to be above the
rtw_free_xmitframe_queue()?as I wrote on the changelog, the sleep_q.lock is already taken inside
rtw_free_xmitframe_queue. If I put the sleep_q.lock above that function a soft lock occurs when I disconnect.Quoted 5 lines
So I put it just below
rtw_free_xmitframe_queue.Things works fine this way.
Please tell me if there's a best way to do it.
Hmm I see, this may work, but the
sleepq_lenaccess really should be protected by the same lock as the freeing of the queue is without dropping it in between.That
rtw_free_xmitframe_queue()takes the sleep_q.lock then to me that signals that other (higher-level) functions should not take sleep_q.lock at all, since this is then private to the functions operating on thesleep_q.
Quoted 6 lines
Quoted 3 lines
I've an idea how we we can possibly tackle this, but I'm not sure yet I will try to make some time to look into this tomorrow or the day after.
I'm just going to go and revert the original change here until you all can sort it out :)
that's the best thing for now ;)
Quoted 4 lines
thanks,
greg k-h
thank you,
fabio