]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
iwlwifi: yoyo: support dump policy for the dump size
authorMukesh Sisodiya <mukesh.sisodiya@intel.com>
Thu, 10 Feb 2022 16:22:29 +0000 (18:22 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 18 Feb 2022 08:40:55 +0000 (10:40 +0200)
Support dump size limitation based on the TLV by firmware.
This is needed for limited memory systems so only the most
important dumps are sent by driver.

Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220210181930.d7e1ff264766.If2327fd890a453cdc9069d26220394d0b4e79743@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c

index 061fe6cc6cf5ba9c16b516ad3362e387b6e183c9..55edd5ada899e492aac4252e8a5953528607c730 100644 (file)
@@ -11,7 +11,8 @@
 #define IWL_FW_INI_MAX_NAME                    32
 #define IWL_FW_INI_MAX_CFG_NAME                        64
 #define IWL_FW_INI_DOMAIN_ALWAYS_ON            0
-#define IWL_FW_INI_REGION_V2_MASK              0x0000FFFF
+#define IWL_FW_INI_REGION_ID_MASK              GENMASK(15, 0)
+#define IWL_FW_INI_REGION_DUMP_POLICY_MASK     GENMASK(31, 16)
 
 /**
  * struct iwl_fw_ini_hcmd
@@ -495,4 +496,31 @@ enum iwl_fw_ini_trigger_reset_fw_policy {
        IWL_FW_INI_RESET_FW_MODE_STOP_FW_ONLY,
        IWL_FW_INI_RESET_FW_MODE_STOP_AND_RELOAD_FW
 };
+
+/**
+ * enum iwl_fw_ini_dump_policy - Determines how to handle dump based on enabled flags
+ *
+ * @IWL_FW_INI_DEBUG_DUMP_POLICY_NO_LIMIT: OS has no limit of dump size
+ * @IWL_FW_INI_DEBUG_DUMP_POLICY_MAX_LIMIT_600KB: mini dump only 600KB region dump
+ * @IWL_FW_IWL_DEBUG_DUMP_POLICY_MAX_LIMIT_5MB: mini dump 5MB size dump
+ */
+enum iwl_fw_ini_dump_policy {
+       IWL_FW_INI_DEBUG_DUMP_POLICY_NO_LIMIT           = BIT(0),
+       IWL_FW_INI_DEBUG_DUMP_POLICY_MAX_LIMIT_600KB    = BIT(1),
+       IWL_FW_IWL_DEBUG_DUMP_POLICY_MAX_LIMIT_5MB      = BIT(2),
+
+};
+
+/**
+ * enum iwl_fw_ini_dump_type - Determines dump type based on size defined by FW.
+ *
+ * @IWL_FW_INI_DUMP_BRIEF : only dump the most important regions
+ * @IWL_FW_INI_DEBUG_MEDIUM: dump more regions than "brief", but not all regions
+ * @IWL_FW_INI_DUMP_VERBOSE : dump all regions
+ */
+enum iwl_fw_ini_dump_type {
+       IWL_FW_INI_DUMP_BRIEF,
+       IWL_FW_INI_DUMP_MEDIUM,
+       IWL_FW_INI_DUMP_VERBOSE,
+};
 #endif
index 238ba4384cd19b00daad1391cfd5753e5f65a503..656a5e7fb4a05209dfa89b636acbbdadc1c719f4 100644 (file)
@@ -2096,21 +2096,40 @@ static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list,
        struct iwl_fw_ini_error_dump_data *tlv;
        struct iwl_fw_ini_error_dump_header *header;
        u32 type = reg->type;
-       u32 id = le32_to_cpu(reg->id);
+       u32 id = le32_get_bits(reg->id, IWL_FW_INI_REGION_ID_MASK);
        u32 num_of_ranges, i, size;
        u8 *range;
        u32 free_size;
        u64 header_size;
+       u32 dump_policy = IWL_FW_INI_DUMP_VERBOSE;
 
-       /*
-        * The higher part of the ID from 2 is irrelevant for
-        * us, so mask it out.
-        */
-       if (le32_to_cpu(reg->hdr.version) >= 2)
-               id &= IWL_FW_INI_REGION_V2_MASK;
+       IWL_DEBUG_FW(fwrt, "WRT: Collecting region: dump type=%d, id=%d, type=%d\n",
+                    dump_policy, id, type);
 
-       IWL_DEBUG_FW(fwrt, "WRT: Collecting region: id=%d, type=%d\n", id,
-                    type);
+       if (le32_to_cpu(reg->hdr.version) >= 2) {
+               u32 dp = le32_get_bits(reg->id,
+                                      IWL_FW_INI_REGION_DUMP_POLICY_MASK);
+
+               if (dump_policy == IWL_FW_INI_DUMP_VERBOSE &&
+                   !(dp & IWL_FW_INI_DEBUG_DUMP_POLICY_NO_LIMIT)) {
+                       IWL_DEBUG_FW(fwrt,
+                                    "WRT: no dump - type %d and policy mismatch=%d\n",
+                                    dump_policy, dp);
+                       return 0;
+               } else if (dump_policy == IWL_FW_INI_DUMP_MEDIUM &&
+                          !(dp & IWL_FW_IWL_DEBUG_DUMP_POLICY_MAX_LIMIT_5MB)) {
+                       IWL_DEBUG_FW(fwrt,
+                                    "WRT: no dump - type %d and policy mismatch=%d\n",
+                                    dump_policy, dp);
+                       return 0;
+               } else if (dump_policy == IWL_FW_INI_DUMP_BRIEF &&
+                          !(dp & IWL_FW_INI_DEBUG_DUMP_POLICY_MAX_LIMIT_600KB)) {
+                       IWL_DEBUG_FW(fwrt,
+                                    "WRT: no dump - type %d and policy mismatch=%d\n",
+                                    dump_policy, dp);
+                       return 0;
+               }
+       }
 
        if (!ops->get_num_of_ranges || !ops->get_size || !ops->fill_mem_hdr ||
            !ops->fill_range) {
index 0cda8ac5024f192932b8fa98276fc108c75fd3ba..bf167bdd02cd60e3165bf3484251bdccc5e58f0d 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2018-2021 Intel Corporation
+ * Copyright (C) 2018-2022 Intel Corporation
  */
 #include <linux/firmware.h>
 #include "iwl-drv.h"
@@ -181,11 +181,11 @@ static int iwl_dbg_tlv_alloc_region(struct iwl_trans *trans,
        u32 tlv_len = sizeof(*tlv) + le32_to_cpu(tlv->length);
 
        /*
-        * The higher part of the ID in from version 2 is irrelevant for
-        * us, so mask it out.
+        * The higher part of the ID from version 2 is debug policy.
+        * The id will be only lsb 16 bits, so mask it out.
         */
        if (le32_to_cpu(reg->hdr.version) >= 2)
-               id &= IWL_FW_INI_REGION_V2_MASK;
+               id &= IWL_FW_INI_REGION_ID_MASK;
 
        if (le32_to_cpu(tlv->length) < sizeof(*reg))
                return -EINVAL;