diff mbox series

mt76: mt7921s: fix possible sdio deadlock in command fail

Message ID 7122534ce50527e099a23fa198683a0e20c6db38.1654998031.git.deren.wu@mediatek.com (mailing list archive)
State Superseded
Delegated to: Felix Fietkau
Headers show
Series mt76: mt7921s: fix possible sdio deadlock in command fail | expand

Commit Message

Deren Wu June 12, 2022, 1:59 a.m. UTC
From: Deren Wu <deren.wu@mediatek.com>

Move sdio_release_host() to final resource handing

Fixes: b12deb5e86fa ("mt76: mt7921s: fix mt7921s_mcu_[fw|drv]_pmctrl")
Reported-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lorenzo Bianconi June 13, 2022, 9:31 a.m. UTC | #1
> From: Deren Wu <deren.wu@mediatek.com>
> 
> Move sdio_release_host() to final resource handing
> 

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

> Fixes: b12deb5e86fa ("mt76: mt7921s: fix mt7921s_mcu_[fw|drv]_pmctrl")
> Reported-by: YN Chen <YN.Chen@mediatek.com>
> Signed-off-by: Deren Wu <deren.wu@mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> index 54a5c712a3c3..1856d677fff4 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> @@ -156,9 +156,9 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
>  
>  	err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status,
>  				 !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000);
> +err:
>  	sdio_release_host(func);
>  
> -err:
>  	if (err < 0) {
>  		dev_err(dev->mt76.dev, "firmware own failed\n");
>  		clear_bit(MT76_STATE_PM, &mphy->state);
> -- 
> 2.18.0
>
Lorenzo Bianconi June 13, 2022, 12:21 p.m. UTC | #2
> From: Deren Wu <deren.wu@mediatek.com>
> 
> Move sdio_release_host() to final resource handing
> 
> Fixes: b12deb5e86fa ("mt76: mt7921s: fix mt7921s_mcu_[fw|drv]_pmctrl")
> Reported-by: YN Chen <YN.Chen@mediatek.com>
> Signed-off-by: Deren Wu <deren.wu@mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> index 54a5c712a3c3..1856d677fff4 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> @@ -156,9 +156,9 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
>  
>  	err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status,
>  				 !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000);
> +err:
>  	sdio_release_host(func);
>  
> -err:
>  	if (err < 0) {
>  		dev_err(dev->mt76.dev, "firmware own failed\n");
>  		clear_bit(MT76_STATE_PM, &mphy->state);
> -- 
> 2.18.0
> 

Hi Deren,

in order to align the code with mt7921e, can you please fold the following
changes into this patch?

Regards,
Lorenzo

--- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
@@ -135,8 +135,8 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
 	struct sdio_func *func = dev->mt76.sdio.func;
 	struct mt76_phy *mphy = &dev->mt76.phy;
 	struct mt76_connac_pm *pm = &dev->pm;
-	int err = 0;
 	u32 status;
+	int err;
 
 	sdio_claim_host(func);
 
@@ -147,7 +147,7 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
 					 2000, 1000000);
 		if (err < 0) {
 			dev_err(dev->mt76.dev, "mailbox ACK not cleared\n");
-			goto err;
+			goto out;
 		}
 	}
 
@@ -155,18 +155,18 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
 
 	err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status,
 				 !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000);
-err:
+out:
 	sdio_release_host(func);
 
 	if (err < 0) {
 		dev_err(dev->mt76.dev, "firmware own failed\n");
 		clear_bit(MT76_STATE_PM, &mphy->state);
-		err = -EIO;
+		return -EIO;
 	}
 
 	pm->stats.last_doze_event = jiffies;
 	pm->stats.awake_time += pm->stats.last_doze_event -
 				pm->stats.last_wake_event;
 
-	return err;
+	return 0;
 }
Deren Wu June 13, 2022, 3:32 p.m. UTC | #3
On Mon, 2022-06-13 at 14:21 +0200, Lorenzo Bianconi wrote:
> > From: Deren Wu <deren.wu@mediatek.com>
> > 
> > Move sdio_release_host() to final resource handing
> > 
> > Fixes: b12deb5e86fa ("mt76: mt7921s: fix
> > mt7921s_mcu_[fw|drv]_pmctrl")
> > Reported-by: YN Chen <YN.Chen@mediatek.com>
> > Signed-off-by: Deren Wu <deren.wu@mediatek.com>
> > ---
> >  drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> > b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> > index 54a5c712a3c3..1856d677fff4 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> > @@ -156,9 +156,9 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev
> > *dev)
> >  
> >  	err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status,
> >  				 !(status & WHLPCR_IS_DRIVER_OWN),
> > 2000, 1000000);
> > +err:
> >  	sdio_release_host(func);
> >  
> > -err:
> >  	if (err < 0) {
> >  		dev_err(dev->mt76.dev, "firmware own failed\n");
> >  		clear_bit(MT76_STATE_PM, &mphy->state);
> > -- 
> > 2.18.0
> > 
> 
> Hi Deren,
> 
> in order to align the code with mt7921e, can you please fold the
> following
> changes into this patch?
> 
> Regards,
> Lorenzo
> 

Hi Lore,

Sure, I will post v2 with your patch.


Thanks,
Deren

> --- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
> @@ -135,8 +135,8 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
>  	struct sdio_func *func = dev->mt76.sdio.func;
>  	struct mt76_phy *mphy = &dev->mt76.phy;
>  	struct mt76_connac_pm *pm = &dev->pm;
> -	int err = 0;
>  	u32 status;
> +	int err;
>  
>  	sdio_claim_host(func);
>  
> @@ -147,7 +147,7 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
>  					 2000, 1000000);
>  		if (err < 0) {
>  			dev_err(dev->mt76.dev, "mailbox ACK not
> cleared\n");
> -			goto err;
> +			goto out;
>  		}
>  	}
>  
> @@ -155,18 +155,18 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev
> *dev)
>  
>  	err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status,
>  				 !(status & WHLPCR_IS_DRIVER_OWN),
> 2000, 1000000);
> -err:
> +out:
>  	sdio_release_host(func);
>  
>  	if (err < 0) {
>  		dev_err(dev->mt76.dev, "firmware own failed\n");
>  		clear_bit(MT76_STATE_PM, &mphy->state);
> -		err = -EIO;
> +		return -EIO;
>  	}
>  
>  	pm->stats.last_doze_event = jiffies;
>  	pm->stats.awake_time += pm->stats.last_doze_event -
>  				pm->stats.last_wake_event;
>  
> -	return err;
> +	return 0;
>  }
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
index 54a5c712a3c3..1856d677fff4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c
@@ -156,9 +156,9 @@  int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)
 
 	err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status,
 				 !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000);
+err:
 	sdio_release_host(func);
 
-err:
 	if (err < 0) {
 		dev_err(dev->mt76.dev, "firmware own failed\n");
 		clear_bit(MT76_STATE_PM, &mphy->state);