]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mt76x02: run calibration after scanning
authorStanislaw Gruszka <sgruszka@redhat.com>
Thu, 1 Nov 2018 15:35:01 +0000 (16:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 07:15:46 +0000 (08:15 +0100)
commit f1b8ee35fec4a070b7760a99709fc98f237c2b86 upstream.

If we are associated and scanning is performed, sw_scan_complete callback
is done after we get back to operating channel, so we do not perform
queue cal work. Fix this queue cal work from sw_scan_complete().

On mt76x0 we have to restore gain in MT_BBP(AGC, 8) register after
scanning, as it was multiple times modified by channel switch code.
So queue cal work without any delay to set AGC gain value.

Similar like in mt76x2 init AGC gain only when set operating channel
and just check before queuing cal work in sw_scan_complete() if
initialization was already done.

Fixes: bbd10586f0df ("mt76x0: phy: do not run calibration during channel switch")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/mediatek/mt76/mt76x0/main.c
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c

index 9273d2d2764ab3e12a63309346821dfffb48bfe0..205c3afe2aeb95dcd91682b1955a396b3c6ee098 100644 (file)
@@ -138,6 +138,9 @@ void mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
        struct mt76x02_dev *dev = hw->priv;
 
        clear_bit(MT76_SCANNING, &dev->mt76.state);
+
+       if (dev->cal.gain_init_done)
+               ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
 }
 EXPORT_SYMBOL_GPL(mt76x0_sw_scan_complete);
 
index b1314c0f74c8187718bf0f15c26d800d2cab4617..771e54b39abfc8c57866f72d3c2c3cdcf552c0f2 100644 (file)
@@ -720,7 +720,6 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
 
        mt76x0_read_rx_gain(dev);
        mt76x0_phy_set_chan_bbp_params(dev, rf_bw_band);
-       mt76x02_init_agc_gain(dev);
 
        if (mt76_is_usb(dev)) {
                mt76x0_vco_cal(dev, channel);
@@ -732,6 +731,7 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
        if (scan)
                return 0;
 
+       mt76x02_init_agc_gain(dev);
        if (mt76_is_mmio(dev))
                mt76x0_phy_calibrate(dev, false);
        mt76x0_phy_set_txpower(dev);
index 7806963b1905293f5067ab5758c35a9f190b8c7d..9a5ae5c06840afb974212f9b323cb39f327030f4 100644 (file)
@@ -63,6 +63,7 @@ struct mt76x02_calibration {
        bool tssi_comp_pending;
        bool dpd_cal_done;
        bool channel_cal_done;
+       bool gain_init_done;
 };
 
 struct mt76x02_dev {
index 0f1d7b5c9f68e31f456d497e820003621d4a72c5..977a8e7e26dfd86523f95f8515178785493927e7 100644 (file)
@@ -254,5 +254,6 @@ void mt76x02_init_agc_gain(struct mt76x02_dev *dev)
        memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
               sizeof(dev->cal.agc_gain_cur));
        dev->cal.low_gain = -1;
+       dev->cal.gain_init_done = true;
 }
 EXPORT_SYMBOL_GPL(mt76x02_init_agc_gain);
index 1971a1b0003849e1f6510761ef7d4e15b0f9c3fd..9471b44ce55898fd7df3d1ba09ab07a768154e9c 100644 (file)
@@ -156,6 +156,9 @@ mt76x2u_sw_scan_complete(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
        struct mt76x02_dev *dev = hw->priv;
 
        clear_bit(MT76_SCANNING, &dev->mt76.state);
+
+       if (dev->cal.gain_init_done)
+               ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
 }
 
 const struct ieee80211_ops mt76x2u_ops = {