]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iwlwifi: fw: add a restart FW debug function
authorSara Sharon <sara.sharon@intel.com>
Thu, 17 May 2018 11:04:19 +0000 (14:04 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 28 Sep 2018 05:57:20 +0000 (08:57 +0300)
Move the restart FW debug code to a function. This avoids code
duplication and lays the infra to support the new start and stop
host commands in some future devices.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/fw/dbg.h
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
drivers/net/wireless/intel/iwlwifi/pcie/trans.c

index 9963d6c84908c58d47bdef979d4e7b815e9e47a6..b0da16f3f47484681837777f65c17ec906b5179f 100644 (file)
@@ -1149,6 +1149,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work)
 {
        struct iwl_fw_runtime *fwrt =
                container_of(work, struct iwl_fw_runtime, dump.wk.work);
+       struct iwl_fw_dbg_params params = {0};
 
        if (fwrt->ops && fwrt->ops->dump_start &&
            fwrt->ops->dump_start(fwrt->ops_ctx))
@@ -1162,38 +1163,16 @@ void iwl_fw_error_dump_wk(struct work_struct *work)
                goto out;
        }
 
-       if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
-               /* stop recording */
-               iwl_fw_dbg_stop_recording(fwrt->trans);
-
-               iwl_fw_error_dump(fwrt);
-
-               /* start recording again if the firmware is not crashed */
-               if (!test_bit(STATUS_FW_ERROR, &fwrt->trans->status) &&
-                   fwrt->fw->dbg_dest_tlv) {
-                       iwl_clear_bits_prph(fwrt->trans,
-                                           MON_BUFF_SAMPLE_CTL, 0x100);
-                       iwl_clear_bits_prph(fwrt->trans,
-                                           MON_BUFF_SAMPLE_CTL, 0x1);
-                       iwl_set_bits_prph(fwrt->trans,
-                                         MON_BUFF_SAMPLE_CTL, 0x1);
-               }
-       } else {
-               u32 in_sample = iwl_read_prph(fwrt->trans, DBGC_IN_SAMPLE);
-               u32 out_ctrl = iwl_read_prph(fwrt->trans, DBGC_OUT_CTRL);
+       iwl_fw_dbg_stop_recording(fwrt->trans, &params);
+
+       iwl_fw_error_dump(fwrt);
 
-               iwl_fw_dbg_stop_recording(fwrt->trans);
+       /* start recording again if the firmware is not crashed */
+       if (!test_bit(STATUS_FW_ERROR, &fwrt->trans->status) &&
+           fwrt->fw->dbg_dest_tlv) {
                /* wait before we collect the data till the DBGC stop */
                udelay(500);
-
-               iwl_fw_error_dump(fwrt);
-
-               /* start recording again if the firmware is not crashed */
-               if (!test_bit(STATUS_FW_ERROR, &fwrt->trans->status) &&
-                   fwrt->fw->dbg_dest_tlv) {
-                       iwl_write_prph(fwrt->trans, DBGC_IN_SAMPLE, in_sample);
-                       iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, out_ctrl);
-               }
+               iwl_fw_dbg_restart_recording(fwrt->trans, &params);
        }
 out:
        if (fwrt->ops && fwrt->ops->dump_end)
index d04e68104ded66336245ed1286c53d4837f73337..878758b6c7ae8416898021d6c113f0ee1267259c 100644 (file)
@@ -83,6 +83,16 @@ struct iwl_fw_dump_desc {
        struct iwl_fw_error_dump_trigger_desc trig_desc;
 };
 
+/**
+ * struct iwl_fw_dbg_params - register values to restore
+ * @in_sample: DBGC_IN_SAMPLE value
+ * @out_ctrl: DBGC_OUT_CTRL value
+ */
+struct iwl_fw_dbg_params {
+       u32 in_sample;
+       u32 out_ctrl;
+};
+
 extern const struct iwl_fw_dump_desc iwl_dump_desc_assert;
 
 static inline void iwl_fw_free_dump_desc(struct iwl_fw_runtime *fwrt)
@@ -196,14 +206,40 @@ _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt,
                                        iwl_fw_dbg_get_trigger((fwrt)->fw,\
                                                               (trig)))
 
-static inline void iwl_fw_dbg_stop_recording(struct iwl_trans *trans)
+static inline void
+iwl_fw_dbg_stop_recording(struct iwl_trans *trans,
+                         struct iwl_fw_dbg_params *params)
 {
        if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
                iwl_set_bits_prph(trans, MON_BUFF_SAMPLE_CTL, 0x100);
+               return;
+       }
+
+       if (params) {
+               params->in_sample = iwl_read_prph(trans, DBGC_IN_SAMPLE);
+               params->out_ctrl = iwl_read_prph(trans, DBGC_OUT_CTRL);
+       }
+
+       iwl_write_prph(trans, DBGC_IN_SAMPLE, 0);
+       udelay(100);
+       iwl_write_prph(trans, DBGC_OUT_CTRL, 0);
+}
+
+static inline void
+iwl_fw_dbg_restart_recording(struct iwl_trans *trans,
+                            struct iwl_fw_dbg_params *params)
+{
+       if (WARN_ON(!params))
+               return;
+
+       if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
+               iwl_clear_bits_prph(trans, MON_BUFF_SAMPLE_CTL, 0x100);
+               iwl_clear_bits_prph(trans, MON_BUFF_SAMPLE_CTL, 0x1);
+               iwl_set_bits_prph(trans, MON_BUFF_SAMPLE_CTL, 0x1);
        } else {
-               iwl_write_prph(trans, DBGC_IN_SAMPLE, 0);
+               iwl_write_prph(trans, DBGC_IN_SAMPLE, params->in_sample);
                udelay(100);
-               iwl_write_prph(trans, DBGC_OUT_CTRL, 0);
+               iwl_write_prph(trans, DBGC_OUT_CTRL, params->out_ctrl);
        }
 }
 
index 99050c8dd43215001fb54a6ef48fc8869a7b4719..5305342439b22983c1ef9b2457187a6a632091e0 100644 (file)
@@ -1042,7 +1042,7 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
         * the recording automatically before entering D3.  This can
         * be removed once the FW starts doing that.
         */
-       iwl_fw_dbg_stop_recording(mvm->fwrt.trans);
+       iwl_fw_dbg_stop_recording(mvm->fwrt.trans, NULL);
 
        /* must be last -- this switches firmware state */
        ret = iwl_mvm_send_cmd(mvm, &d3_cfg_cmd);
index 5f61b02e651e64fa813d4966f1a1ab3c4b11d2b1..b5902c74e5d0365d3701cce4e491e72c3b31026e 100644 (file)
@@ -165,7 +165,7 @@ void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power)
        trans_pcie->is_down = true;
 
        /* Stop dbgc before stopping device */
-       iwl_fw_dbg_stop_recording(trans);
+       iwl_fw_dbg_stop_recording(trans, NULL);
 
        /* tell the device to stop sending interrupts */
        iwl_disable_interrupts(trans);
index cc8c53dc0ab67f72764afe9e2b0bfa1af0a7294a..5ecd5c8d0f0248404604e366cc3d6d1097a51347 100644 (file)
@@ -1243,7 +1243,7 @@ static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
        trans_pcie->is_down = true;
 
        /* Stop dbgc before stopping device */
-       iwl_fw_dbg_stop_recording(trans);
+       iwl_fw_dbg_stop_recording(trans, NULL);
 
        /* tell the device to stop sending interrupts */
        iwl_disable_interrupts(trans);