]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
iwlwifi: track current firmware image in common code
authorJohannes Berg <johannes.berg@intel.com>
Fri, 2 Jun 2017 09:56:58 +0000 (11:56 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Tue, 1 Aug 2017 09:41:43 +0000 (12:41 +0300)
Track the current firmware image in the common code instead
of in the opmode so that later patches can access it there
in a common way.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/runtime.h
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/mvm/power.c
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
drivers/net/wireless/intel/iwlwifi/mvm/utils.c

index 185902ce7e130a300f5f0828410ac57998095c53..c483a76cb0e567aa35bf06e452573318bf3f864c 100644 (file)
@@ -85,6 +85,8 @@ struct iwl_fwrt_shared_mem_cfg {
  * @num_of_paging_blk: number of paging blocks
  * @num_of_pages_in_last_blk: number of pages in the last block
  * @smem_cfg: saved firmware SMEM configuration
+ * @cur_fw_img: current firmware image, must be maintained by
+ *     the driver by calling &iwl_fw_set_current_image()
  */
 struct iwl_fw_runtime {
        struct iwl_trans *trans;
@@ -96,6 +98,8 @@ struct iwl_fw_runtime {
        u16 num_of_paging_blk;
        u16 num_of_pages_in_last_blk;
 
+       enum iwl_ucode_type cur_fw_img;
+
        /* memory configuration */
        struct iwl_fwrt_shared_mem_cfg smem_cfg;
 };
@@ -110,6 +114,12 @@ static inline void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt,
        fwrt->dev = trans->dev;
 }
 
+static inline void iwl_fw_set_current_image(struct iwl_fw_runtime *fwrt,
+                                           enum iwl_ucode_type cur_fw_img)
+{
+       fwrt->cur_fw_img = cur_fw_img;
+}
+
 int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type);
 void iwl_free_fw_paging(struct iwl_fw_runtime *fwrt);
 
index c1c9c489edc90b62c4fdefd00203484d40caf03d..9991494314e24db31d9aff780cf2dc5baebe163f 100644 (file)
@@ -84,7 +84,7 @@ static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
        int pos, budget;
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR)
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
                return -EIO;
 
        mutex_lock(&mvm->mutex);
@@ -105,7 +105,7 @@ static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
        int ret;
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR)
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
                return -EIO;
 
        mutex_lock(&mvm->mutex);
@@ -122,7 +122,7 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
        u32 flush_arg;
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR)
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
                return -EIO;
 
        if (kstrtou32(buf, 0, &flush_arg))
@@ -155,7 +155,7 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
        int sta_id, drain, ret;
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR)
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
                return -EIO;
 
        if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
@@ -192,7 +192,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
                return -EINVAL;
 
        /* default is to dump the entire data segment */
-       img = &mvm->fw->img[mvm->cur_ucode];
+       img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
        ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
        len = img->sec[IWL_UCODE_SECTION_DATA].len;
 
@@ -224,7 +224,7 @@ static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
        if (!iwl_mvm_firmware_running(mvm))
                return -EINVAL;
 
-       img = &mvm->fw->img[mvm->cur_ucode];
+       img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
        img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
        img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
 
index 9d54005b6d507cb7f405b8418ff45d5555637d54..0c12e604f22bdd293976086c7def33a53901d748 100644 (file)
@@ -572,7 +572,7 @@ void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
        if (!mvm->cfg->dccm_offset || !mvm->cfg->dccm_len) {
                const struct fw_img *img;
 
-               img = &mvm->fw->img[mvm->cur_ucode];
+               img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
                sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
                sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
        } else {
@@ -693,7 +693,7 @@ void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
 
        /* Make room for fw's virtual image pages, if it exists */
        if (!mvm->trans->cfg->gen2 &&
-           mvm->fw->img[mvm->cur_ucode].paging_mem_size &&
+           mvm->fw->img[mvm->fwrt.cur_fw_img].paging_mem_size &&
            mvm->fwrt.fw_paging_db[0].fw_paging_block)
                file_len += mvm->fwrt.num_of_paging_blk *
                        (sizeof(*dump_data) +
@@ -832,7 +832,7 @@ void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
 
        /* Dump fw's virtual image */
        if (!mvm->trans->cfg->gen2 &&
-           mvm->fw->img[mvm->cur_ucode].paging_mem_size &&
+           mvm->fw->img[mvm->fwrt.cur_fw_img].paging_mem_size &&
            mvm->fwrt.fw_paging_db[0].fw_paging_block) {
                for (i = 1; i < mvm->fwrt.num_of_paging_blk + 1; i++) {
                        struct iwl_fw_error_dump_paging *paging;
index 161b7452baa2290fbc99d52e7943011fa2db089f..08108620b9776e73aad7d0e240ba3433992950e5 100644 (file)
@@ -251,7 +251,7 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
        struct iwl_mvm_alive_data alive_data;
        const struct fw_img *fw;
        int ret, i;
-       enum iwl_ucode_type old_type = mvm->cur_ucode;
+       enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img;
        static const u16 alive_cmd[] = { MVM_ALIVE };
        struct iwl_sf_region st_fwrd_space;
 
@@ -264,7 +264,7 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
                fw = iwl_get_ucode_image(mvm->fw, ucode_type);
        if (WARN_ON(!fw))
                return -EINVAL;
-       mvm->cur_ucode = ucode_type;
+       iwl_fw_set_current_image(&mvm->fwrt, ucode_type);
        clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
 
        iwl_init_notification_wait(&mvm->notif_wait, &alive_wait,
@@ -273,7 +273,7 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
 
        ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT);
        if (ret) {
-               mvm->cur_ucode = old_type;
+               iwl_fw_set_current_image(&mvm->fwrt, old_type);
                iwl_remove_notification(&mvm->notif_wait, &alive_wait);
                return ret;
        }
@@ -297,13 +297,13 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
                                "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
                                iwl_read_prph(trans, SB_CPU_1_STATUS),
                                iwl_read_prph(trans, SB_CPU_2_STATUS));
-               mvm->cur_ucode = old_type;
+               iwl_fw_set_current_image(&mvm->fwrt, old_type);
                return ret;
        }
 
        if (!alive_data.valid) {
                IWL_ERR(mvm, "Loaded ucode is not valid!\n");
-               mvm->cur_ucode = old_type;
+               iwl_fw_set_current_image(&mvm->fwrt, old_type);
                return -EIO;
        }
 
@@ -432,7 +432,7 @@ error:
 static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
 {
        struct iwl_phy_cfg_cmd phy_cfg_cmd;
-       enum iwl_ucode_type ucode_type = mvm->cur_ucode;
+       enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img;
 
        /* Set parameters */
        phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm));
@@ -1064,7 +1064,7 @@ static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)
        if (ret)
                return ret;
 
-       return iwl_init_paging(&mvm->fwrt, mvm->cur_ucode);
+       return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img);
 }
 
 int iwl_mvm_up(struct iwl_mvm *mvm)
index 739e7cbea82ff6af63c11f7d7df00108bd74c72c..988f4c331d151988ce9a3e3d4856fe3159899b3e 100644 (file)
@@ -754,7 +754,6 @@ struct iwl_mvm {
         */
        struct iwl_mvm_vif *bf_allowed_vif;
 
-       enum iwl_ucode_type cur_ucode;
        bool hw_registered;
        bool calibrating;
        u32 error_event_table[2];
index 8c49ac903c8c253948e028beca8940ed1ad68654..60f0c9975538e1170f5f8eff213b15b4f5dac550 100644 (file)
@@ -621,9 +621,9 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
        }
        mvm->sf_state = SF_UNINIT;
        if (iwl_mvm_has_new_tx_api(mvm))
-               mvm->cur_ucode = IWL_UCODE_REGULAR;
+               iwl_fw_set_current_image(&mvm->fwrt, IWL_UCODE_REGULAR);
        else
-               mvm->cur_ucode = IWL_UCODE_INIT;
+               iwl_fw_set_current_image(&mvm->fwrt, IWL_UCODE_INIT);
        mvm->drop_bcn_ap_mode = true;
 
        mutex_init(&mvm->mutex);
@@ -1133,7 +1133,7 @@ static bool iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
         * Stop the device if we run OPERATIONAL firmware or if we are in the
         * middle of the calibrations.
         */
-       return state && (mvm->cur_ucode != IWL_UCODE_INIT || calibrating);
+       return state && (mvm->fwrt.cur_fw_img != IWL_UCODE_INIT || calibrating);
 }
 
 static void iwl_mvm_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb)
@@ -1263,7 +1263,7 @@ void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error)
                reprobe->dev = mvm->trans->dev;
                INIT_WORK(&reprobe->work, iwl_mvm_reprobe_wk);
                schedule_work(&reprobe->work);
-       } else if (mvm->cur_ucode == IWL_UCODE_REGULAR &&
+       } else if (mvm->fwrt.cur_fw_img == IWL_UCODE_REGULAR &&
                   mvm->hw_registered) {
                /* don't let the transport/FW power down */
                iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
@@ -1441,7 +1441,7 @@ int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
 
        IWL_DEBUG_RPM(mvm, "MVM entering D0i3\n");
 
-       if (WARN_ON_ONCE(mvm->cur_ucode != IWL_UCODE_REGULAR))
+       if (WARN_ON_ONCE(mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR))
                return -EINVAL;
 
        set_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status);
@@ -1667,7 +1667,7 @@ int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm)
 
        IWL_DEBUG_RPM(mvm, "MVM exiting D0i3\n");
 
-       if (WARN_ON_ONCE(mvm->cur_ucode != IWL_UCODE_REGULAR))
+       if (WARN_ON_ONCE(mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR))
                return -EINVAL;
 
        mutex_lock(&mvm->d0i3_suspend_mutex);
index e684811f8e8b3156b4f392d1fc5624a299d22465..c05e5ac565aed93c39950cd456760ccd76f70b5b 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
- * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
+ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  *
  * 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
@@ -34,7 +34,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
- * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
+ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -186,7 +186,7 @@ static void iwl_mvm_power_configure_uapsd(struct iwl_mvm *mvm,
                if (!mvmvif->queue_params[ac].uapsd)
                        continue;
 
-               if (mvm->cur_ucode != IWL_UCODE_WOWLAN)
+               if (mvm->fwrt.cur_fw_img != IWL_UCODE_WOWLAN)
                        cmd->flags |=
                                cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK);
 
@@ -220,14 +220,15 @@ static void iwl_mvm_power_configure_uapsd(struct iwl_mvm *mvm,
                                    BIT(IEEE80211_AC_BK))) {
                cmd->flags |= cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
                cmd->snooze_interval = cpu_to_le16(IWL_MVM_PS_SNOOZE_INTERVAL);
-               cmd->snooze_window = (mvm->cur_ucode == IWL_UCODE_WOWLAN) ?
-                       cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) :
-                       cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW);
+               cmd->snooze_window =
+                       (mvm->fwrt.cur_fw_img == IWL_UCODE_WOWLAN) ?
+                               cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) :
+                               cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW);
        }
 
        cmd->uapsd_max_sp = mvm->hw->uapsd_max_sp_len;
 
-       if (mvm->cur_ucode == IWL_UCODE_WOWLAN || cmd->flags &
+       if (mvm->fwrt.cur_fw_img == IWL_UCODE_WOWLAN || cmd->flags &
            cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
                cmd->rx_data_timeout_uapsd =
                        cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
@@ -502,7 +503,7 @@ static int iwl_mvm_power_send_cmd(struct iwl_mvm *mvm,
        struct iwl_mac_power_cmd cmd = {};
 
        iwl_mvm_power_build_cmd(mvm, vif, &cmd,
-                               mvm->cur_ucode != IWL_UCODE_WOWLAN);
+                               mvm->fwrt.cur_fw_img != IWL_UCODE_WOWLAN);
        iwl_mvm_power_log(mvm, &cmd);
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        memcpy(&iwl_mvm_vif_from_mac80211(vif)->mac_pwr_cmd, &cmd, sizeof(cmd));
@@ -525,8 +526,8 @@ int iwl_mvm_power_update_device(struct iwl_mvm *mvm)
                cmd.flags |= cpu_to_le16(DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK);
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
-       if ((mvm->cur_ucode == IWL_UCODE_WOWLAN) ? mvm->disable_power_off_d3 :
-           mvm->disable_power_off)
+       if ((mvm->fwrt.cur_fw_img == IWL_UCODE_WOWLAN) ?
+                       mvm->disable_power_off_d3 : mvm->disable_power_off)
                cmd.flags &=
                        cpu_to_le16(~DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK);
 #endif
@@ -933,7 +934,7 @@ static int iwl_mvm_power_set_ba(struct iwl_mvm *mvm,
        if (!mvmvif->bf_data.bf_enabled)
                return 0;
 
-       if (mvm->cur_ucode == IWL_UCODE_WOWLAN)
+       if (mvm->fwrt.cur_fw_img == IWL_UCODE_WOWLAN)
                cmd.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_D3);
 
        mvmvif->bf_data.ba_enabled = !(!mvmvif->pm_enabled ||
index 453a785a3ea5e91a8a68a475aa2c6a6b1d8f1ff2..a638bd69a1f9ac41daedc1cc5339ed312c11f8cc 100644 (file)
@@ -629,7 +629,7 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
        mutex_lock(&mvm->mutex);
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR) {
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
                ret = -EIO;
                goto out;
        }
@@ -680,7 +680,7 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
        mutex_lock(&mvm->mutex);
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR) {
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
                ret = -EIO;
                goto out;
        }
@@ -795,7 +795,7 @@ static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev,
        mutex_lock(&mvm->mutex);
 
        if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->cur_ucode != IWL_UCODE_REGULAR) {
+           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
                ret = -EIO;
                goto unlock;
        }
index fc5a490880d0c0fca8232ddea6213b9aa7a09a65..4e80c8fa47417e6c64890a3d04c7aa52654ff865 100644 (file)
@@ -464,8 +464,8 @@ static void iwl_mvm_dump_umac_error_log(struct iwl_mvm *mvm)
                IWL_ERR(mvm,
                        "Not valid error log pointer 0x%08X for %s uCode\n",
                        base,
-                       (mvm->cur_ucode == IWL_UCODE_INIT)
-                                       ? "Init" : "RT");
+                       (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT)
+                       ? "Init" : "RT");
                return;
        }
 
@@ -500,7 +500,7 @@ static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm *mvm, u32 base)
        struct iwl_error_event_table table;
        u32 val;
 
-       if (mvm->cur_ucode == IWL_UCODE_INIT) {
+       if (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) {
                if (!base)
                        base = mvm->fw->init_errlog_ptr;
        } else {
@@ -512,8 +512,8 @@ static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm *mvm, u32 base)
                IWL_ERR(mvm,
                        "Not valid error log pointer 0x%08X for %s uCode\n",
                        base,
-                       (mvm->cur_ucode == IWL_UCODE_INIT)
-                                       ? "Init" : "RT");
+                       (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT)
+                       ? "Init" : "RT");
                return;
        }