@@ -427,6 +427,10 @@ struct ath10k_fw_crash_data {
uuid_le uuid;
struct timespec timestamp;
__le32 registers[REG_DUMP_COUNT_QCA988X];
+ __le32 stack_buf[ATH10K_FW_STACK_SIZE / sizeof(__le32)];
+ __le32 exc_stack_buf[ATH10K_FW_STACK_SIZE / sizeof(__le32)];
+ __le32 stack_addr;
+ __le32 exc_stack_addr;
};
struct ath10k_debug {
@@ -36,10 +36,15 @@
* enum ath10k_fw_crash_dump_type - types of data in the dump file
* @ATH10K_FW_CRASH_DUMP_REGDUMP: Register crash dump in binary format
* @ATH10K_FW_ERROR_DUMP_DBGLOG: Recent firmware debug log entries
+ * @ATH10K_FW_CRASH_DUMP_STACK: Stack memory contents.
+ * @ATH10K_FW_CRASH_DUMP_EXC_STACK: Exception stack memory contents.
*/
enum ath10k_fw_crash_dump_type {
ATH10K_FW_CRASH_DUMP_REGISTERS = 0,
ATH10K_FW_CRASH_DUMP_DBGLOG = 1,
+ ATH10K_FW_CRASH_DUMP_STACK = 2,
+ ATH10K_FW_CRASH_DUMP_EXC_STACK = 3,
+
ATH10K_FW_CRASH_DUMP_MAX,
};
@@ -103,8 +108,11 @@ struct ath10k_dump_file_data {
/* VERMAGIC_STRING */
char kernel_ver[64];
+ __le32 stack_addr;
+ __le32 exc_stack_addr;
+
/* room for growth w/out changing binary format */
- u8 unused[128];
+ u8 unused[120];
/* struct ath10k_tlv_dump_data + more */
u8 data[0];
@@ -797,6 +805,8 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar)
len = hdr_len;
len += sizeof(*dump_tlv) + sizeof(crash_data->registers);
len += sizeof(*dump_tlv) + sizeof(ar->debug.dbglog_entry_data);
+ len += sizeof(*dump_tlv) + sizeof(crash_data->stack_buf);
+ len += sizeof(*dump_tlv) + sizeof(crash_data->exc_stack_buf);
sofar += hdr_len;
@@ -836,6 +846,8 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar)
dump_data->ht_cap_info = cpu_to_le32(ar->ht_cap_info);
dump_data->vht_cap_info = cpu_to_le32(ar->vht_cap_info);
dump_data->num_rf_chains = cpu_to_le32(ar->num_rf_chains);
+ dump_data->stack_addr = cpu_to_le32(crash_data->stack_addr);
+ dump_data->exc_stack_addr = cpu_to_le32(crash_data->exc_stack_addr);
strlcpy(dump_data->fw_ver, ar->hw->wiphy->fw_version,
sizeof(dump_data->fw_ver));
@@ -868,7 +880,22 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar)
cpu_to_le32(ar->debug.dbglog_entry_data.head_idx);
dbglog_storage->tail_idx =
cpu_to_le32(ar->debug.dbglog_entry_data.tail_idx);
+ sofar += sizeof(*dump_tlv) + tmp;
+ /* Gather firmware stack dump */
+ tmp = sizeof(crash_data->stack_buf);
+ dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
+ dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_STACK);
+ dump_tlv->tlv_len = cpu_to_le32(tmp);
+ memcpy(dump_tlv->tlv_data, crash_data->stack_buf, tmp);
+ sofar += sizeof(*dump_tlv) + tmp;
+
+ /* Gather firmware exception stack dump */
+ tmp = sizeof(crash_data->exc_stack_buf);
+ dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
+ dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_EXC_STACK);
+ dump_tlv->tlv_len = cpu_to_le32(tmp);
+ memcpy(dump_tlv->tlv_data, crash_data->exc_stack_buf, tmp);
sofar += sizeof(*dump_tlv) + tmp;
ar->debug.fw_crash_data->crashed_since_read = false;
@@ -122,6 +122,8 @@ enum qca9377_chip_id_rev {
#define REG_DUMP_COUNT_QCA988X 60
+#define ATH10K_FW_STACK_SIZE 4096
+
struct ath10k_fw_ie {
__le32 id;
__le32 len;
@@ -985,6 +985,22 @@ static int ath10k_pci_diag_read32(struct ath10k *ar, u32 address, u32 *value)
return ret;
}
+static int __ath10k_pci_diag_read_hi_addr(struct ath10k *ar, __le32 *dest,
+ u32 src)
+{
+ u32 host_addr;
+ int ret;
+
+ host_addr = host_interest_item_address(src);
+
+ ret = ath10k_pci_diag_read32(ar, host_addr, dest);
+ if (ret != 0) {
+ ath10k_warn(ar, "failed to get memcpy hi address for firmware address %d: %d\n",
+ src, ret);
+ }
+ return ret;
+}
+
static int __ath10k_pci_diag_read_hi(struct ath10k *ar, void *dest,
u32 src, u32 len)
{
@@ -1013,6 +1029,9 @@ static int __ath10k_pci_diag_read_hi(struct ath10k *ar, void *dest,
#define ath10k_pci_diag_read_hi(ar, dest, src, len) \
__ath10k_pci_diag_read_hi(ar, dest, HI_ITEM(src), len)
+#define ath10k_pci_diag_read_hi_addr(ar, dest, src) \
+ __ath10k_pci_diag_read_hi_addr(ar, dest, HI_ITEM(src))
+
int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
const void *data, int nbytes)
{
@@ -1405,6 +1424,37 @@ u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe)
return ath10k_ce_num_free_src_entries(ar_pci->pipe_info[pipe].ce_hdl);
}
+/* Save the main firmware stack */
+static void ath10k_pci_dump_stack(struct ath10k *ar,
+ struct ath10k_fw_crash_data *crash_data)
+{
+ if (!crash_data)
+ return;
+
+ lockdep_assert_held(&ar->data_lock);
+ BUILD_BUG_ON(ATH10K_FW_STACK_SIZE % 4);
+
+ ath10k_pci_diag_read_hi(ar, crash_data->stack_buf,
+ hi_stack, ATH10K_FW_STACK_SIZE);
+ ath10k_pci_diag_read_hi_addr(ar, &crash_data->stack_addr, hi_stack);
+}
+
+/* Save the exception firmware stack */
+static void ath10k_pci_dump_exc_stack(struct ath10k *ar,
+ struct ath10k_fw_crash_data *crash_data)
+{
+ if (!crash_data)
+ return;
+
+ lockdep_assert_held(&ar->data_lock);
+
+ ath10k_pci_diag_read_hi(ar, crash_data->exc_stack_buf,
+ hi_err_stack, ATH10K_FW_STACK_SIZE);
+
+ ath10k_pci_diag_read_hi_addr(ar, &crash_data->exc_stack_addr,
+ hi_err_stack);
+}
+
static void ath10k_pci_dump_registers(struct ath10k *ar,
struct ath10k_fw_crash_data *crash_data)
{
@@ -1555,6 +1605,8 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k *ar)
ath10k_print_driver_info(ar);
ath10k_pci_dump_registers(ar, crash_data);
ath10k_pci_dump_dbglog(ar);
+ ath10k_pci_dump_stack(ar, crash_data);
+ ath10k_pci_dump_exc_stack(ar, crash_data);
if (crash_data)
crash_data->crashed_since_read = true;