linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5.0 v2] mt76x0u: fix suspend/resume
@ 2019-02-06 14:34 Stanislaw Gruszka
  2019-02-06 15:06 ` Lorenzo Bianconi
  2019-02-07 16:33 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2019-02-06 14:34 UTC (permalink / raw)
  To: linux-wireless; +Cc: Lorenzo Bianconi, Felix Fietkau

We need to reset MCU and do other initializations on resume otherwise
MT7610U device will fail to initialize, what cause system hung due to
USB requests timeouts.

Patch fixes 4.19 -> 4.20 regression.

Cc: stable@vger.kernel.org # 4.20+
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
v2: minor coding style changes

 drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 46 ++++++++++++++++---------
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
index 0e6b43bb4678..a5ea3ba495a4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
@@ -158,39 +158,49 @@ static const struct ieee80211_ops mt76x0u_ops = {
 	.get_txpower = mt76x02_get_txpower,
 };
 
-static int mt76x0u_register_device(struct mt76x02_dev *dev)
+static int mt76x0u_init_hardware(struct mt76x02_dev *dev)
 {
-	struct ieee80211_hw *hw = dev->mt76.hw;
 	int err;
 
-	err = mt76u_alloc_queues(&dev->mt76);
-	if (err < 0)
-		goto out_err;
-
-	err = mt76u_mcu_init_rx(&dev->mt76);
-	if (err < 0)
-		goto out_err;
-
 	mt76x0_chip_onoff(dev, true, true);
-	if (!mt76x02_wait_for_mac(&dev->mt76)) {
-		err = -ETIMEDOUT;
-		goto out_err;
-	}
+
+	if (!mt76x02_wait_for_mac(&dev->mt76))
+		return -ETIMEDOUT;
 
 	err = mt76x0u_mcu_init(dev);
 	if (err < 0)
-		goto out_err;
+		return err;
 
 	mt76x0_init_usb_dma(dev);
 	err = mt76x0_init_hardware(dev);
 	if (err < 0)
-		goto out_err;
+		return err;
 
 	mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e);
 	mt76_wr(dev, MT_TXOP_CTRL_CFG,
 		FIELD_PREP(MT_TXOP_TRUN_EN, 0x3f) |
 		FIELD_PREP(MT_TXOP_EXT_CCA_DLY, 0x58));
 
+	return 0;
+}
+
+static int mt76x0u_register_device(struct mt76x02_dev *dev)
+{
+	struct ieee80211_hw *hw = dev->mt76.hw;
+	int err;
+
+	err = mt76u_alloc_queues(&dev->mt76);
+	if (err < 0)
+		goto out_err;
+
+	err = mt76u_mcu_init_rx(&dev->mt76);
+	if (err < 0)
+		goto out_err;
+
+	err = mt76x0u_init_hardware(dev);
+	if (err < 0)
+		goto out_err;
+
 	err = mt76x0_register_device(dev);
 	if (err < 0)
 		goto out_err;
@@ -301,6 +311,8 @@ static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,
 
 	mt76u_stop_queues(&dev->mt76);
 	mt76x0u_mac_stop(dev);
+	clear_bit(MT76_STATE_MCU_RUNNING, &dev->mt76.state);
+	mt76x0_chip_onoff(dev, false, false);
 	usb_kill_urb(usb->mcu.res.urb);
 
 	return 0;
@@ -328,7 +340,7 @@ static int __maybe_unused mt76x0_resume(struct usb_interface *usb_intf)
 	tasklet_enable(&usb->rx_tasklet);
 	tasklet_enable(&usb->tx_tasklet);
 
-	ret = mt76x0_init_hardware(dev);
+	ret = mt76x0u_init_hardware(dev);
 	if (ret)
 		goto err;
 
-- 
2.7.5


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

* Re: [PATCH 5.0 v2] mt76x0u: fix suspend/resume
  2019-02-06 14:34 [PATCH 5.0 v2] mt76x0u: fix suspend/resume Stanislaw Gruszka
@ 2019-02-06 15:06 ` Lorenzo Bianconi
  2019-02-07 16:33 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2019-02-06 15:06 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: linux-wireless, Felix Fietkau

> We need to reset MCU and do other initializations on resume otherwise
> MT7610U device will fail to initialize, what cause system hung due to
> USB requests timeouts.
> 
> Patch fixes 4.19 -> 4.20 regression.
> 
> Cc: stable@vger.kernel.org # 4.20+
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> v2: minor coding style changes
> 

Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

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

* Re: [PATCH 5.0 v2] mt76x0u: fix suspend/resume
  2019-02-06 14:34 [PATCH 5.0 v2] mt76x0u: fix suspend/resume Stanislaw Gruszka
  2019-02-06 15:06 ` Lorenzo Bianconi
@ 2019-02-07 16:33 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2019-02-07 16:33 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: linux-wireless, Lorenzo Bianconi, Felix Fietkau

Stanislaw Gruszka <sgruszka@redhat.com> wrote:

> We need to reset MCU and do other initializations on resume otherwise
> MT7610U device will fail to initialize, what cause system hung due to
> USB requests timeouts.
> 
> Patch fixes 4.19 -> 4.20 regression.
> 
> Cc: stable@vger.kernel.org # 4.20+
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

Patch applied to wireless-drivers.git, thanks.

d04ca383860b mt76x0u: fix suspend/resume

-- 
https://patchwork.kernel.org/patch/10799445/

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


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

end of thread, other threads:[~2019-02-07 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 14:34 [PATCH 5.0 v2] mt76x0u: fix suspend/resume Stanislaw Gruszka
2019-02-06 15:06 ` Lorenzo Bianconi
2019-02-07 16:33 ` 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).