linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: nbd@nbd.name
Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org
Subject: [PATCH 12/13] mt76x0: phy: do not run calibration during channel switch
Date: Fri, 12 Oct 2018 12:16:28 +0200	[thread overview]
Message-ID: <adbb31aad18331d356b4abd135611e3158f1a8ef.1539338611.git.lorenzo.bianconi@redhat.com> (raw)
In-Reply-To: <cover.1539338611.git.lorenzo.bianconi@redhat.com>

Do not perform phy/vga calibration during channel switch.
Moreover remove mt76x0_agc_save and mt76x0_agc_restore routines
since they are no longer necessary. Furthermore run mt76_set_channel
in order to check if there are pending frames during channel switch

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 .../net/wireless/mediatek/mt76/mt76x0/main.c  | 22 ++++++++++++------
 .../wireless/mediatek/mt76/mt76x0/mt76x0.h    |  2 --
 .../net/wireless/mediatek/mt76/mt76x0/phy.c   | 23 +++++++------------
 drivers/net/wireless/mediatek/mt76/mt76x02.h  |  2 --
 4 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
index c9cd0254a979..9273d2d2764a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
@@ -16,6 +16,20 @@
 #include <linux/etherdevice.h>
 #include "mt76x0.h"
 
+static int
+mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
+{
+	int ret;
+
+	cancel_delayed_work_sync(&dev->cal_work);
+
+	mt76_set_channel(&dev->mt76);
+	ret = mt76x0_phy_set_channel(dev, chandef);
+	mt76_txq_schedule_all(&dev->mt76);
+
+	return ret;
+}
+
 int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
 {
 	struct mt76x02_dev *dev = hw->priv;
@@ -25,7 +39,7 @@ int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
 
 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
 		ieee80211_stop_queues(hw);
-		ret = mt76x0_phy_set_channel(dev, &hw->conf.chandef);
+		ret = mt76x0_set_channel(dev, &hw->conf.chandef);
 		ieee80211_wake_queues(hw);
 	}
 
@@ -114,8 +128,6 @@ void mt76x0_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 {
 	struct mt76x02_dev *dev = hw->priv;
 
-	cancel_delayed_work_sync(&dev->cal_work);
-	mt76x0_agc_save(dev);
 	set_bit(MT76_SCANNING, &dev->mt76.state);
 }
 EXPORT_SYMBOL_GPL(mt76x0_sw_scan);
@@ -125,11 +137,7 @@ void mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
 {
 	struct mt76x02_dev *dev = hw->priv;
 
-	mt76x0_agc_restore(dev);
 	clear_bit(MT76_SCANNING, &dev->mt76.state);
-
-	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
-				     MT_CALIBRATE_INTERVAL);
 }
 EXPORT_SYMBOL_GPL(mt76x0_sw_scan_complete);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
index 6717d83e0ff6..2187bafaf2e9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
@@ -66,8 +66,6 @@ int mt76x0_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
 /* PHY */
 void mt76x0_phy_init(struct mt76x02_dev *dev);
 int mt76x0_wait_bbp_ready(struct mt76x02_dev *dev);
-void mt76x0_agc_save(struct mt76x02_dev *dev);
-void mt76x0_agc_restore(struct mt76x02_dev *dev);
 int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
 			    struct cfg80211_chan_def *chandef);
 void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 3d0fcf8c34b4..cf024950e0ed 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -723,17 +723,21 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
 
 	if (mt76_is_usb(dev)) {
 		mt76x0_vco_cal(dev, channel);
-		if (scan)
-			mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1,
-					      false);
 	} else {
 		/* enable vco */
 		rf_set(dev, MT_RF(0, 4), BIT(7));
-		mt76x0_phy_calibrate(dev, false);
 	}
 
+	if (scan)
+		return 0;
+
+	if (mt76_is_mmio(dev))
+		mt76x0_phy_calibrate(dev, false);
 	mt76x0_phy_set_txpower(dev);
 
+	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
+				     MT_CALIBRATE_INTERVAL);
+
 	return 0;
 }
 
@@ -770,17 +774,6 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev)
 	mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false);
 }
 
-void mt76x0_agc_save(struct mt76x02_dev *dev)
-{
-	/* Only one RX path */
-	dev->agc_save = FIELD_GET(MT_BBP_AGC_GAIN, mt76_rr(dev, MT_BBP(AGC, 8)));
-}
-
-void mt76x0_agc_restore(struct mt76x02_dev *dev)
-{
-	mt76_rmw_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN, dev->agc_save);
-}
-
 static void mt76x0_temp_sensor(struct mt76x02_dev *dev)
 {
 	u8 rf_b7_73, rf_b0_66, rf_b0_67;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index f375fdcbd2bf..47c42c607964 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -102,8 +102,6 @@ struct mt76x02_dev {
 
 	bool no_2ghz;
 
-	u8 agc_save;
-
 	u8 coverage_class;
 	u8 slottime;
 
-- 
2.17.2


  parent reply	other threads:[~2018-10-12 10:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 10:16 [PATCH 00/13] add calibration logics for mt76x0e driver Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 01/13] mt76: move mt76x02_phy_set_bw in mt76x02-lib module Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 02/13] mt76: move mt76x02_phy_set_band " Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 03/13] mt76x0: pci: rename mt76x0_phy_calibrate Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 04/13] mt76x0: pci: introduce mt76x0_phy_calirate routine Lorenzo Bianconi
2018-10-12 12:32   ` Stanislaw Gruszka
2018-10-12 12:51     ` Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 05/13] mt76x0: phy: update set_channel for mt76x0e devices Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 06/13] mt76x0: eeprom: introduce mt76x0_tssi_enabled routine Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 07/13] mt76x0: phy: add phy/vco temperature compensation Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 08/13] mt76: move rssi_gain_thresh routines in mt76x02-lib module Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 09/13] mt76: move mt76x02_phy_adjust_vga_gain in mt76/mt76x02_phy.c Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 10/13] mt76: introduce mt76x02_init_agc_gain routine Lorenzo Bianconi
2018-10-12 10:16 ` [PATCH 11/13] mt76x0: phy: align channel gain logic to mt76x2 one Lorenzo Bianconi
2018-10-12 10:16 ` Lorenzo Bianconi [this message]
2018-10-12 10:16 ` [PATCH 13/13] mt76x0: phy: use proper name convention Lorenzo Bianconi
2018-10-12 20:32 ` [PATCH 00/13] add calibration logics for mt76x0e driver Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adbb31aad18331d356b4abd135611e3158f1a8ef.1539338611.git.lorenzo.bianconi@redhat.com \
    --to=lorenzo.bianconi@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=sgruszka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).