iwlwifi: avoid debug max amsdu config overwriting itself
authorMordechay Goodstein <mordechay.goodstein@intel.com>
Fri, 24 Apr 2020 15:48:15 +0000 (18:48 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 8 May 2020 06:51:00 +0000 (09:51 +0300)
If we set amsdu_len one after another the second one overwrites
the orig_amsdu_len so allow only moving from debug to non debug state.

Also the TLC update check was wrong: it was checking that also the orig
is smaller then the new updated size, which is not the case in debug
amsdu mode.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Fixes: af2984e9e625 ("iwlwifi: mvm: add a debugfs entry to set a fixed size AMSDU for all TX packets")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200424182644.e565446a4fce.I9729d8c520d8b8bb4de9a5cdc62e01eb85168aac@changeid
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c

index 3beef8d077b82efeca138c00460a668a30a575b3..8fae7e707374b998b2583e0b37435a489ccb093c 100644 (file)
@@ -5,10 +5,9 @@
  *
  * GPL LICENSE SUMMARY
  *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019 Intel Corporation
+ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
  *
  * BSD LICENSE
  *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019 Intel Corporation
+ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -481,6 +479,11 @@ static ssize_t iwl_dbgfs_amsdu_len_write(struct ieee80211_sta *sta,
        if (kstrtou16(buf, 0, &amsdu_len))
                return -EINVAL;
 
+       /* only change from debug set <-> debug unset */
+       if ((amsdu_len && mvmsta->orig_amsdu_len) ||
+           (!!amsdu_len && mvmsta->orig_amsdu_len))
+               return -EBUSY;
+
        if (amsdu_len) {
                mvmsta->orig_amsdu_len = sta->max_amsdu_len;
                sta->max_amsdu_len = amsdu_len;
index 15d11fb72aca49790d6061d7f9126e8b324e4f42..6f4d241d47e9f9b45d3d93035f5655d7ba9e924a 100644 (file)
@@ -369,14 +369,15 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm,
                u16 size = le32_to_cpu(notif->amsdu_size);
                int i;
 
-               /*
-                * In debug sta->max_amsdu_len < size
-                * so also check with orig_amsdu_len which holds the original
-                * data before debugfs changed the value
-                */
-               if (WARN_ON(sta->max_amsdu_len < size &&
-                           mvmsta->orig_amsdu_len < size))
+               if (sta->max_amsdu_len < size) {
+                       /*
+                        * In debug sta->max_amsdu_len < size
+                        * so also check with orig_amsdu_len which holds the
+                        * original data before debugfs changed the value
+                        */
+                       WARN_ON(mvmsta->orig_amsdu_len < size);
                        goto out;
+               }
 
                mvmsta->amsdu_enabled = le32_to_cpu(notif->amsdu_enabled);
                mvmsta->max_amsdu_len = size;