iwlwifi: parse error tables from debug TLVs
authorJohannes Berg <johannes.berg@intel.com>
Fri, 10 Dec 2021 09:12:36 +0000 (11:12 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Tue, 21 Dec 2021 10:35:05 +0000 (12:35 +0200)
With more things being added, we're no longer going to duplicate
the error tables from the debug TLVs nor send them at runtime.
Use the debug TLVs to find the locations of the error tables. As
we've never released firmware using IWL_UCODE_TLV_TCM_DEBUG_ADDRS
just remove that entirely.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211210110539.779d68490f68.I472c7d9cbaca46000a10ec18808ef54836b33a8a@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/file.h
drivers/net/wireless/intel/iwlwifi/iwl-drv.c

index 2245254174247eb1c07502abd99f7c62acf86cdc..62b527b3a6c5226dc28ab00ac1e6a44d95ecd8c9 100644 (file)
@@ -386,7 +386,16 @@ enum iwl_fw_ini_region_type {
        IWL_FW_INI_REGION_NUM
 }; /* FW_TLV_DEBUG_REGION_TYPE_API_E */
 
-#define IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_HW_SMEM        1
+enum iwl_fw_ini_region_device_memory_subtype {
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_HW_SMEM = 1,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_UMAC_ERROR_TABLE = 5,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_LMAC_1_ERROR_TABLE = 7,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_LMAC_2_ERROR_TABLE = 10,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_TCM_1_ERROR_TABLE = 14,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_TCM_2_ERROR_TABLE = 16,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_RCM_1_ERROR_TABLE = 18,
+       IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_RCM_2_ERROR_TABLE = 20,
+}; /* FW_TLV_DEBUG_REGION_DEVICE_MEMORY_SUBTYPE_API_E */
 
 /**
  * enum iwl_fw_ini_time_point
index 3d572f5024bbcbf5e1c3281b59d11d4159792211..e4ebda64cd52d070815ee881489e41764c0d678e 100644 (file)
@@ -98,7 +98,6 @@ enum iwl_ucode_tlv_type {
 
        IWL_UCODE_TLV_PNVM_VERSION              = 62,
        IWL_UCODE_TLV_PNVM_SKU                  = 64,
-       IWL_UCODE_TLV_TCM_DEBUG_ADDRS           = 65,
 
        IWL_UCODE_TLV_SEC_TABLE_ADDR            = 66,
        IWL_UCODE_TLV_D3_KEK_KCK_ADDR           = 67,
index 40e8d7ed56155abfd992ddc4745e27d05da5f35f..e8550fe3b39cef1ab9af119d05e81e39452a34f9 100644 (file)
@@ -586,6 +586,51 @@ static void iwl_drv_set_dump_exclude(struct iwl_drv *drv,
        excl->size = le32_to_cpu(fw->size);
 }
 
+static void iwl_parse_dbg_tlv_assert_tables(struct iwl_drv *drv,
+                                           const struct iwl_ucode_tlv *tlv)
+{
+       const struct iwl_fw_ini_region_tlv *region;
+       u32 length = le32_to_cpu(tlv->length);
+       u32 addr;
+
+       if (length < offsetof(typeof(*region), special_mem) +
+                    sizeof(region->special_mem))
+               return;
+
+       region = (void *)tlv->data;
+       addr = le32_to_cpu(region->special_mem.base_addr);
+       addr += le32_to_cpu(region->special_mem.offset);
+       addr &= ~FW_ADDR_CACHE_CONTROL;
+
+       if (region->type != IWL_FW_INI_REGION_SPECIAL_DEVICE_MEMORY)
+               return;
+
+       switch (region->sub_type) {
+       case IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_UMAC_ERROR_TABLE:
+               drv->trans->dbg.umac_error_event_table = addr;
+               drv->trans->dbg.error_event_table_tlv_status |=
+                       IWL_ERROR_EVENT_TABLE_UMAC;
+               break;
+       case IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_LMAC_1_ERROR_TABLE:
+               drv->trans->dbg.lmac_error_event_table[0] = addr;
+               drv->trans->dbg.error_event_table_tlv_status |=
+                       IWL_ERROR_EVENT_TABLE_LMAC1;
+               break;
+       case IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_LMAC_2_ERROR_TABLE:
+               drv->trans->dbg.lmac_error_event_table[1] = addr;
+               drv->trans->dbg.error_event_table_tlv_status |=
+                       IWL_ERROR_EVENT_TABLE_LMAC2;
+               break;
+       case IWL_FW_INI_REGION_DEVICE_MEMORY_SUBTYPE_TCM_1_ERROR_TABLE:
+               drv->trans->dbg.tcm_error_event_table = addr;
+               drv->trans->dbg.error_event_table_tlv_status |=
+                       IWL_ERROR_EVENT_TABLE_TCM;
+               break;
+       default:
+               break;
+       }
+}
+
 static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
                                const struct firmware *ucode_raw,
                                struct iwl_firmware_pieces *pieces,
@@ -1153,21 +1198,12 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
                                IWL_ERROR_EVENT_TABLE_LMAC1;
                        break;
                        }
-               case IWL_UCODE_TLV_TCM_DEBUG_ADDRS: {
-                       struct iwl_fw_tcm_error_addr *ptr = (void *)tlv_data;
-
-                       if (tlv_len != sizeof(*ptr))
-                               goto invalid_tlv_len;
-                       drv->trans->dbg.tcm_error_event_table =
-                               le32_to_cpu(ptr->addr) & ~FW_ADDR_CACHE_CONTROL;
-                       drv->trans->dbg.error_event_table_tlv_status |=
-                               IWL_ERROR_EVENT_TABLE_TCM;
-                       break;
-                       }
+               case IWL_UCODE_TLV_TYPE_REGIONS:
+                       iwl_parse_dbg_tlv_assert_tables(drv, tlv);
+                       fallthrough;
                case IWL_UCODE_TLV_TYPE_DEBUG_INFO:
                case IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION:
                case IWL_UCODE_TLV_TYPE_HCMD:
-               case IWL_UCODE_TLV_TYPE_REGIONS:
                case IWL_UCODE_TLV_TYPE_TRIGGERS:
                case IWL_UCODE_TLV_TYPE_CONF_SET:
                        if (iwlwifi_mod_params.enable_ini)