To do not brake HW restart we should keep initialization vectors data.
I assumed that on start the data is already initialized to zeros, but
that not true on some scenarios and we should clear it. So add
additional flag to check if we are under HW restart and clear IV's
data if we are not.
Patch fixes AP mode regression.
Patch pending on linux-wireless and imported from patchwork.
Fixes: 0b2c42ced21a ("mac80211: Update to version 5.2-rc7")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
--- /dev/null
+From patchwork Mon Aug 19 11:20:07 2019
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Stanislaw Gruszka <sgruszka@redhat.com>
+X-Patchwork-Id: 11100685
+X-Patchwork-Delegate: kvalo@adurom.com
+Return-Path: <linux-wireless-owner@kernel.org>
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+To: linux-wireless@vger.kernel.org
+Subject: [PATCH 5.3] rt2x00: clear IV's on start to fix AP mode regression
+Date: Mon, 19 Aug 2019 13:20:07 +0200
+Message-Id: <1566213607-6723-1-git-send-email-sgruszka@redhat.com>
+Sender: linux-wireless-owner@vger.kernel.org
+List-ID: <linux-wireless.vger.kernel.org>
+X-Mailing-List: linux-wireless@vger.kernel.org
+
+To do not brake HW restart we should keep initialization vectors data.
+I assumed that on start the data is already initialized to zeros, but
+that not true on some scenarios and we should clear it. So add
+additional flag to check if we are under HW restart and clear IV's
+data if we are not.
+
+Patch fixes AP mode regression.
+
+Reported-and-tested-by: Emil Karlson <jekarl@iki.fi>
+Fixes: 710e6cc1595e ("rt2800: do not nullify initialization vector data")
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 +++++++++
+ drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 +
+ drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 13 ++++++++-----
+ 3 files changed, 18 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -6095,6 +6095,15 @@ static int rt2800_init_registers(struct
+ }
+
+ /*
++ * Clear encryption initialization vectors on start, but keep them
++ * for watchdog reset. Otherwise we will have wrong IVs and not be
++ * able to keep connections after reset.
++ */
++ if (!test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags))
++ for (i = 0; i < 256; i++)
++ rt2800_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0);
++
++ /*
+ * Clear all beacons
+ */
+ for (i = 0; i < 8; i++)
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -658,6 +658,7 @@ enum rt2x00_state_flags {
+ DEVICE_STATE_ENABLED_RADIO,
+ DEVICE_STATE_SCANNING,
+ DEVICE_STATE_FLUSHING,
++ DEVICE_STATE_RESET,
+
+ /*
+ * Driver configuration
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -1256,13 +1256,14 @@ static int rt2x00lib_initialize(struct r
+
+ int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
+ {
+- int retval;
++ int retval = 0;
+
+ if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) {
+ /*
+ * This is special case for ieee80211_restart_hw(), otherwise
+ * mac80211 never call start() two times in row without stop();
+ */
++ set_bit(DEVICE_STATE_RESET, &rt2x00dev->flags);
+ rt2x00dev->ops->lib->pre_reset_hw(rt2x00dev);
+ rt2x00lib_stop(rt2x00dev);
+ }
+@@ -1273,14 +1274,14 @@ int rt2x00lib_start(struct rt2x00_dev *r
+ */
+ retval = rt2x00lib_load_firmware(rt2x00dev);
+ if (retval)
+- return retval;
++ goto out;
+
+ /*
+ * Initialize the device.
+ */
+ retval = rt2x00lib_initialize(rt2x00dev);
+ if (retval)
+- return retval;
++ goto out;
+
+ rt2x00dev->intf_ap_count = 0;
+ rt2x00dev->intf_sta_count = 0;
+@@ -1289,11 +1290,13 @@ int rt2x00lib_start(struct rt2x00_dev *r
+ /* Enable the radio */
+ retval = rt2x00lib_enable_radio(rt2x00dev);
+ if (retval)
+- return retval;
++ goto out;
+
+ set_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags);
+
+- return 0;
++out:
++ clear_bit(DEVICE_STATE_RESET, &rt2x00dev->flags);
++ return retval;
+ }
+
+ void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev)
.drv_init_registers = rt2800mmio_init_registers,
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-@@ -694,6 +694,7 @@ enum rt2x00_capability_flags {
+@@ -695,6 +695,7 @@ enum rt2x00_capability_flags {
REQUIRE_HT_TX_DESC,
REQUIRE_PS_AUTOWAKE,
REQUIRE_DELAYED_RFKILL,
/*
* Capabilities
-@@ -970,6 +971,11 @@ struct rt2x00_dev {
+@@ -971,6 +972,11 @@ struct rt2x00_dev {
const struct firmware *fw;
/*
DECLARE_KFIFO_PTR(txstatus_fifo, u32);
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -1418,6 +1418,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
+@@ -1421,6 +1421,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup);
INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep);
/*
* Let the driver probe the device to detect the capabilities.
*/
-@@ -1561,6 +1565,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
+@@ -1564,6 +1568,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
* Free the driver data.
*/
kfree(rt2x00dev->drv_data);
#include "rt2x00.h"
#include "rt2800lib.h"
-@@ -9526,6 +9527,17 @@ static int rt2800_init_eeprom(struct rt2
+@@ -9535,6 +9536,17 @@ static int rt2800_init_eeprom(struct rt2
rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -1356,7 +1356,7 @@ static inline void rt2x00lib_set_if_comb
+@@ -1359,7 +1359,7 @@ static inline void rt2x00lib_set_if_comb
*/
if_limit = &rt2x00dev->if_limits_ap;
if_limit->max = rt2x00dev->ops->max_ap_intf;
bbp = rt2800_bbp_read(rt2x00dev, 4);
rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf));
rt2800_bbp_write(rt2x00dev, 4, bbp);
-@@ -9555,7 +9594,8 @@ static int rt2800_init_eeprom(struct rt2
+@@ -9564,7 +9603,8 @@ static int rt2800_init_eeprom(struct rt2
*/
eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1);
if (rt2x00_get_field16(eeprom,
EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
__set_bit(CAPABILITY_EXTERNAL_PA_TX0,
-@@ -9566,6 +9606,18 @@ static int rt2800_init_eeprom(struct rt2
+@@ -9575,6 +9615,18 @@ static int rt2800_init_eeprom(struct rt2
&rt2x00dev->cap_flags);
}
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
-@@ -8417,6 +8417,58 @@ static void rt2800_init_rfcsr_5592(struc
+@@ -8426,6 +8426,58 @@ static void rt2800_init_rfcsr_5592(struc
rt2800_led_open_drain_enable(rt2x00dev);
}
static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
bool set_bw, bool is_ht40)
{
-@@ -9024,6 +9076,7 @@ static void rt2800_init_rfcsr_6352(struc
+@@ -9033,6 +9085,7 @@ static void rt2800_init_rfcsr_6352(struc
rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
-@@ -8469,6 +8469,160 @@ void rt2800_rf_self_txdc_cal(struct rt2x
+@@ -8478,6 +8478,160 @@ void rt2800_rf_self_txdc_cal(struct rt2x
}
EXPORT_SYMBOL_GPL(rt2800_rf_self_txdc_cal);
static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
bool set_bw, bool is_ht40)
{
-@@ -9076,6 +9230,7 @@ static void rt2800_init_rfcsr_6352(struc
+@@ -9085,6 +9239,7 @@ static void rt2800_init_rfcsr_6352(struc
rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
-@@ -8623,6 +8623,71 @@ void rt2800_r_calibration(struct rt2x00_
+@@ -8632,6 +8632,71 @@ void rt2800_r_calibration(struct rt2x00_
}
EXPORT_SYMBOL_GPL(rt2800_r_calibration);
static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
bool set_bw, bool is_ht40)
{
-@@ -9232,6 +9297,7 @@ static void rt2800_init_rfcsr_6352(struc
+@@ -9241,6 +9306,7 @@ static void rt2800_init_rfcsr_6352(struc
rt2800_r_calibration(rt2x00dev);
rt2800_rf_self_txdc_cal(rt2x00dev);
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
-@@ -8688,6 +8688,386 @@ void rt2800_rxdcoc_calibration(struct rt
+@@ -8697,6 +8697,386 @@ void rt2800_rxdcoc_calibration(struct rt
}
EXPORT_SYMBOL_GPL(rt2800_rxdcoc_calibration);
static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
bool set_bw, bool is_ht40)
{
-@@ -9300,6 +9680,7 @@ static void rt2800_init_rfcsr_6352(struc
+@@ -9309,6 +9689,7 @@ static void rt2800_init_rfcsr_6352(struc
rt2800_rxdcoc_calibration(rt2x00dev);
rt2800_bw_filter_calibration(rt2x00dev, true);
rt2800_bw_filter_calibration(rt2x00dev, false);
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
-@@ -9068,6 +9068,954 @@ restore_value:
+@@ -9077,6 +9077,954 @@ restore_value:
}
EXPORT_SYMBOL_GPL(rt2800_rxiq_calibration);
static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
bool set_bw, bool is_ht40)
{
-@@ -9680,6 +10628,7 @@ static void rt2800_init_rfcsr_6352(struc
+@@ -9689,6 +10637,7 @@ static void rt2800_init_rfcsr_6352(struc
rt2800_rxdcoc_calibration(rt2x00dev);
rt2800_bw_filter_calibration(rt2x00dev, true);
rt2800_bw_filter_calibration(rt2x00dev, false);