wifi: iwlwifi: unify cmd_queue_full() into nic_error()
authorJohannes Berg <johannes.berg@intel.com>
Fri, 27 Dec 2024 08:01:09 +0000 (10:01 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 13 Jan 2025 14:26:39 +0000 (15:26 +0100)
Except for some special handling in DVM, error dump and some
message behaviour, cmd_queue_full and nic_error are equivalent
now. Unify by giving a special error type, so DVM can continue
to differentiate.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241227095718.0222183504aa.Ie29cef75fbd91b64a43619bc36bd5b29c5b9f957@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/dvm/main.c
drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
drivers/net/wireless/intel/iwlwifi/pcie/tx.c

index 4f58469..797b7c3 100644 (file)
@@ -1957,25 +1957,22 @@ static void iwl_nic_error(struct iwl_op_mode *op_mode,
 {
        struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
 
+       if (type == IWL_ERR_TYPE_CMD_QUEUE_FULL && iwl_check_for_ct_kill(priv))
+               return;
+
        IWL_ERR(priv, "Loaded firmware version: %s\n",
                priv->fw->fw_version);
 
-       iwl_dump_nic_error_log(priv);
-       iwl_dump_nic_event_log(priv, false, NULL);
+       if (type == IWL_ERR_TYPE_CMD_QUEUE_FULL) {
+               IWL_ERR(priv, "Command queue full!\n");
+       } else {
+               iwl_dump_nic_error_log(priv);
+               iwl_dump_nic_event_log(priv, false, NULL);
+       }
 
        iwlagn_fw_error(priv, false);
 }
 
-static void iwl_cmd_queue_full(struct iwl_op_mode *op_mode)
-{
-       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
-
-       if (!iwl_check_for_ct_kill(priv)) {
-               IWL_ERR(priv, "Restarting adapter queue is full\n");
-               iwlagn_fw_error(priv, false);
-       }
-}
-
 #define EEPROM_RF_CONFIG_TYPE_MAX      0x3
 
 static void iwl_nic_config(struct iwl_op_mode *op_mode)
@@ -2128,7 +2125,6 @@ static const struct iwl_op_mode_ops iwl_dvm_ops = {
        .hw_rf_kill = iwl_set_hw_rfkill_state,
        .free_skb = iwl_free_skb,
        .nic_error = iwl_nic_error,
-       .cmd_queue_full = iwl_cmd_queue_full,
        .nic_config = iwl_nic_config,
        .wimax_active = iwl_wimax_active,
 };
index 8febc94..3b4085d 100644 (file)
@@ -51,11 +51,13 @@ struct iwl_cfg;
  * @IWL_ERR_TYPE_RESET_HS_TIMEOUT: reset handshake timed out,
  *     any debug collection must happen synchronously as
  *     the device will be shut down
+ * @IWL_ERR_TYPE_CMD_QUEUE_FULL: command queue was full
  */
 enum iwl_fw_error_type {
        IWL_ERR_TYPE_IRQ,
        IWL_ERR_TYPE_NMI_FORCED,
        IWL_ERR_TYPE_RESET_HS_TIMEOUT,
+       IWL_ERR_TYPE_CMD_QUEUE_FULL,
 };
 
 /**
@@ -93,8 +95,6 @@ enum iwl_fw_error_type {
  *     Must be atomic
  * @nic_error: error notification. Must be atomic and must be called with BH
  *     disabled, unless the type is IWL_ERR_TYPE_RESET_HS_TIMEOUT
- * @cmd_queue_full: Called when the command queue gets full. Must be atomic and
- *     called with BH disabled.
  * @nic_config: configure NIC, called before firmware is started.
  *     May sleep
  * @wimax_active: invoked when WiMax becomes active. May sleep
@@ -120,7 +120,6 @@ struct iwl_op_mode_ops {
        void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb);
        void (*nic_error)(struct iwl_op_mode *op_mode,
                          enum iwl_fw_error_type type);
-       void (*cmd_queue_full)(struct iwl_op_mode *op_mode);
        void (*nic_config)(struct iwl_op_mode *op_mode);
        void (*wimax_active)(struct iwl_op_mode *op_mode);
        void (*time_point)(struct iwl_op_mode *op_mode,
@@ -198,11 +197,6 @@ static inline void iwl_op_mode_nic_error(struct iwl_op_mode *op_mode,
        op_mode->ops->nic_error(op_mode, type);
 }
 
-static inline void iwl_op_mode_cmd_queue_full(struct iwl_op_mode *op_mode)
-{
-       op_mode->ops->cmd_queue_full(op_mode);
-}
-
 static inline void iwl_op_mode_nic_config(struct iwl_op_mode *op_mode)
 {
        might_sleep();
index aad0449..13a2403 100644 (file)
@@ -2118,9 +2118,11 @@ static void iwl_mvm_nic_error(struct iwl_op_mode *op_mode,
 {
        struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
 
-       if (!test_bit(STATUS_TRANS_DEAD, &mvm->trans->status) &&
-           !test_and_clear_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE,
-                               &mvm->status))
+       if (type == IWL_ERR_TYPE_CMD_QUEUE_FULL)
+               IWL_ERR(mvm, "Command queue full!\n");
+       else if (!test_bit(STATUS_TRANS_DEAD, &mvm->trans->status) &&
+                !test_and_clear_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE,
+                                    &mvm->status))
                iwl_mvm_dump_nic_error_log(mvm);
 
        /* reset HS timeout is during shutdown, so collect right now */
@@ -2140,14 +2142,6 @@ static void iwl_mvm_nic_error(struct iwl_op_mode *op_mode,
        iwl_mvm_nic_restart(mvm);
 }
 
-static void iwl_mvm_cmd_queue_full(struct iwl_op_mode *op_mode)
-{
-       struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
-
-       WARN_ON(1);
-       iwl_mvm_nic_restart(mvm);
-}
-
 static void iwl_op_mode_mvm_time_point(struct iwl_op_mode *op_mode,
                                       enum iwl_fw_ini_time_point tp_id,
                                       union iwl_dbg_tlv_tp_data *tp_data)
@@ -2181,7 +2175,6 @@ static void iwl_op_mode_mvm_device_powered_off(struct iwl_op_mode *op_mode)
        .hw_rf_kill = iwl_mvm_set_hw_rfkill_state,              \
        .free_skb = iwl_mvm_free_skb,                           \
        .nic_error = iwl_mvm_nic_error,                         \
-       .cmd_queue_full = iwl_mvm_cmd_queue_full,               \
        .nic_config = iwl_mvm_nic_config,                       \
        /* as we only register one, these MUST be common! */    \
        .start = iwl_op_mode_mvm_start,                         \
index b1846ab..4c92588 100644 (file)
@@ -1298,7 +1298,8 @@ int iwl_pcie_gen2_enqueue_hcmd(struct iwl_trans *trans,
                spin_unlock_irqrestore(&txq->lock, flags);
 
                IWL_ERR(trans, "No space in command queue\n");
-               iwl_op_mode_cmd_queue_full(trans->op_mode);
+               iwl_op_mode_nic_error(trans->op_mode,
+                                     IWL_ERR_TYPE_CMD_QUEUE_FULL);
                idx = -ENOSPC;
                goto free_dup_buf;
        }
index 1ef1434..aaa1b87 100644 (file)
@@ -1449,7 +1449,8 @@ int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
                spin_unlock_irqrestore(&txq->lock, flags);
 
                IWL_ERR(trans, "No space in command queue\n");
-               iwl_op_mode_cmd_queue_full(trans->op_mode);
+               iwl_op_mode_nic_error(trans->op_mode,
+                                     IWL_ERR_TYPE_CMD_QUEUE_FULL);
                idx = -ENOSPC;
                goto free_dup_buf;
        }