wifi: iwlwifi: mvm: make "pldr_sync" mode effective
authorJohannes Berg <johannes.berg@intel.com>
Wed, 13 Sep 2023 11:56:43 +0000 (14:56 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 13 Sep 2023 14:11:40 +0000 (16:11 +0200)
If the device initialized with ME active, this would indeed
work, since the NVM information would be obtained from ME.
However, in the much more likely case that ME isn't active
and the firmware takes actions requiring the sync, this was
not working correctly when the firmware is only run at init
to obtain NVM data, since mac80211 isn't even initialized.

Fix this by moving the 'pldr_sync' handling to a different
place.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230913145231.45a94d480e56.Id9277f1df6a63ab0dfca0d0c0f448c759e1b8e73@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/ops.c

index f682c9067abb495a33ea14af6e284412dd235db0..567b02754a438ad9cd9140eb4b327f420f75c83d 100644 (file)
@@ -583,6 +583,7 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm)
        static const u16 init_complete[] = {
                INIT_COMPLETE_NOTIF,
        };
+       u32 sb_cfg;
        int ret;
 
        if (mvm->trans->cfg->tx_with_siso_diversity)
@@ -592,6 +593,12 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm)
 
        mvm->rfkill_safe_init_done = false;
 
+       sb_cfg = iwl_read_umac_prph(mvm->trans, SB_MODIFY_CFG_FLAG);
+       /* if needed, we'll reset this on our way out later */
+       mvm->pldr_sync = !(sb_cfg & SB_CFG_RESIDES_IN_OTP_MASK);
+       if (mvm->pldr_sync && iwl_mei_pldr_req())
+               return -EBUSY;
+
        iwl_init_notification_wait(&mvm->notif_wait,
                                   &init_wait,
                                   init_complete,
@@ -605,6 +612,13 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm)
        ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
        if (ret) {
                IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
+
+               /* if we needed reset then fail here, but notify and remove */
+               if (mvm->pldr_sync) {
+                       iwl_mei_alive_notif(false);
+                       iwl_trans_pcie_remove(mvm->trans, true);
+               }
+
                goto error;
        }
        iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_AFTER_ALIVE,
@@ -1502,7 +1516,6 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
        struct ieee80211_channel *chan;
        struct cfg80211_chan_def chandef;
        struct ieee80211_supported_band *sband = NULL;
-       u32 sb_cfg;
 
        lockdep_assert_held(&mvm->mutex);
 
@@ -1510,11 +1523,6 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
        if (ret)
                return ret;
 
-       sb_cfg = iwl_read_umac_prph(mvm->trans, SB_MODIFY_CFG_FLAG);
-       mvm->pldr_sync = !(sb_cfg & SB_CFG_RESIDES_IN_OTP_MASK);
-       if (mvm->pldr_sync && iwl_mei_pldr_req())
-               return -EBUSY;
-
        ret = iwl_mvm_load_rt_fw(mvm);
        if (ret) {
                IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
index a4ac178d76b3714fa2812daa1db017be7c8b38ca..93223f8c07b48845d7980b91b17281d17273e250 100644 (file)
@@ -1169,18 +1169,8 @@ int iwl_mvm_mac_start(struct ieee80211_hw *hw)
 
        for (retry = 0; retry <= max_retry; retry++) {
                ret = __iwl_mvm_mac_start(mvm);
-               if (!ret)
-                       break;
-
-               /*
-                * In PLDR sync PCI re-enumeration is needed. no point to retry
-                * mac start before that.
-                */
-               if (mvm->pldr_sync) {
-                       iwl_mei_alive_notif(false);
-                       iwl_trans_pcie_remove(mvm->trans, true);
+               if (!ret || mvm->pldr_sync)
                        break;
-               }
 
                IWL_ERR(mvm, "mac start retry %d\n", retry);
        }
index d4983abd9f9710d0ae4edbcc92f479cfb7859b01..1c21a313f8f1ed960db2cb81e55bd46adac3749d 100644 (file)
@@ -790,6 +790,9 @@ get_nvm_from_fw:
        if (ret)
                IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
 
+       /* no longer need this regardless of failure or not */
+       mvm->pldr_sync = false;
+
        return ret;
 }