From: Greg Kroah-Hartman Date: Tue, 29 Jan 2019 10:33:15 +0000 (+0100) Subject: 4.20-stable patches X-Git-Tag: v4.9.154~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d99e68ba09290009f61b2360e83a7d62d914788b;p=thirdparty%2Fkernel%2Fstable-queue.git 4.20-stable patches added patches: ide-fix-a-typo-in-the-settings-proc-file-name.patch mt76x0-antenna-select-corrections.patch mt76x0-do-not-overwrite-other-mt_bbp-agc-8-fields.patch mt76x0-do-not-perform-mcu-calibration-for-mt7630.patch mt76x0-phy-unify-calibration-between-mt76x0u-and-mt76x0e.patch mt76x0-use-band-parameter-for-lc-calibration.patch mt76x02-assure-we-update-gain-after-scan.patch mt76x02-run-calibration-after-scanning.patch revert-mm-memory_hotplug-initialize-struct-pages-for-the-full-memory-section.patch usb-dwc3-gadget-clear-req-needs_extra_trb-flag-on-cleanup.patch --- diff --git a/queue-4.20/ide-fix-a-typo-in-the-settings-proc-file-name.patch b/queue-4.20/ide-fix-a-typo-in-the-settings-proc-file-name.patch new file mode 100644 index 00000000000..106c81a42af --- /dev/null +++ b/queue-4.20/ide-fix-a-typo-in-the-settings-proc-file-name.patch @@ -0,0 +1,30 @@ +From f8ff6c732d35904d773043f979b844ef330c701b Mon Sep 17 00:00:00 2001 +From: Christoph Hellwig +Date: Thu, 20 Dec 2018 17:16:53 +0100 +Subject: ide: fix a typo in the settings proc file name + +From: Christoph Hellwig + +commit f8ff6c732d35904d773043f979b844ef330c701b upstream. + +Fixes: ec7d9c9ce8 ("ide: replace ->proc_fops with ->proc_show") +Reported-by: kernel test robot +Signed-off-by: Christoph Hellwig +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/ide/ide-proc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/ide/ide-proc.c ++++ b/drivers/ide/ide-proc.c +@@ -544,7 +544,7 @@ void ide_proc_port_register_devices(ide_ + drive->proc = proc_mkdir(drive->name, parent); + if (drive->proc) { + ide_add_proc_entries(drive->proc, generic_drive_entries, drive); +- proc_create_data("setting", S_IFREG|S_IRUSR|S_IWUSR, ++ proc_create_data("settings", S_IFREG|S_IRUSR|S_IWUSR, + drive->proc, &ide_settings_proc_fops, + drive); + } diff --git a/queue-4.20/mt76x0-antenna-select-corrections.patch b/queue-4.20/mt76x0-antenna-select-corrections.patch new file mode 100644 index 00000000000..fd53c04d0c0 --- /dev/null +++ b/queue-4.20/mt76x0-antenna-select-corrections.patch @@ -0,0 +1,142 @@ +From foo@baz Tue Jan 29 11:19:20 CET 2019 +From: Stanislaw Gruszka +Date: Tue, 22 Jan 2019 13:38:36 +0100 +Subject: mt76x0: antenna select corrections +To: stable@vger.kernel.org +Cc: Felix Fietkau , linux-wireless@vger.kernel.org, Lorenzo Bianconi +Message-ID: <1548160717-4059-7-git-send-email-sgruszka@redhat.com> + +From: Stanislaw Gruszka + +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 +Signed-off-by: Felix Fietkau +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 52 +++++++++++++++----- + drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +-- + 2 files changed, 44 insertions(+), 18 deletions(-) + +--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c ++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +@@ -518,21 +518,47 @@ mt76x0_phy_set_chan_bbp_params(struct mt + + 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 mt76x0 + 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 + { + 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); +--- 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) diff --git a/queue-4.20/mt76x0-do-not-overwrite-other-mt_bbp-agc-8-fields.patch b/queue-4.20/mt76x0-do-not-overwrite-other-mt_bbp-agc-8-fields.patch new file mode 100644 index 00000000000..faec39b9174 --- /dev/null +++ b/queue-4.20/mt76x0-do-not-overwrite-other-mt_bbp-agc-8-fields.patch @@ -0,0 +1,40 @@ +From b983a5b900627faa49cf37e101d65b56e941c740 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 31 Oct 2018 08:32:58 +0100 +Subject: mt76x0: do not overwrite other MT_BBP(AGC, 8) fields + +From: Stanislaw Gruszka + +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 +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Felix Fietkau +Signed-off-by: Greg Kroah-Hartman + + +--- + drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c ++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +@@ -817,10 +817,8 @@ done: + 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 diff --git a/queue-4.20/mt76x0-do-not-perform-mcu-calibration-for-mt7630.patch b/queue-4.20/mt76x0-do-not-perform-mcu-calibration-for-mt7630.patch new file mode 100644 index 00000000000..553375db6f9 --- /dev/null +++ b/queue-4.20/mt76x0-do-not-perform-mcu-calibration-for-mt7630.patch @@ -0,0 +1,50 @@ +From foo@baz Tue Jan 29 11:19:20 CET 2019 +From: Stanislaw Gruszka +Date: Tue, 22 Jan 2019 13:38:35 +0100 +Subject: mt76x0: do not perform MCU calibration for MT7630 +To: stable@vger.kernel.org +Cc: Felix Fietkau , linux-wireless@vger.kernel.org, Lorenzo Bianconi +Message-ID: <1548160717-4059-6-git-send-email-sgruszka@redhat.com> + +From: Stanislaw Gruszka + +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 +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 5 +++++ + drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 3 +++ + 2 files changed, 8 insertions(+) + +--- 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 mt7 + + 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, +--- 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 + 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, diff --git a/queue-4.20/mt76x0-phy-unify-calibration-between-mt76x0u-and-mt76x0e.patch b/queue-4.20/mt76x0-phy-unify-calibration-between-mt76x0u-and-mt76x0e.patch new file mode 100644 index 00000000000..fdd779e4ce1 --- /dev/null +++ b/queue-4.20/mt76x0-phy-unify-calibration-between-mt76x0u-and-mt76x0e.patch @@ -0,0 +1,184 @@ +From foo@baz Tue Jan 29 11:19:20 CET 2019 +From: Stanislaw Gruszka +Date: Tue, 22 Jan 2019 13:38:37 +0100 +Subject: mt76x0: phy: unify calibration between mt76x0u and mt76x0e +To: stable@vger.kernel.org +Cc: Felix Fietkau , linux-wireless@vger.kernel.org, Lorenzo Bianconi +Message-ID: <1548160717-4059-8-git-send-email-sgruszka@redhat.com> + +From: Lorenzo Bianconi + +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 +Signed-off-by: Felix Fietkau +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Greg Kroah-Hartman +--- + 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(-) + +--- 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 + * +--- 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 ieee + 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); +--- 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 + 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 mt76x0 + 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 mt76x0 + 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; +--- 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 ieee8021 + 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, diff --git a/queue-4.20/mt76x0-use-band-parameter-for-lc-calibration.patch b/queue-4.20/mt76x0-use-band-parameter-for-lc-calibration.patch new file mode 100644 index 00000000000..587472a22de --- /dev/null +++ b/queue-4.20/mt76x0-use-band-parameter-for-lc-calibration.patch @@ -0,0 +1,58 @@ +From ad3f993a0857ad3b792e7463828eb0d90cdd6f4d Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Thu, 25 Oct 2018 18:18:33 +0200 +Subject: mt76x0: use band parameter for LC calibration + +From: Stanislaw Gruszka + +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 +Signed-off-by: Felix Fietkau +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- 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 mt76x + 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 + 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 + + 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); diff --git a/queue-4.20/mt76x02-assure-we-update-gain-after-scan.patch b/queue-4.20/mt76x02-assure-we-update-gain-after-scan.patch new file mode 100644 index 00000000000..2d9d0db2cec --- /dev/null +++ b/queue-4.20/mt76x02-assure-we-update-gain-after-scan.patch @@ -0,0 +1,52 @@ +From foo@baz Tue Jan 29 11:19:20 CET 2019 +From: Stanislaw Gruszka +Date: Tue, 22 Jan 2019 13:38:34 +0100 +Subject: mt76x02: assure we update gain after scan +To: stable@vger.kernel.org +Cc: Felix Fietkau , linux-wireless@vger.kernel.org, Lorenzo Bianconi +Message-ID: <1548160717-4059-5-git-send-email-sgruszka@redhat.com> + +From: Stanislaw Gruszka + +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 +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Greg Kroah-Hartman +--- + 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(-) + +--- 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 ieee + + 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); + +--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c ++++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +@@ -834,7 +834,8 @@ mt76x0_phy_update_channel_gain(struct mt + 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) { diff --git a/queue-4.20/mt76x02-run-calibration-after-scanning.patch b/queue-4.20/mt76x02-run-calibration-after-scanning.patch new file mode 100644 index 00000000000..d5c0cca9a3e --- /dev/null +++ b/queue-4.20/mt76x02-run-calibration-after-scanning.patch @@ -0,0 +1,96 @@ +From f1b8ee35fec4a070b7760a99709fc98f237c2b86 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Thu, 1 Nov 2018 16:35:01 +0100 +Subject: mt76x02: run calibration after scanning + +From: Stanislaw Gruszka + +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 +Signed-off-by: Felix Fietkau +Signed-off-by: Greg Kroah-Hartman + + +--- + 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(-) + +--- 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 ieee + 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); + +--- 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 mt76x0 + + 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 mt76x0 + if (scan) + return 0; + ++ mt76x02_init_agc_gain(dev); + if (mt76_is_mmio(dev)) + mt76x0_phy_calibrate(dev, false); + mt76x0_phy_set_txpower(dev); +--- 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 { +--- 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 mt76x0 + 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); +--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c ++++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c +@@ -156,6 +156,9 @@ mt76x2u_sw_scan_complete(struct ieee8021 + 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 = { diff --git a/queue-4.20/revert-mm-memory_hotplug-initialize-struct-pages-for-the-full-memory-section.patch b/queue-4.20/revert-mm-memory_hotplug-initialize-struct-pages-for-the-full-memory-section.patch new file mode 100644 index 00000000000..36350af11a6 --- /dev/null +++ b/queue-4.20/revert-mm-memory_hotplug-initialize-struct-pages-for-the-full-memory-section.patch @@ -0,0 +1,65 @@ +From 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a Mon Sep 17 00:00:00 2001 +From: Michal Hocko +Date: Fri, 25 Jan 2019 19:08:58 +0100 +Subject: Revert "mm, memory_hotplug: initialize struct pages for the full memory section" + +From: Michal Hocko + +commit 4aa9fc2a435abe95a1e8d7f8c7b3d6356514b37a upstream. + +This reverts commit 2830bf6f05fb3e05bc4743274b806c821807a684. + +The underlying assumption that one sparse section belongs into a single +numa node doesn't hold really. Robert Shteynfeld has reported a boot +failure. The boot log was not captured but his memory layout is as +follows: + + Early memory node ranges + node 1: [mem 0x0000000000001000-0x0000000000090fff] + node 1: [mem 0x0000000000100000-0x00000000dbdf8fff] + node 1: [mem 0x0000000100000000-0x0000001423ffffff] + node 0: [mem 0x0000001424000000-0x0000002023ffffff] + +This means that node0 starts in the middle of a memory section which is +also in node1. memmap_init_zone tries to initialize padding of a +section even when it is outside of the given pfn range because there are +code paths (e.g. memory hotplug) which assume that the full worth of +memory section is always initialized. + +In this particular case, though, such a range is already intialized and +most likely already managed by the page allocator. Scribbling over +those pages corrupts the internal state and likely blows up when any of +those pages gets used. + +Reported-by: Robert Shteynfeld +Fixes: 2830bf6f05fb ("mm, memory_hotplug: initialize struct pages for the full memory section") +Cc: stable@kernel.org +Signed-off-by: Michal Hocko +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + mm/page_alloc.c | 12 ------------ + 1 file changed, 12 deletions(-) + +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -5542,18 +5542,6 @@ void __meminit memmap_init_zone(unsigned + cond_resched(); + } + } +-#ifdef CONFIG_SPARSEMEM +- /* +- * If the zone does not span the rest of the section then +- * we should at least initialize those pages. Otherwise we +- * could blow up on a poisoned page in some paths which depend +- * on full sections being initialized (e.g. memory hotplug). +- */ +- while (end_pfn % PAGES_PER_SECTION) { +- __init_single_page(pfn_to_page(end_pfn), end_pfn, zone, nid); +- end_pfn++; +- } +-#endif + } + + #ifdef CONFIG_ZONE_DEVICE diff --git a/queue-4.20/series b/queue-4.20/series index c01a712def7..287c96d86f8 100644 --- a/queue-4.20/series +++ b/queue-4.20/series @@ -105,3 +105,13 @@ bpf-fix-sanitation-of-alu-op-with-pointer-scalar-typ.patch bpf-fix-inner-map-masking-to-prevent-oob-under-specu.patch drivers-hv-vmbus-remove-the-useless-api-vmbus_get_ou.patch vmbus-fix-subchannel-removal.patch +revert-mm-memory_hotplug-initialize-struct-pages-for-the-full-memory-section.patch +usb-dwc3-gadget-clear-req-needs_extra_trb-flag-on-cleanup.patch +mt76x0-do-not-overwrite-other-mt_bbp-agc-8-fields.patch +mt76x0-use-band-parameter-for-lc-calibration.patch +mt76x02-run-calibration-after-scanning.patch +mt76x02-assure-we-update-gain-after-scan.patch +mt76x0-do-not-perform-mcu-calibration-for-mt7630.patch +mt76x0-antenna-select-corrections.patch +mt76x0-phy-unify-calibration-between-mt76x0u-and-mt76x0e.patch +ide-fix-a-typo-in-the-settings-proc-file-name.patch diff --git a/queue-4.20/usb-dwc3-gadget-clear-req-needs_extra_trb-flag-on-cleanup.patch b/queue-4.20/usb-dwc3-gadget-clear-req-needs_extra_trb-flag-on-cleanup.patch new file mode 100644 index 00000000000..91e8bbbae60 --- /dev/null +++ b/queue-4.20/usb-dwc3-gadget-clear-req-needs_extra_trb-flag-on-cleanup.patch @@ -0,0 +1,51 @@ +From bd6742249b9ca918565e4e3abaa06665e587f4b5 Mon Sep 17 00:00:00 2001 +From: Jack Pham +Date: Thu, 10 Jan 2019 12:39:55 -0800 +Subject: usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup + +From: Jack Pham + +commit bd6742249b9ca918565e4e3abaa06665e587f4b5 upstream. + +OUT endpoint requests may somtimes have this flag set when +preparing to be submitted to HW indicating that there is an +additional TRB chained to the request for alignment purposes. +If that request is removed before the controller can execute the +transfer (e.g. ep_dequeue/ep_disable), the request will not go +through the dwc3_gadget_ep_cleanup_completed_request() handler +and will not have its needs_extra_trb flag cleared when +dwc3_gadget_giveback() is called. This same request could be +later requeued for a new transfer that does not require an +extra TRB and if it is successfully completed, the cleanup +and TRB reclamation will incorrectly process the additional TRB +which belongs to the next request, and incorrectly advances the +TRB dequeue pointer, thereby messing up calculation of the next +requeust's actual/remaining count when it completes. + +The right thing to do here is to ensure that the flag is cleared +before it is given back to the function driver. A good place +to do that is in dwc3_gadget_del_and_unmap_request(). + +Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") +Cc: stable@vger.kernel.org +Signed-off-by: Jack Pham +Signed-off-by: Felipe Balbi +[jackp: backport to <= 4.20: replaced 'needs_extra_trb' with 'unaligned' + and 'zero' members in patch and reworded commit text] +Signed-off-by: Jack Pham +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/gadget.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -177,6 +177,8 @@ static void dwc3_gadget_del_and_unmap_re + req->started = false; + list_del(&req->list); + req->remaining = 0; ++ req->unaligned = false; ++ req->zero = false; + + if (req->request.status == -EINPROGRESS) + req->request.status = status;