All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap
@ 2022-07-24  8:58 sean.wang
  2022-07-24  8:58 ` [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload sean.wang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: sean.wang @ 2022-07-24  8:58 UTC (permalink / raw)
  To: nbd, lorenzo.bianconi
  Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
	Deren.Wu, km.lin, jenhao.yang, robin.chiu, Eddie.Chen, ch.yeh,
	posh.sun, ted.huang, Stella.Chang, Tom.Chou, steve.lee, jsiuda,
	frankgor, kuabhs, druth, abhishekpandit, shawnku, linux-wireless,
	linux-mediatek

From: Sean Wang <sean.wang@mediatek.com>

Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
with the context holding dev->muxtex and the driver might access the
device in low power state.

Fixes: 9d958b60ebc2 ("mt76: mt7921: fix command timeout in AP stop period")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7921/main.c  | 21 ++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 1438a9f8d1fd..7a4a3ed1817e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1526,17 +1526,23 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	struct mt7921_dev *dev = mt7921_hw_dev(hw);
 	int err;
 
+	mt7921_mutex_acquire(dev);
+
 	err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
 					  true);
 	if (err)
-		return err;
+		goto failed;
 
 	err = mt7921_mcu_set_bss_pm(dev, vif, true);
 	if (err)
-		return err;
+		goto failed;
+
+	err = mt7921_mcu_sta_update(dev, NULL, vif, true,
+				    MT76_STA_INFO_STATE_NONE);
+failed:
+	mt7921_mutex_release(dev);
 
-	return mt7921_mcu_sta_update(dev, NULL, vif, true,
-				     MT76_STA_INFO_STATE_NONE);
+	return err;
 }
 
 static void
@@ -1548,11 +1554,16 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	struct mt7921_dev *dev = mt7921_hw_dev(hw);
 	int err;
 
+	mt7921_mutex_acquire(dev);
+
 	err = mt7921_mcu_set_bss_pm(dev, vif, false);
 	if (err)
-		return;
+		goto failed;
 
 	mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false);
+
+failed:
+	mt7921_mutex_release(dev);
 }
 
 const struct ieee80211_ops mt7921_ops = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload
  2022-07-24  8:58 [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap sean.wang
@ 2022-07-24  8:58 ` sean.wang
  2022-07-25  8:10   ` Lorenzo Bianconi
  2022-07-25 10:45   ` AngeloGioacchino Del Regno
  2022-07-25  8:00 ` [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap Lorenzo Bianconi
  2022-07-25 10:44 ` AngeloGioacchino Del Regno
  2 siblings, 2 replies; 6+ messages in thread
From: sean.wang @ 2022-07-24  8:58 UTC (permalink / raw)
  To: nbd, lorenzo.bianconi
  Cc: sean.wang, Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang,
	Deren.Wu, km.lin, jenhao.yang, robin.chiu, Eddie.Chen, ch.yeh,
	posh.sun, ted.huang, Stella.Chang, Tom.Chou, steve.lee, jsiuda,
	frankgor, kuabhs, druth, abhishekpandit, shawnku, linux-wireless,
	linux-mediatek

From: Sean Wang <sean.wang@mediatek.com>

Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
with the context holding dev->muxtex and the driver might access the
device in low power state.

Fixes: 24299fc869f7 ("mt76: mt7921: enable rx header traslation offload")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt7921/main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 7a4a3ed1817e..0d1b17e439dc 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1404,6 +1404,8 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
 	struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
 	struct mt7921_dev *dev = mt7921_hw_dev(hw);
 
+	mt7921_mutex_acquire(dev);
+
 	if (enabled)
 		set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
 	else
@@ -1411,6 +1413,8 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
 
 	mt76_connac_mcu_sta_update_hdr_trans(&dev->mt76, vif, &msta->wcid,
 					     MCU_UNI_CMD(STA_REC_UPDATE));
+
+	mt7921_mutex_release(dev);
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap
  2022-07-24  8:58 [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap sean.wang
  2022-07-24  8:58 ` [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload sean.wang
@ 2022-07-25  8:00 ` Lorenzo Bianconi
  2022-07-25 10:44 ` AngeloGioacchino Del Regno
  2 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-07-25  8:00 UTC (permalink / raw)
  To: sean.wang
  Cc: nbd, lorenzo.bianconi, Soul.Huang, YN.Chen, Leon.Yen,
	Eric-SY.Chang, Deren.Wu, km.lin, jenhao.yang, robin.chiu,
	Eddie.Chen, ch.yeh, posh.sun, ted.huang, Stella.Chang, Tom.Chou,
	steve.lee, jsiuda, frankgor, kuabhs, druth, abhishekpandit,
	shawnku, linux-wireless, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 2073 bytes --]

> From: Sean Wang <sean.wang@mediatek.com>
> 
> Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
> with the context holding dev->muxtex and the driver might access the
> device in low power state.
> 
> Fixes: 9d958b60ebc2 ("mt76: mt7921: fix command timeout in AP stop period")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
>  .../net/wireless/mediatek/mt76/mt7921/main.c  | 21 ++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 1438a9f8d1fd..7a4a3ed1817e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -1526,17 +1526,23 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>  	struct mt7921_dev *dev = mt7921_hw_dev(hw);
>  	int err;
>  
> +	mt7921_mutex_acquire(dev);
> +
>  	err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
>  					  true);
>  	if (err)
> -		return err;
> +		goto failed;
>  
>  	err = mt7921_mcu_set_bss_pm(dev, vif, true);
>  	if (err)
> -		return err;
> +		goto failed;
> +
> +	err = mt7921_mcu_sta_update(dev, NULL, vif, true,
> +				    MT76_STA_INFO_STATE_NONE);

nit: maybe better "out" instead of "failed"

> +failed:
> +	mt7921_mutex_release(dev);
>  
> -	return mt7921_mcu_sta_update(dev, NULL, vif, true,
> -				     MT76_STA_INFO_STATE_NONE);
> +	return err;
>  }
>  
>  static void
> @@ -1548,11 +1554,16 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>  	struct mt7921_dev *dev = mt7921_hw_dev(hw);
>  	int err;
>  
> +	mt7921_mutex_acquire(dev);
> +
>  	err = mt7921_mcu_set_bss_pm(dev, vif, false);
>  	if (err)
> -		return;
> +		goto failed;
>  
>  	mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false);
> +
> +failed:

same here

> +	mt7921_mutex_release(dev);
>  }
>  
>  const struct ieee80211_ops mt7921_ops = {
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload
  2022-07-24  8:58 ` [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload sean.wang
@ 2022-07-25  8:10   ` Lorenzo Bianconi
  2022-07-25 10:45   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-07-25  8:10 UTC (permalink / raw)
  To: sean.wang
  Cc: nbd, lorenzo.bianconi, Soul.Huang, YN.Chen, Leon.Yen,
	Eric-SY.Chang, Deren.Wu, km.lin, jenhao.yang, robin.chiu,
	Eddie.Chen, ch.yeh, posh.sun, ted.huang, Stella.Chang, Tom.Chou,
	steve.lee, jsiuda, frankgor, kuabhs, druth, abhishekpandit,
	shawnku, linux-wireless, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]

> From: Sean Wang <sean.wang@mediatek.com>
> 
> Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
> with the context holding dev->muxtex and the driver might access the
> device in low power state.
> 
> Fixes: 24299fc869f7 ("mt76: mt7921: enable rx header traslation offload")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7921/main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 7a4a3ed1817e..0d1b17e439dc 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -1404,6 +1404,8 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
>  	struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
>  	struct mt7921_dev *dev = mt7921_hw_dev(hw);
>  
> +	mt7921_mutex_acquire(dev);
> +
>  	if (enabled)
>  		set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
>  	else
> @@ -1411,6 +1413,8 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
>  
>  	mt76_connac_mcu_sta_update_hdr_trans(&dev->mt76, vif, &msta->wcid,
>  					     MCU_UNI_CMD(STA_REC_UPDATE));
> +
> +	mt7921_mutex_release(dev);
>  }
>  
>  #if IS_ENABLED(CONFIG_IPV6)
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap
  2022-07-24  8:58 [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap sean.wang
  2022-07-24  8:58 ` [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload sean.wang
  2022-07-25  8:00 ` [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap Lorenzo Bianconi
@ 2022-07-25 10:44 ` AngeloGioacchino Del Regno
  2 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-07-25 10:44 UTC (permalink / raw)
  To: sean.wang, nbd, lorenzo.bianconi
  Cc: Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang, Deren.Wu, km.lin,
	jenhao.yang, robin.chiu, Eddie.Chen, ch.yeh, posh.sun, ted.huang,
	Stella.Chang, Tom.Chou, steve.lee, jsiuda, frankgor, kuabhs,
	druth, abhishekpandit, shawnku, linux-wireless, linux-mediatek

Il 24/07/22 10:58, sean.wang@mediatek.com ha scritto:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
> with the context holding dev->muxtex and the driver might access the
> device in low power state.
> 
> Fixes: 9d958b60ebc2 ("mt76: mt7921: fix command timeout in AP stop period")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>

Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

(P.S.: I agree with Lorenzo's nits.)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload
  2022-07-24  8:58 ` [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload sean.wang
  2022-07-25  8:10   ` Lorenzo Bianconi
@ 2022-07-25 10:45   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-07-25 10:45 UTC (permalink / raw)
  To: sean.wang, nbd, lorenzo.bianconi
  Cc: Soul.Huang, YN.Chen, Leon.Yen, Eric-SY.Chang, Deren.Wu, km.lin,
	jenhao.yang, robin.chiu, Eddie.Chen, ch.yeh, posh.sun, ted.huang,
	Stella.Chang, Tom.Chou, steve.lee, jsiuda, frankgor, kuabhs,
	druth, abhishekpandit, shawnku, linux-wireless, linux-mediatek

Il 24/07/22 10:58, sean.wang@mediatek.com ha scritto:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
> with the context holding dev->muxtex and the driver might access the
> device in low power state.
> 
> Fixes: 24299fc869f7 ("mt76: mt7921: enable rx header traslation offload")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-25 10:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-24  8:58 [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap sean.wang
2022-07-24  8:58 ` [PATCH 2/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload sean.wang
2022-07-25  8:10   ` Lorenzo Bianconi
2022-07-25 10:45   ` AngeloGioacchino Del Regno
2022-07-25  8:00 ` [PATCH 1/2] mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap Lorenzo Bianconi
2022-07-25 10:44 ` AngeloGioacchino Del Regno

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.