]> www.infradead.org Git - users/hch/misc.git/commitdiff
wifi: iwlwifi: simplify iwl_trans_pcie_d3_resume
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 26 Aug 2025 15:55:01 +0000 (18:55 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Thu, 28 Aug 2025 06:56:42 +0000 (09:56 +0300)
If iwl_trans_d3_resume succeeded but the hw requested a reset, this will
be indicated to the opmode via the iwl_d3_status parameter while the return
value will be 0.

But the opmode doesn't really care if the resume failed or if a restart
is required. It acts the same in both cases (beside different logs, but
this can be done in iwl_trans_pcie_d3_resume)

This complicates the code for no good reason.

Change the iwl_trans_pcie_d3_resume to return an error value also in the
case that everything went successfully but a restart is required,
and add more logs so we can differentiate between the cases.

This makes iwl_d3_status redundant. Remove it as well.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250826184046.5fa2d909c75d.Ida19d8d8d73eddf12b30f1d473ea675f415778b2@changeid
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/iwl-trans.c
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
drivers/net/wireless/intel/iwlwifi/mld/d3.c
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/internal.h
drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c

index f1a39169eb4d65dce247cfd7d1525c8af4dc78a6..a0a26ef482a5ef4e8c02d121b5a79c04a1b77d5d 100644 (file)
@@ -422,7 +422,6 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        struct ieee80211_vif *vif;
        u32 base;
        int ret;
-       enum iwl_d3_status d3_status;
        struct error_table_start {
                /* cf. struct iwl_error_event_table */
                u32 valid;
@@ -451,15 +450,10 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        /* we'll clear ctx->vif during iwlagn_prepare_restart() */
        vif = ctx->vif;
 
-       ret = iwl_trans_d3_resume(priv->trans, &d3_status, true);
+       ret = iwl_trans_d3_resume(priv->trans, true);
        if (ret)
                goto out_unlock;
 
-       if (d3_status != IWL_D3_STATUS_ALIVE) {
-               IWL_INFO(priv, "Device was reset during suspend\n");
-               goto out_unlock;
-       }
-
        /* uCode is no longer operating by itself */
        iwl_write32(priv->trans, CSR_UCODE_DRV_GP1_CLR,
                    CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
index d68a820c3d4873e0e18dfea16b55e0719e19d404..a19ffff2fffba630cfd22c17b82bc2cae06bbbf2 100644 (file)
@@ -510,12 +510,11 @@ int iwl_trans_d3_suspend(struct iwl_trans *trans, bool reset)
 }
 IWL_EXPORT_SYMBOL(iwl_trans_d3_suspend);
 
-int iwl_trans_d3_resume(struct iwl_trans *trans, enum iwl_d3_status *status,
-                       bool reset)
+int iwl_trans_d3_resume(struct iwl_trans *trans, bool reset)
 {
        might_sleep();
 
-       return iwl_trans_pcie_d3_resume(trans, status, reset);
+       return iwl_trans_pcie_d3_resume(trans, reset);
 }
 IWL_EXPORT_SYMBOL(iwl_trans_d3_resume);
 
index 0fca6992ec5b0cf4c55cee5ec734da516773892c..b0bf88a889b4d7c464e4211744ca839b34224ed1 100644 (file)
@@ -274,16 +274,6 @@ static inline void iwl_free_rxb(struct iwl_rx_cmd_buffer *r)
 #define IWL_MAX_RX_HW_QUEUES   16
 #define IWL_9000_MAX_RX_HW_QUEUES      1
 
-/**
- * enum iwl_d3_status - WoWLAN image/device status
- * @IWL_D3_STATUS_ALIVE: firmware is still running after resume
- * @IWL_D3_STATUS_RESET: device was reset while suspended
- */
-enum iwl_d3_status {
-       IWL_D3_STATUS_ALIVE,
-       IWL_D3_STATUS_RESET,
-};
-
 /**
  * enum iwl_trans_status: transport status flags
  * @STATUS_SYNC_HCMD_ACTIVE: a SYNC command is being processed
@@ -951,8 +941,7 @@ void iwl_trans_stop_device(struct iwl_trans *trans);
 
 int iwl_trans_d3_suspend(struct iwl_trans *trans, bool reset);
 
-int iwl_trans_d3_resume(struct iwl_trans *trans, enum iwl_d3_status *status,
-                       bool reset);
+int iwl_trans_d3_resume(struct iwl_trans *trans, bool reset);
 
 struct iwl_trans_dump_data *
 iwl_trans_dump_data(struct iwl_trans *trans, u32 dump_mask,
index aad944f8ab026c1282702c703091135e99d13f31..5d24292c45a56ee9c8e8fc6de28da6d64231261a 100644 (file)
@@ -1195,7 +1195,6 @@ static int iwl_mld_wait_d3_notif(struct iwl_mld *mld,
                WIDE_ID(PROT_OFFLOAD_GROUP, D3_END_NOTIFICATION)
        };
        struct iwl_notification_wait wait_d3_notif;
-       enum iwl_d3_status d3_status;
        int ret;
 
        if (with_wowlan)
@@ -1211,14 +1210,8 @@ static int iwl_mld_wait_d3_notif(struct iwl_mld *mld,
                                           iwl_mld_handle_d3_notif,
                                           resume_data);
 
-       ret = iwl_trans_d3_resume(mld->trans, &d3_status, false);
-       if (ret || d3_status != IWL_D3_STATUS_ALIVE) {
-               if (d3_status != IWL_D3_STATUS_ALIVE) {
-                       IWL_INFO(mld, "Device was reset during suspend\n");
-                       ret = -ENOENT;
-               } else {
-                       IWL_ERR(mld, "Transport resume failed\n");
-               }
+       ret = iwl_trans_d3_resume(mld->trans, false);
+       if (ret) {
                iwl_remove_notification(&mld->notif_wait, &wait_d3_notif);
                return ret;
        }
index d22ee06ff2c98bbe97f0b0643d516cd33e92e93a..38832f5e4068980308ffe57f71bb545b0d6d9c24 100644 (file)
@@ -2984,7 +2984,6 @@ static bool iwl_mvm_wait_d3_notif(struct iwl_notif_wait_data *notif_wait,
 static int iwl_mvm_resume_firmware(struct iwl_mvm *mvm)
 {
        int ret;
-       enum iwl_d3_status d3_status;
        struct iwl_host_cmd cmd = {
                .id = D0I3_END_CMD,
                .flags = CMD_WANT_SKB,
@@ -2992,15 +2991,10 @@ static int iwl_mvm_resume_firmware(struct iwl_mvm *mvm)
        bool reset = fw_has_capa(&mvm->fw->ucode_capa,
                                 IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
 
-       ret = iwl_trans_d3_resume(mvm->trans, &d3_status, !reset);
+       ret = iwl_trans_d3_resume(mvm->trans, !reset);
        if (ret)
                return ret;
 
-       if (d3_status != IWL_D3_STATUS_ALIVE) {
-               IWL_INFO(mvm, "Device was reset during suspend\n");
-               return -ENOENT;
-       }
-
        /*
         * We should trigger resume flow using command only for 22000 family
         * AX210 and above don't need the command since they have
index b6ff9d62fab7c6d9a4087e64813b2c0b6694f730..54b9788300436f6dc9b1ef019cf36fbffe5ea8ee 100644 (file)
@@ -1064,7 +1064,6 @@ iwl_trans_pcie_dump_data(struct iwl_trans *trans, u32 dump_mask,
                         const struct iwl_dump_sanitize_ops *sanitize_ops,
                         void *sanitize_ctx);
 int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
-                            enum iwl_d3_status *status,
                             bool reset);
 int iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool reset);
 void iwl_trans_pci_interrupts(struct iwl_trans *trans, bool enable);
index ff0979d0b8b061bac26d862271ff8ebc8b1590b5..0946ea223e460c31fb431593868315b2e6da4966 100644 (file)
@@ -1530,7 +1530,6 @@ int iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool reset)
 }
 
 int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
-                            enum iwl_d3_status *status,
                             bool reset)
 {
        struct iwl_trans_pcie *trans_pcie =  IWL_TRANS_GET_PCIE_TRANS(trans);
@@ -1545,8 +1544,11 @@ int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
                            CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
 
        ret = iwl_finish_nic_init(trans);
-       if (ret)
+       if (ret) {
+               IWL_ERR(trans, "Failed to init nic upon resume. err = %d\n",
+                       ret);
                return ret;
+       }
 
        /*
         * Reconfigure IVAR table in case of MSIX or reset ict table in
@@ -1581,14 +1583,12 @@ int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
 
        val = iwl_read32(trans, CSR_RESET);
        if (val & CSR_RESET_REG_FLAG_NEVO_RESET) {
-               *status = IWL_D3_STATUS_RESET;
+               IWL_INFO(trans, "Device was reset during suspend\n");
                trans->state = IWL_TRANS_NO_FW;
-       } else {
-               *status = IWL_D3_STATUS_ALIVE;
-               return iwl_pcie_d3_handshake(trans, false);
+               return -ENOENT;
        }
 
-       return 0;
+       return iwl_pcie_d3_handshake(trans, false);
 }
 
 static void