linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap
@ 2021-05-15 13:26 Lorenzo Bianconi
  2021-05-29 13:41 ` Lorenzo Bianconi
  2021-05-30 16:20 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2021-05-15 13:26 UTC (permalink / raw)
  To: kvalo; +Cc: nbd, linux-wireless, lorenzo.bianconi, sean.wang

Remove MT76_STATE_PM in mt7615_init_device() and introduce
__mt7663s_mcu_drv_pmctrl for fw loading in mt7663s.
This patch fixes a crash at bootstrap for device (e.g. mt7622) that do
not support runtime-pm

Fixes: 7f2bc8ba11a0 ("mt76: connac: introduce wake counter for fw_pmctrl synchronization")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes since v1:
- use proper Fixes commit hash
---
 .../net/wireless/mediatek/mt76/mt7615/init.c  |  1 -
 .../wireless/mediatek/mt76/mt7615/sdio_mcu.c  | 19 ++++++++++++-------
 .../wireless/mediatek/mt76/mt7615/usb_mcu.c   |  3 ---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
index 86341d1f82f3..d20f05a7717d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
@@ -510,7 +510,6 @@ void mt7615_init_device(struct mt7615_dev *dev)
 	mutex_init(&dev->pm.mutex);
 	init_waitqueue_head(&dev->pm.wait);
 	spin_lock_init(&dev->pm.txq_lock);
-	set_bit(MT76_STATE_PM, &dev->mphy.state);
 	INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work);
 	INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
 	INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
index 17fe4187d1de..d1be78b0711c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
@@ -51,16 +51,13 @@ mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
 	return ret;
 }
 
-static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
+static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
 {
 	struct sdio_func *func = dev->mt76.sdio.func;
 	struct mt76_phy *mphy = &dev->mt76.phy;
 	u32 status;
 	int ret;
 
-	if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
-		goto out;
-
 	sdio_claim_host(func);
 
 	sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, NULL);
@@ -76,13 +73,21 @@ static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
 	}
 
 	sdio_release_host(func);
-
-out:
 	dev->pm.last_activity = jiffies;
 
 	return 0;
 }
 
+static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
+{
+	struct mt76_phy *mphy = &dev->mt76.phy;
+
+	if (test_and_clear_bit(MT76_STATE_PM, &mphy->state))
+		return __mt7663s_mcu_drv_pmctrl(dev);
+
+	return 0;
+}
+
 static int mt7663s_mcu_fw_pmctrl(struct mt7615_dev *dev)
 {
 	struct sdio_func *func = dev->mt76.sdio.func;
@@ -123,7 +128,7 @@ int mt7663s_mcu_init(struct mt7615_dev *dev)
 	struct mt7615_mcu_ops *mcu_ops;
 	int ret;
 
-	ret = mt7663s_mcu_drv_pmctrl(dev);
+	ret = __mt7663s_mcu_drv_pmctrl(dev);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
index c55698f9c49a..028ff432d811 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
@@ -55,10 +55,7 @@ int mt7663u_mcu_init(struct mt7615_dev *dev)
 
 	dev->mt76.mcu_ops = &mt7663u_mcu_ops,
 
-	/* usb does not support runtime-pm */
-	clear_bit(MT76_STATE_PM, &dev->mphy.state);
 	mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);
-
 	if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) {
 		mt7615_mcu_restart(&dev->mt76);
 		if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
-- 
2.31.1


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

* Re: [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap
  2021-05-15 13:26 [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap Lorenzo Bianconi
@ 2021-05-29 13:41 ` Lorenzo Bianconi
  2021-06-03  9:42   ` Kalle Valo
  2021-05-30 16:20 ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2021-05-29 13:41 UTC (permalink / raw)
  To: kvalo; +Cc: nbd, linux-wireless, lorenzo.bianconi, sean.wang

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

> Remove MT76_STATE_PM in mt7615_init_device() and introduce
> __mt7663s_mcu_drv_pmctrl for fw loading in mt7663s.
> This patch fixes a crash at bootstrap for device (e.g. mt7622) that do
> not support runtime-pm
> 
> Fixes: 7f2bc8ba11a0 ("mt76: connac: introduce wake counter for fw_pmctrl synchronization")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Hi Kalle,

any news about this patch?

Regards,
Lorenzo

> ---
> Changes since v1:
> - use proper Fixes commit hash
> ---
>  .../net/wireless/mediatek/mt76/mt7615/init.c  |  1 -
>  .../wireless/mediatek/mt76/mt7615/sdio_mcu.c  | 19 ++++++++++++-------
>  .../wireless/mediatek/mt76/mt7615/usb_mcu.c   |  3 ---
>  3 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
> index 86341d1f82f3..d20f05a7717d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
> @@ -510,7 +510,6 @@ void mt7615_init_device(struct mt7615_dev *dev)
>  	mutex_init(&dev->pm.mutex);
>  	init_waitqueue_head(&dev->pm.wait);
>  	spin_lock_init(&dev->pm.txq_lock);
> -	set_bit(MT76_STATE_PM, &dev->mphy.state);
>  	INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work);
>  	INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
>  	INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
> index 17fe4187d1de..d1be78b0711c 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
> @@ -51,16 +51,13 @@ mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
>  	return ret;
>  }
>  
> -static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
> +static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
>  {
>  	struct sdio_func *func = dev->mt76.sdio.func;
>  	struct mt76_phy *mphy = &dev->mt76.phy;
>  	u32 status;
>  	int ret;
>  
> -	if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
> -		goto out;
> -
>  	sdio_claim_host(func);
>  
>  	sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, NULL);
> @@ -76,13 +73,21 @@ static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
>  	}
>  
>  	sdio_release_host(func);
> -
> -out:
>  	dev->pm.last_activity = jiffies;
>  
>  	return 0;
>  }
>  
> +static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
> +{
> +	struct mt76_phy *mphy = &dev->mt76.phy;
> +
> +	if (test_and_clear_bit(MT76_STATE_PM, &mphy->state))
> +		return __mt7663s_mcu_drv_pmctrl(dev);
> +
> +	return 0;
> +}
> +
>  static int mt7663s_mcu_fw_pmctrl(struct mt7615_dev *dev)
>  {
>  	struct sdio_func *func = dev->mt76.sdio.func;
> @@ -123,7 +128,7 @@ int mt7663s_mcu_init(struct mt7615_dev *dev)
>  	struct mt7615_mcu_ops *mcu_ops;
>  	int ret;
>  
> -	ret = mt7663s_mcu_drv_pmctrl(dev);
> +	ret = __mt7663s_mcu_drv_pmctrl(dev);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
> index c55698f9c49a..028ff432d811 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
> @@ -55,10 +55,7 @@ int mt7663u_mcu_init(struct mt7615_dev *dev)
>  
>  	dev->mt76.mcu_ops = &mt7663u_mcu_ops,
>  
> -	/* usb does not support runtime-pm */
> -	clear_bit(MT76_STATE_PM, &dev->mphy.state);
>  	mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);
> -
>  	if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) {
>  		mt7615_mcu_restart(&dev->mt76);
>  		if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
> -- 
> 2.31.1
> 

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

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

* Re: [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap
  2021-05-15 13:26 [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap Lorenzo Bianconi
  2021-05-29 13:41 ` Lorenzo Bianconi
@ 2021-05-30 16:20 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2021-05-30 16:20 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: nbd, linux-wireless, lorenzo.bianconi, sean.wang

Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Remove MT76_STATE_PM in mt7615_init_device() and introduce
> __mt7663s_mcu_drv_pmctrl for fw loading in mt7663s.
> This patch fixes a crash at bootstrap for device (e.g. mt7622) that do
> not support runtime-pm
> 
> Fixes: 7f2bc8ba11a0 ("mt76: connac: introduce wake counter for fw_pmctrl synchronization")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Patch applied to wireless-drivers.git, thanks.

02de318afa7a mt76: mt7615: do not set MT76_STATE_PM at bootstrap

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/e5a2618574007113d844874420f7855891abf167.1621085028.git.lorenzo@kernel.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

* Re: [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap
  2021-05-29 13:41 ` Lorenzo Bianconi
@ 2021-06-03  9:42   ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2021-06-03  9:42 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: nbd, linux-wireless, lorenzo.bianconi, sean.wang

Lorenzo Bianconi <lorenzo@kernel.org> writes:

>> Remove MT76_STATE_PM in mt7615_init_device() and introduce
>> __mt7663s_mcu_drv_pmctrl for fw loading in mt7663s.
>> This patch fixes a crash at bootstrap for device (e.g. mt7622) that do
>> not support runtime-pm
>> 
>> Fixes: 7f2bc8ba11a0 ("mt76: connac: introduce wake counter for
>> fw_pmctrl synchronization")
>> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>
> Hi Kalle,
>
> any news about this patch?

Should be in wireless-drivers now.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

end of thread, other threads:[~2021-06-03  9:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 13:26 [PATCH v2 5.13] mt76: mt7615: do not set MT76_STATE_PM at bootstrap Lorenzo Bianconi
2021-05-29 13:41 ` Lorenzo Bianconi
2021-06-03  9:42   ` Kalle Valo
2021-05-30 16:20 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).