diff mbox series

mt76: mt7915: simplify mt7915_mac_sta_poll routine

Message ID db48916a553fee715fc9c0c1f83f363a01218dff.1615139832.git.lorenzo@kernel.org (mailing list archive)
State Rejected
Delegated to: Felix Fietkau
Headers show
Series mt76: mt7915: simplify mt7915_mac_sta_poll routine | expand

Commit Message

Lorenzo Bianconi March 7, 2021, 5:59 p.m. UTC
Drop unnecessary lock around sta_poll_list list in mt7915_mac_sta_poll
routine.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Lorenzo Bianconi March 8, 2021, 10:08 a.m. UTC | #1
> Drop unnecessary lock around sta_poll_list list in mt7915_mac_sta_poll
> routine.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Hi Felix,

please let's drop this patch, as we discussed, there is a race on
list_del_init(&msta->poll_list).

Regards,
Lorenzo

> ---
>  drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index b3168dd3baed..cde98b86e2bb 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -117,23 +117,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
>  
>  	rcu_read_lock();
>  
> -	while (true) {
> +	while (!list_empty(&sta_poll_list)) {
>  		bool clear = false;
>  		u32 addr;
> -		u16 idx;
>  
> -		spin_lock_bh(&dev->sta_poll_lock);
> -		if (list_empty(&sta_poll_list)) {
> -			spin_unlock_bh(&dev->sta_poll_lock);
> -			break;
> -		}
>  		msta = list_first_entry(&sta_poll_list,
>  					struct mt7915_sta, poll_list);
>  		list_del_init(&msta->poll_list);
> -		spin_unlock_bh(&dev->sta_poll_lock);
>  
> -		idx = msta->wcid.idx;
> -		addr = mt7915_mac_wtbl_lmac_addr(dev, idx) + 20 * 4;
> +		addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx) + 20 * 4;
>  
>  		for (i = 0; i < IEEE80211_NUM_ACS; i++) {
>  			u32 tx_last = msta->airtime_ac[i];
> @@ -152,7 +144,7 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
>  		}
>  
>  		if (clear) {
> -			mt7915_mac_wtbl_update(dev, idx,
> +			mt7915_mac_wtbl_update(dev, msta->wcid.idx,
>  					       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>  			memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac));
>  		}
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index b3168dd3baed..cde98b86e2bb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -117,23 +117,15 @@  static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
 
 	rcu_read_lock();
 
-	while (true) {
+	while (!list_empty(&sta_poll_list)) {
 		bool clear = false;
 		u32 addr;
-		u16 idx;
 
-		spin_lock_bh(&dev->sta_poll_lock);
-		if (list_empty(&sta_poll_list)) {
-			spin_unlock_bh(&dev->sta_poll_lock);
-			break;
-		}
 		msta = list_first_entry(&sta_poll_list,
 					struct mt7915_sta, poll_list);
 		list_del_init(&msta->poll_list);
-		spin_unlock_bh(&dev->sta_poll_lock);
 
-		idx = msta->wcid.idx;
-		addr = mt7915_mac_wtbl_lmac_addr(dev, idx) + 20 * 4;
+		addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx) + 20 * 4;
 
 		for (i = 0; i < IEEE80211_NUM_ACS; i++) {
 			u32 tx_last = msta->airtime_ac[i];
@@ -152,7 +144,7 @@  static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
 		}
 
 		if (clear) {
-			mt7915_mac_wtbl_update(dev, idx,
+			mt7915_mac_wtbl_update(dev, msta->wcid.idx,
 					       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
 			memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac));
 		}