2019-01-22 12:38:41

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

There ware several bugs introduced in 4.20 development cycle
for mt76x0 driver, that were fixed later but missed 4.20
release. This patche set fixes issues for MT7610U and
MT7630E.

Bug reference:
https://bugzilla.kernel.org/show_bug.cgi?id=202243

Lorenzo Bianconi (1):
mt76x0: phy: unify calibration between mt76x0u and mt76x0e

Stanislaw Gruszka (6):
mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
mt76x0: use band parameter for LC calibration
mt76x02: run calibration after scanning
mt76x02: assure we update gain after scan
mt76x0: do not perform MCU calibration for MT7630
mt76x0: antenna select corrections

drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 9 +-
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 170 +++++++--------------
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 1 +
drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 +
.../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +-
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 1 +
.../net/wireless/mediatek/mt76/mt76x2/usb_main.c | 3 +
9 files changed, 76 insertions(+), 125 deletions(-)

--
1.9.3



2019-01-22 12:38:42

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 1/7] mt76x0: do not overwrite other MT_BBP(AGC, 8) fields

commit b983a5b900627faa49cf37e101d65b56e941c740 upstream.

MT_BBP(AGC, 8) register has values depend on band in
mt76x0_bbp_switch_tab, so we should not overwrite other fields
than MT_BBP_AGC_GAIN when setting gain.

This can fix performance issues when connecting to 2.4GHz AP.

Fixes: 4636a2544c3b ("mt76x0: phy: align channel gain logic to mt76x2 one")
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index cf024950e0ed..1af2a1227924 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -817,10 +817,8 @@ static void mt76x0_temp_sensor(struct mt76x02_dev *dev)
static void mt76x0_phy_set_gain_val(struct mt76x02_dev *dev)
{
u8 gain = dev->cal.agc_gain_cur[0] - dev->cal.agc_gain_adjust;
- u32 val = 0x122c << 16 | 0xf2;

- mt76_wr(dev, MT_BBP(AGC, 8),
- val | FIELD_PREP(MT_BBP_AGC_GAIN, gain));
+ mt76_rmw_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN, gain);
}

static void
--
1.9.3


2019-01-22 12:38:44

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 2/7] mt76x0: use band parameter for LC calibration

commit ad3f993a0857ad3b792e7463828eb0d90cdd6f4d upstream.

We use always 1 as band parameter for MCU_CAL_LC, this break 2GHz,
we should use 0 for this band instead.

Patch fixes problems happened sometimes when try to associate with 2GHz
AP and manifest by errors like below:

[14680.920823] wlan0: authenticate with 18:31:bf:c0:51:b0
[14681.109506] wlan0: send auth to 18:31:bf:c0:51:b0 (try 1/3)
[14681.310454] wlan0: send auth to 18:31:bf:c0:51:b0 (try 2/3)
[14681.518469] wlan0: send auth to 18:31:bf:c0:51:b0 (try 3/3)
[14681.726499] wlan0: authentication with 18:31:bf:c0:51:b0 timed out

Fixes: 9aec146d0f6b ("mt76x0: pci: introduce mt76x0_phy_calirate routine")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 1af2a1227924..b1314c0f74c8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -585,6 +585,7 @@ void mt76x0_phy_set_txpower(struct mt76x02_dev *dev)
void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)
{
struct ieee80211_channel *chan = dev->mt76.chandef.chan;
+ int is_5ghz = (chan->band == NL80211_BAND_5GHZ) ? 1 : 0;
u32 val, tx_alc, reg_val;

if (power_on) {
@@ -602,7 +603,7 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)
reg_val = mt76_rr(dev, MT_BBP(IBI, 9));
mt76_wr(dev, MT_BBP(IBI, 9), 0xffffff7e);

- if (chan->band == NL80211_BAND_5GHZ) {
+ if (is_5ghz) {
if (chan->hw_value < 100)
val = 0x701;
else if (chan->hw_value < 140)
@@ -615,7 +616,7 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)

mt76x02_mcu_calibrate(dev, MCU_CAL_FULL, val, false);
msleep(350);
- mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 1, false);
+ mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz, false);
usleep_range(15000, 20000);

mt76_wr(dev, MT_BBP(IBI, 9), reg_val);
--
1.9.3


2019-01-22 12:38:45

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 3/7] mt76x02: run calibration after scanning

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: Felix Fietkau <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 3 +++
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 +
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 1 +
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c | 3 +++
5 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
index 9273d2d2764a..205c3afe2aeb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
@@ -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);

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index b1314c0f74c8..771e54b39abf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -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);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 7806963b1905..9a5ae5c06840 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -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 {
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
index 0f1d7b5c9f68..977a8e7e26df 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
@@ -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);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
index 1971a1b00038..9471b44ce558 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
@@ -156,6 +156,9 @@ static int mt76x2u_add_interface(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);
}

const struct ieee80211_ops mt76x2u_ops = {
--
1.9.3


2019-01-22 12:38:52

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 4/7] mt76x02: assure we update gain after scan

commit 4784a3cc3fffd0ba5ef6c7a23980ae0318fc1369 upstream.

Assure that after we initialize dev->cal.low_gain to -1 this
will cause update gain calibration. Otherwise this might or
might not happen depending on value of second bit of low_gain
and values read from registers in mt76x02_phy_adjust_vga_gain().

Signed-off-by: Felix Fietkau <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 5 ++++-
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 3 ++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
index 205c3afe2aeb..4126ac5d9a8a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
@@ -139,8 +139,11 @@ void mt76x0_sw_scan_complete(struct ieee80211_hw *hw,

clear_bit(MT76_SCANNING, &dev->mt76.state);

- if (dev->cal.gain_init_done)
+ if (dev->cal.gain_init_done) {
+ /* Restore AGC gain and resume calibration after scanning. */
+ dev->cal.low_gain = -1;
ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
+ }
}
EXPORT_SYMBOL_GPL(mt76x0_sw_scan_complete);

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 771e54b39abf..f99097e265aa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -834,7 +834,8 @@ static void mt76x0_phy_set_gain_val(struct mt76x02_dev *dev)
low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) +
(dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));

- gain_change = (dev->cal.low_gain & 2) ^ (low_gain & 2);
+ gain_change = dev->cal.low_gain < 0 ||
+ (dev->cal.low_gain & 2) ^ (low_gain & 2);
dev->cal.low_gain = low_gain;

if (!gain_change) {
--
1.9.3


2019-01-22 12:38:54

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 5/7] mt76x0: do not perform MCU calibration for MT7630

commit a83150eaad42769e4d08b6e07956a489e40214ae upstream.

Driver works better for MT7630 without MCU calibration, which
looks like it can hangs the firmware. Vendor driver do not
perform it for MT7630 as well.

Signed-off-by: Felix Fietkau <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +++++
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 3 +++
2 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
index 2187bafaf2e9..0057f69d0c36 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
@@ -41,6 +41,11 @@ static inline bool is_mt7610e(struct mt76x02_dev *dev)

void mt76x0_init_debugfs(struct mt76x02_dev *dev);

+static inline bool is_mt7630(struct mt76x02_dev *dev)
+{
+ return mt76_chip(&dev->mt76) == 0x7630;
+}
+
/* Init */
struct mt76x02_dev *
mt76x0_alloc_device(struct device *pdev,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index f99097e265aa..d598ddc632cc 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -588,6 +588,9 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)
int is_5ghz = (chan->band == NL80211_BAND_5GHZ) ? 1 : 0;
u32 val, tx_alc, reg_val;

+ if (is_mt7630(dev))
+ return;
+
if (power_on) {
mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
mt76x02_mcu_calibrate(dev, MCU_CAL_VCO, chan->hw_value,
--
1.9.3


2019-01-22 12:38:55

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 6/7] mt76x0: antenna select corrections

commit ef442b73b6bc36b5499e1983611abb46e6337975 upstream.

Update mt76x0_phy_ant_select() to conform vendor driver, most notably
add dual antenna mode support, read configuration from EEPROM and
move ant select out of channel config to init phase. Plus small MT7630E
quirk for MT_CMB_CTRL register which vendor driver dedicated to this
chip do.

This make MT7630E workable with mt76x0e driver and do not cause any
problems on MT7610U for me.

Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 52 ++++++++++++++++------
.../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 ++---
2 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index d598ddc632cc..8d654aa63e93 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -518,21 +518,47 @@ static void mt76x0_vco_cal(struct mt76x02_dev *dev, u8 channel)

static void mt76x0_ant_select(struct mt76x02_dev *dev)
{
- struct ieee80211_channel *chan = dev->mt76.chandef.chan;
-
- /* single antenna mode */
- if (chan->band == NL80211_BAND_2GHZ) {
- mt76_rmw(dev, MT_COEXCFG3,
- BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
- mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
+ u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
+ u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
+ u32 wlan, coex3, cmb;
+ bool ant_div;
+
+ wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
+ cmb = mt76_rr(dev, MT_CMB_CTRL);
+ coex3 = mt76_rr(dev, MT_COEXCFG3);
+
+ cmb &= ~(BIT(14) | BIT(12));
+ wlan &= ~(BIT(6) | BIT(5));
+ coex3 &= ~GENMASK(5, 2);
+
+ if (ee_ant & MT_EE_ANTENNA_DUAL) {
+ /* dual antenna mode */
+ ant_div = !(nic_conf2 & MT_EE_NIC_CONF_2_ANT_OPT) &&
+ (nic_conf2 & MT_EE_NIC_CONF_2_ANT_DIV);
+ if (ant_div)
+ cmb |= BIT(12);
+ else
+ coex3 |= BIT(4);
+ coex3 |= BIT(3);
+ if (dev->mt76.cap.has_2ghz)
+ wlan |= BIT(6);
} else {
- mt76_rmw(dev, MT_COEXCFG3, BIT(5) | BIT(2),
- BIT(4) | BIT(3));
- mt76_clear(dev, MT_WLAN_FUN_CTRL,
- BIT(6) | BIT(5));
+ /* sigle antenna mode */
+ if (dev->mt76.cap.has_5ghz) {
+ coex3 |= BIT(3) | BIT(4);
+ } else {
+ wlan |= BIT(6);
+ coex3 |= BIT(1);
+ }
}
- mt76_clear(dev, MT_CMB_CTRL, BIT(14) | BIT(12));
+
+ if (is_mt7630(dev))
+ cmb |= BIT(14) | BIT(11);
+
+ mt76_wr(dev, MT_WLAN_FUN_CTRL, wlan);
+ mt76_wr(dev, MT_CMB_CTRL, cmb);
mt76_clear(dev, MT_COEXCFG0, BIT(2));
+ mt76_wr(dev, MT_COEXCFG3, coex3);
}

static void
@@ -700,7 +726,6 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
mt76x02_phy_set_bw(dev, chandef->width, ch_group_index);
mt76x02_phy_set_band(dev, chandef->chan->band,
ch_group_index & 1);
- mt76x0_ant_select(dev);

mt76_rmw(dev, MT_EXT_CCA_CFG,
(MT_EXT_CCA_CFG_CCA0 |
@@ -927,6 +952,7 @@ void mt76x0_phy_init(struct mt76x02_dev *dev)
{
INIT_DELAYED_WORK(&dev->cal_work, mt76x0_phy_calibration_work);

+ mt76x0_ant_select(dev);
mt76x0_rf_init(dev);
mt76x02_phy_set_rxpath(dev);
mt76x02_phy_set_txdac(dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
index b3ec74835d10..1de041590050 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
@@ -25,6 +25,7 @@ enum mt76x02_eeprom_field {
MT_EE_VERSION = 0x002,
MT_EE_MAC_ADDR = 0x004,
MT_EE_PCI_ID = 0x00A,
+ MT_EE_ANTENNA = 0x022,
MT_EE_NIC_CONF_0 = 0x034,
MT_EE_NIC_CONF_1 = 0x036,
MT_EE_COUNTRY_REGION_5GHZ = 0x038,
@@ -104,6 +105,8 @@ enum mt76x02_eeprom_field {
__MT_EE_MAX
};

+#define MT_EE_ANTENNA_DUAL BIT(15)
+
#define MT_EE_NIC_CONF_0_RX_PATH GENMASK(3, 0)
#define MT_EE_NIC_CONF_0_TX_PATH GENMASK(7, 4)
#define MT_EE_NIC_CONF_0_PA_TYPE GENMASK(9, 8)
@@ -118,12 +121,9 @@ enum mt76x02_eeprom_field {
#define MT_EE_NIC_CONF_1_LNA_EXT_5G BIT(3)
#define MT_EE_NIC_CONF_1_TX_ALC_EN BIT(13)

-#define MT_EE_NIC_CONF_2_RX_STREAM GENMASK(3, 0)
-#define MT_EE_NIC_CONF_2_TX_STREAM GENMASK(7, 4)
-#define MT_EE_NIC_CONF_2_HW_ANTDIV BIT(8)
+#define MT_EE_NIC_CONF_2_ANT_OPT BIT(3)
+#define MT_EE_NIC_CONF_2_ANT_DIV BIT(4)
#define MT_EE_NIC_CONF_2_XTAL_OPTION GENMASK(10, 9)
-#define MT_EE_NIC_CONF_2_TEMP_DISABLE BIT(11)
-#define MT_EE_NIC_CONF_2_COEX_METHOD GENMASK(15, 13)

#define MT_EFUSE_USAGE_MAP_SIZE (MT_EE_USAGE_MAP_END - \
MT_EE_USAGE_MAP_START + 1)
--
1.9.3


2019-01-22 12:38:57

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH 4.20.x 7/7] mt76x0: phy: unify calibration between mt76x0u and mt76x0e

From: Lorenzo Bianconi <[email protected]>

commit 1163bdb636a118b9d7c3c03b9e67e7e799425a9c upstream.

Align phy calibration logic between mt76x0u and mt76x0e drivers
This patch improves connection stability with low SNR

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 3 -
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 101 +----------------------
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 1 +
4 files changed, 6 insertions(+), 100 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 3bfa7f5e3513..2e5bcb3fdff7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) 2016 Felix Fietkau <[email protected]>
*
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
index 4126ac5d9a8a..732f4b87fdcb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/main.c
@@ -116,9 +116,6 @@ void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
MT_BKOFF_SLOT_CFG_SLOTTIME, slottime);
}

- if (changed & BSS_CHANGED_ASSOC)
- mt76x0_phy_recalibrate_after_assoc(dev);
-
mutex_unlock(&dev->mt76.mutex);
}
EXPORT_SYMBOL_GPL(mt76x0_bss_info_changed);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 8d654aa63e93..c34abd1c6030 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -215,62 +215,6 @@ int mt76x0_wait_bbp_ready(struct mt76x02_dev *dev)
return 0;
}

-static void mt76x0_vco_cal(struct mt76x02_dev *dev, u8 channel)
-{
- u8 val;
-
- val = rf_rr(dev, MT_RF(0, 4));
- if ((val & 0x70) != 0x30)
- return;
-
- /*
- * Calibration Mode - Open loop, closed loop, and amplitude:
- * B0.R06.[0]: 1
- * B0.R06.[3:1] bp_close_code: 100
- * B0.R05.[7:0] bp_open_code: 0x0
- * B0.R04.[2:0] cal_bits: 000
- * B0.R03.[2:0] startup_time: 011
- * B0.R03.[6:4] settle_time:
- * 80MHz channel: 110
- * 40MHz channel: 101
- * 20MHz channel: 100
- */
- val = rf_rr(dev, MT_RF(0, 6));
- val &= ~0xf;
- val |= 0x09;
- rf_wr(dev, MT_RF(0, 6), val);
-
- val = rf_rr(dev, MT_RF(0, 5));
- if (val != 0)
- rf_wr(dev, MT_RF(0, 5), 0x0);
-
- val = rf_rr(dev, MT_RF(0, 4));
- val &= ~0x07;
- rf_wr(dev, MT_RF(0, 4), val);
-
- val = rf_rr(dev, MT_RF(0, 3));
- val &= ~0x77;
- if (channel == 1 || channel == 7 || channel == 9 || channel >= 13) {
- val |= 0x63;
- } else if (channel == 3 || channel == 4 || channel == 10) {
- val |= 0x53;
- } else if (channel == 2 || channel == 5 || channel == 6 ||
- channel == 8 || channel == 11 || channel == 12) {
- val |= 0x43;
- } else {
- WARN(1, "Unknown channel %u\n", channel);
- return;
- }
- rf_wr(dev, MT_RF(0, 3), val);
-
- /* TODO replace by mt76x0_rf_set(dev, MT_RF(0, 4), BIT(7)); */
- val = rf_rr(dev, MT_RF(0, 4));
- val = ((val & ~(0x80)) | 0x80);
- rf_wr(dev, MT_RF(0, 4), val);
-
- msleep(2);
-}
-
static void
mt76x0_phy_set_band(struct mt76x02_dev *dev, enum nl80211_band band)
{
@@ -749,19 +693,15 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
mt76x0_read_rx_gain(dev);
mt76x0_phy_set_chan_bbp_params(dev, rf_bw_band);

- if (mt76_is_usb(dev)) {
- mt76x0_vco_cal(dev, channel);
- } else {
- /* enable vco */
- rf_set(dev, MT_RF(0, 4), BIT(7));
- }
+ /* enable vco */
+ rf_set(dev, MT_RF(0, 4), BIT(7));

if (scan)
return 0;

+ mt76x0_phy_calibrate(dev, false);
mt76x02_init_agc_gain(dev);
- 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,
@@ -770,39 +710,6 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
return 0;
}

-void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev)
-{
- u32 tx_alc, reg_val;
- u8 channel = dev->mt76.chandef.chan->hw_value;
- int is_5ghz = (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) ? 1 : 0;
-
- mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
-
- mt76x0_vco_cal(dev, channel);
-
- tx_alc = mt76_rr(dev, MT_TX_ALC_CFG_0);
- mt76_wr(dev, MT_TX_ALC_CFG_0, 0);
- usleep_range(500, 700);
-
- reg_val = mt76_rr(dev, MT_BBP(IBI, 9));
- mt76_wr(dev, MT_BBP(IBI, 9), 0xffffff7e);
-
- mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 0, false);
-
- mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz, false);
- mt76x02_mcu_calibrate(dev, MCU_CAL_LOFT, is_5ghz, false);
- mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false);
- mt76x02_mcu_calibrate(dev, MCU_CAL_TX_GROUP_DELAY, is_5ghz, false);
- mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQ, is_5ghz, false);
- mt76x02_mcu_calibrate(dev, MCU_CAL_RX_GROUP_DELAY, is_5ghz, false);
-
- mt76_wr(dev, MT_BBP(IBI, 9), reg_val);
- mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc);
- msleep(100);
-
- mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false);
-}
-
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/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
index a7fd36c2f633..ea517864186b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
@@ -117,6 +117,7 @@ static int mt76x0u_start(struct ieee80211_hw *hw)
if (ret)
goto out;

+ mt76x0_phy_calibrate(dev, true);
ieee80211_queue_delayed_work(dev->mt76.hw, &dev->mac_work,
MT_CALIBRATE_INTERVAL);
ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
--
1.9.3


2019-01-28 17:15:52

by Sid Hayn

[permalink] [raw]
Subject: Re: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

On Tue, Jan 22, 2019 at 7:41 AM Stanislaw Gruszka <[email protected]> wrote:
>
> There ware several bugs introduced in 4.20 development cycle
> for mt76x0 driver, that were fixed later but missed 4.20
> release. This patche set fixes issues for MT7610U and
> MT7630E.
>
> Bug reference:
> https://bugzilla.kernel.org/show_bug.cgi?id=202243
>
> Lorenzo Bianconi (1):
> mt76x0: phy: unify calibration between mt76x0u and mt76x0e
>
> Stanislaw Gruszka (6):
> mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
> mt76x0: use band parameter for LC calibration
> mt76x02: run calibration after scanning
> mt76x02: assure we update gain after scan
> mt76x0: do not perform MCU calibration for MT7630
> mt76x0: antenna select corrections
>
> drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
> drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 9 +-
> drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +
> drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 170 +++++++--------------
> drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 1 +
> drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 +
> .../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +-
> drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 1 +
> .../net/wireless/mediatek/mt76/mt76x2/usb_main.c | 3 +
> 9 files changed, 76 insertions(+), 125 deletions(-)
>
> --
> 1.9.3
>

Please forgive if I'm mistaken, but I haven't seen this hit the stable
queue or see any response at all. Did this get missed or just hasn't
been reached yet?

Thanks,
Zero

2019-01-29 08:04:20

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

Sid Hayn <[email protected]> writes:

> On Tue, Jan 22, 2019 at 7:41 AM Stanislaw Gruszka <[email protected]> wrote:
>>
>> There ware several bugs introduced in 4.20 development cycle
>> for mt76x0 driver, that were fixed later but missed 4.20
>> release. This patche set fixes issues for MT7610U and
>> MT7630E.
>>
>> Bug reference:
>> https://bugzilla.kernel.org/show_bug.cgi?id=202243
>>
>> Lorenzo Bianconi (1):
>> mt76x0: phy: unify calibration between mt76x0u and mt76x0e
>>
>> Stanislaw Gruszka (6):
>> mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
>> mt76x0: use band parameter for LC calibration
>> mt76x02: run calibration after scanning
>> mt76x02: assure we update gain after scan
>> mt76x0: do not perform MCU calibration for MT7630
>> mt76x0: antenna select corrections
>>
>> drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
>> drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 9 +-
>> drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +
>> drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 170 +++++++--------------
>> drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 1 +
>> drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 +
>> .../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +-
>> drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 1 +
>> .../net/wireless/mediatek/mt76/mt76x2/usb_main.c | 3 +
>> 9 files changed, 76 insertions(+), 125 deletions(-)
>>
>> --
>> 1.9.3
>>
>
> Please forgive if I'm mistaken, but I haven't seen this hit the stable
> queue or see any response at all. Did this get missed or just hasn't
> been reached yet?

It's been only 7 days since the patches were submitted. The maintainers
have a lot to do and a lot of email to process, don't expect that
everything will be done instantly.

--
Kalle Valo

2019-01-29 09:43:38

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

On Mon, Jan 28, 2019 at 11:06:41AM -0500, Sid Hayn wrote:
> On Tue, Jan 22, 2019 at 7:41 AM Stanislaw Gruszka <[email protected]> wrote:
> >
> > There ware several bugs introduced in 4.20 development cycle
> > for mt76x0 driver, that were fixed later but missed 4.20
> > release. This patche set fixes issues for MT7610U and
> > MT7630E.
> >
> > Bug reference:
> > https://bugzilla.kernel.org/show_bug.cgi?id=202243
> >
> > Lorenzo Bianconi (1):
> > mt76x0: phy: unify calibration between mt76x0u and mt76x0e
> >
> > Stanislaw Gruszka (6):
> > mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
> > mt76x0: use band parameter for LC calibration
> > mt76x02: run calibration after scanning
> > mt76x02: assure we update gain after scan
> > mt76x0: do not perform MCU calibration for MT7630
> > mt76x0: antenna select corrections
> >
> > drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
> > drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 9 +-
> > drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +
> > drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 170 +++++++--------------
> > drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 1 +
> > drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 +
> > .../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +-
> > drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 1 +
> > .../net/wireless/mediatek/mt76/mt76x2/usb_main.c | 3 +
> > 9 files changed, 76 insertions(+), 125 deletions(-)
> >
> > --
> > 1.9.3
> >
>
> Please forgive if I'm mistaken, but I haven't seen this hit the stable
> queue or see any response at all. Did this get missed or just hasn't
> been reached yet?

Not reached yet, please give us a chance :)

Backports that have to be "applied by hand" like this are at the bottom
of the pile...

greg k-h

2019-01-29 10:38:42

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

On Tue, Jan 22, 2019 at 01:38:30PM +0100, Stanislaw Gruszka wrote:
> There ware several bugs introduced in 4.20 development cycle
> for mt76x0 driver, that were fixed later but missed 4.20
> release. This patche set fixes issues for MT7610U and
> MT7630E.
>
> Bug reference:
> https://bugzilla.kernel.org/show_bug.cgi?id=202243
>
> Lorenzo Bianconi (1):
> mt76x0: phy: unify calibration between mt76x0u and mt76x0e
>
> Stanislaw Gruszka (6):
> mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
> mt76x0: use band parameter for LC calibration
> mt76x02: run calibration after scanning
> mt76x02: assure we update gain after scan
> mt76x0: do not perform MCU calibration for MT7630
> mt76x0: antenna select corrections

Now queued up, thanks.

greg k-h

2019-01-29 15:56:04

by Sid Hayn

[permalink] [raw]
Subject: Re: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

Thanks for the responses, I know how hard you all work. From my
perspective I cannot tell the difference between missed and just in
queue.

Is there a patchwork page for patches targeting stable, or is the
process there too complex for patchwork? Right now I only see the
mailing list and the stable queue git tree and no other idea on how to
see status.

Thanks again for your hard work, truly didn't mean to suggest otherwise.

-Zero


On Tue, Jan 29, 2019 at 4:43 AM Greg KH <[email protected]> wrote:
>
> On Mon, Jan 28, 2019 at 11:06:41AM -0500, Sid Hayn wrote:
> > On Tue, Jan 22, 2019 at 7:41 AM Stanislaw Gruszka <[email protected]> wrote:
> > >
> > > There ware several bugs introduced in 4.20 development cycle
> > > for mt76x0 driver, that were fixed later but missed 4.20
> > > release. This patche set fixes issues for MT7610U and
> > > MT7630E.
> > >
> > > Bug reference:
> > > https://bugzilla.kernel.org/show_bug.cgi?id=202243
> > >
> > > Lorenzo Bianconi (1):
> > > mt76x0: phy: unify calibration between mt76x0u and mt76x0e
> > >
> > > Stanislaw Gruszka (6):
> > > mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
> > > mt76x0: use band parameter for LC calibration
> > > mt76x02: run calibration after scanning
> > > mt76x02: assure we update gain after scan
> > > mt76x0: do not perform MCU calibration for MT7630
> > > mt76x0: antenna select corrections
> > >
> > > drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
> > > drivers/net/wireless/mediatek/mt76/mt76x0/main.c | 9 +-
> > > drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +
> > > drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 170 +++++++--------------
> > > drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 1 +
> > > drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 +
> > > .../net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +-
> > > drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 1 +
> > > .../net/wireless/mediatek/mt76/mt76x2/usb_main.c | 3 +
> > > 9 files changed, 76 insertions(+), 125 deletions(-)
> > >
> > > --
> > > 1.9.3
> > >
> >
> > Please forgive if I'm mistaken, but I haven't seen this hit the stable
> > queue or see any response at all. Did this get missed or just hasn't
> > been reached yet?
>
> Not reached yet, please give us a chance :)
>
> Backports that have to be "applied by hand" like this are at the bottom
> of the pile...
>
> greg k-h

2019-01-29 16:09:58

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 4.20.x 0/7] mt76x0 fixes for 4.20 stable

On Tue, Jan 29, 2019 at 10:55:55AM -0500, Sid Hayn wrote:
> Thanks for the responses, I know how hard you all work. From my
> perspective I cannot tell the difference between missed and just in
> queue.

Given that it was only a week, normally it takes longer, so just be
patient.

> Is there a patchwork page for patches targeting stable, or is the
> process there too complex for patchwork? Right now I only see the
> mailing list and the stable queue git tree and no other idea on how to
> see status.

There is no other way, sorry. If after 2 weeks we don't pick something
up, and it's not the week after -rc1 happened, just email asking what
the status is, it's not a problem.

thanks,

greg k-h