fix mt76x0u driver hw stop sequence
Subsystems (2)
cover fix mt76x0u driver hw stop sequence
Fix two issue introduced in mt76x0u driver with latest rework to share hw initialization between mt760 and mt76x2 drivers
Lorenzo Bianconi (2):
mt76: usb: fix hw initialization sequence
mt76x0: usb: stop cal/mac workqueues at hw stop
Stanislaw Gruszka (1):
mt76: fix frag length allocation for usb
.../net/wireless/mediatek/mt76/mt76x0/usb.c | 24 +++++++++---------- .../wireless/mediatek/mt76/mt76x2/usb_init.c | 2 +- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 mt76: fix frag length allocation for usb
From: Stanislaw Gruszka <[email protected]>
This is correct fix for c12128ce44b0 ("mt76: use a per rx queue page fragment cache"). We use wrong length when we allocate segments for MCU transmissions, which require bigger segment size than e->buf_size.
Commit 481bb0432414 ("mt76: usb: make rx page_frag_cache access atomic") partially solved the problem or actually mask it by changing mt76u_mcu_init_rx() and mt76u_alloc_queues() sequence, so e->buf_size become non zero any longer, but still not big enough to handle MCU data.
Patch fixes memory corruption which can manifest itself as random, not easy to reproduce crashes, during mt76 driver load or unload.
--- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/usb.c +1 -1
@@ -286,7 +286,7 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,void *data;int offset; - data =page_frag_alloc (&q->rx_page, q->buf_size,GFP_ATOMIC ); + data =page_frag_alloc (&q->rx_page, len,GFP_ATOMIC );if (!data)break ;
Signature · 1 line
2.17.1
PATCH 2/3 mt76: usb: fix hw initialization sequence
In reply to Lorenzo Bianconimt76u_alloc_queues need to be called before mt76u_mcu_init_rx since it initializes rx_page_lock spinlock used in mt76u_buf_alloc routine.
mt76x0_alloc_device signature")
--- .../net/wireless/mediatek/mt76/mt76x0/usb.c | 18 +++++++++--------- .../wireless/mediatek/mt76/mt76x2/usb_init.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +9 -9
@@ -179,28 +179,28 @@ static int mt76x0u_register_device(struct mt76x0_dev *dev)struct ieee80211_hw *hw = dev->mt76.hw;int err; - err =mt76u_mcu_init_rx (&dev->mt76); + err =mt76u_alloc_queues (&dev->mt76);if (err <0 ) -return err; + goto out_err; - err =mt76u_alloc_queues (&dev->mt76); + err =mt76u_mcu_init_rx (&dev->mt76);if (err <0 ) -return err; + goto out_err;mt76x0_chip_onoff (dev, true, true);if (!mt76x02_wait_for_mac (&dev->mt76)) { err = -ETIMEDOUT ; - goto err; + goto out_err; } err =mt76x0u_mcu_init (dev);if (err <0 ) - goto err; + goto out_err;mt76x0_init_usb_dma (dev); err =mt76x0_init_hardware (dev);if (err <0 ) - goto err; + goto out_err;mt76_rmw (dev,MT_US_CYC_CFG ,MT_US_CYC_CNT ,0x1e ); mt76_wr(dev, MT_TXOP_CTRL_CFG,
@@ -209,7 +209,7 @@ static int mt76x0u_register_device(struct mt76x0_dev *dev) err =mt76x0_register_device (dev);if (err <0 ) - goto err; + goto out_err;/* check hw sg support in order to enable AMSDU */ if (mt76u_check_sg (&dev->mt76))
@@ -221,7 +221,7 @@ static int mt76x0u_register_device(struct mt76x0_dev *dev)return 0 ; -err: +out_err:mt76x0u_cleanup (dev);return err; }
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c +1 -1
@@ -262,7 +262,7 @@ int mt76x2u_register_device(struct mt76x2_dev *dev) err =mt76u_mcu_init_rx (&dev->mt76);if (err <0 ) -return err; + goto fail; err =mt76x2u_init_hardware (dev);if (err <0 )
Signature · 1 line
2.17.1
PATCH 3/3 mt76x0: usb: stop cal/mac workqueues at hw stop
In reply to Lorenzo BianconiStop mac and calibration work stopping the hw even if the device has been removed
mt76x0_alloc_device signature")
--- drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +3 -3
@@ -86,14 +86,14 @@ static void mt76x0u_cleanup(struct mt76x0_dev *dev)static void mt76x0u_mac_stop (struct mt76x0_dev *dev) { -if (test_bit (MT76_REMOVED , &dev->mt76.state)) -return ; -clear_bit (MT76_STATE_RUNNING , &dev->mt76.state);cancel_delayed_work_sync (&dev->cal_work);cancel_delayed_work_sync (&dev->mac_work);mt76u_stop_stat_wk (&dev->mt76); +if (test_bit (MT76_REMOVED , &dev->mt76.state)) +return ; +mt76_clear (dev,MT_BEACON_TIME_CFG ,MT_BEACON_TIME_CFG_TIMER_EN |MT_BEACON_TIME_CFG_SYNC_MODE |MT_BEACON_TIME_CFG_TBTT_EN |MT_BEACON_TIME_CFG_BEACON_TX );
Signature · 1 line
2.17.1
Quoted 2 lines · Lorenzo Bianconi
Fix two issue introduced in mt76x0u driver with latest rework to share hw initialization between mt760 and mt76x2 drivers
Merged, thanks.
- Felix