ath10k: provide firmware crash info via debugfs.
PATCH v2 1/4 ath10k: provide firmware crash info via debugfs.
From: Ben Greear <[email protected]>
Store the firmware crash registers and last 128 or so firmware debug-log ids and present them to user-space via debugfs.
Should help with figuring out why the firmware crashed.
--- drivers/net/wireless/ath/ath10k/core.c | 1 + drivers/net/wireless/ath/ath10k/core.h | 71 ++++++++++++++ drivers/net/wireless/ath/ath10k/debug.c | 166 ++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/debug.h | 3 + drivers/net/wireless/ath/ath10k/hw.h | 24 +++++ drivers/net/wireless/ath/ath10k/pci.c | 103 +++++++++++++++++++- drivers/net/wireless/ath/ath10k/pci.h | 3 - 7 files changed, 366 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +1 -0
@@ -1068,6 +1068,7 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,mutex_init (&ar->conf_mutex);spin_lock_init (&ar->data_lock); +spin_lock_init (&ar->crash_data_lock);INIT_LIST_HEAD (&ar->peers);init_waitqueue_head (&ar->peer_mapping_wq);
drivers/net/wireless/ath/ath10k/core.h +71 -0
83 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/debug.c +166 -0
184 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/debug.h +3 -0
@@ -110,4 +110,7 @@ static inline void ath10k_dbg_dump(enum ath10k_debug_mask mask, { }#endif /* CONFIG_ATH10K_DEBUG */ + +void ath10k_dbg_save_fw_dbg_buffer (struct ath10k *ar,u8 *buffer,int len); +#endif /* _DEBUG_H_ */
drivers/net/wireless/ath/ath10k/hw.h +24 -0
@@ -38,6 +38,8 @@/* includes also the null byte */ #define ATH10K_FIRMWARE_MAGIC "QCA-ATH10K" +#define REG_DUMP_COUNT_QCA988X 60 +struct ath10k_fw_ie {__le32 id;__le32 len;
@@ -361,4 +363,26 @@ enum ath10k_mcast2ucast_mode {#define RTC_STATE_V_GET (x) (((x) & RTC_STATE_V_MASK) >> RTC_STATE_V_LSB) + +/* Target debug log related defines and structs */ + +/* Target is 32-bit CPU, so we just use u32 for +* the pointers. The memory space is relative to the +* target, not the host. +*/ +struct ath10k_fw_dbglog_buf { +u32 next;/* pointer to dblog_buf_s. */ +u32 buffer;/* pointer to u8 buffer */ +u32 bufsize; +u32 length; +u32 count; +u32 free; +} __packed; + +struct ath10k_fw_dbglog_hdr { +u32 dbuf;/* pointer to dbglog_buf_s */ +u32 dropped; +} __packed; + +#endif /* _HW_H_ */
drivers/net/wireless/ath/ath10k/pci.c +101 -2
133 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/pci.h +0 -3
@@ -23,9 +23,6 @@#include "hw.h" #include "ce.h" -/* FW dump area */ -#define REG_DUMP_COUNT_QCA988X 60 -/* * maximum number of bytes that can be handled atomically by DiagRead/DiagWrite */
Signature · 1 line
1.7.11.7
PATCH v2 2/4 ath10k: save firmware debug log messages.
From: Ben Greear <[email protected]>
They may be dumped through the firmware dump debugfs file.
--- drivers/net/wireless/ath/ath10k/wmi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath10k/wmi.c +6 -0
@@ -1089,6 +1089,12 @@ static int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)trace_ath10k_wmi_dbglog (skb->data, skb->len); +/* First 4 bytes are a messages-dropped-due-to-overflow counter, +* and should not be recorded in the dbglog buffer, so we skip +* them. +*/ +ath10k_dbg_save_fw_dbg_buffer (ar, skb->data +4 , skb->len -4 ); +return 0 ; }
Signature · 1 line
1.7.11.7
PATCH v2 3/4 ath10k: save firmware stack upon firmware crash.
In reply to [email protected]From: Ben Greear <[email protected]>
Should help debug firmware crashes, and give users a way to provide some useful debug reports to firmware developers.
--- drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/debug.c | 9 ++++++++ drivers/net/wireless/ath/ath10k/hw.h | 1 + drivers/net/wireless/ath/ath10k/pci.c | 39 +++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+)
drivers/net/wireless/ath/ath10k/core.h +2 -0
@@ -346,6 +346,7 @@ enum ath10k_dev_flags {enum ath10k_fw_error_dump_type {ATH10K_FW_ERROR_DUMP_DBGLOG =0 ,ATH10K_FW_ERROR_DUMP_REGDUMP =1 , +ATH10K_FW_ERROR_DUMP_STACK =2 ,ATH10K_FW_ERROR_DUMP_MAX , };
@@ -558,6 +559,7 @@ struct ath10k {bool crashed_since_read;struct ath10k_dbglog_entry_storage dbglog_entry_data;u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ]; +unsigned char stack_buf[ATH10K_FW_STACK_SIZE ];#ifdef CONFIG_ATH10K_DEBUGFS struct ath10k_debug debug;
drivers/net/wireless/ath/ath10k/debug.c +9 -0
@@ -619,6 +619,7 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) len = hdr_len; len +=sizeof (*dump_tlv) +sizeof (ar->reg_dump_values); len +=sizeof (*dump_tlv) +sizeof (ar->dbglog_entry_data); + len +=sizeof (*dump_tlv) +sizeof (ar->stack_buf);lockdep_assert_held (&ar->conf_mutex);
@@ -685,8 +686,16 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar)memcpy (dump_tlv->tlv_data, &ar->reg_dump_values, dump_tlv->tlv_len); sofar +=sizeof (*dump_tlv) + dump_tlv->tlv_len; +/* Gather firmware stack dump */ + dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar); + dump_tlv->type =ATH10K_FW_ERROR_DUMP_STACK ; + dump_tlv->tlv_len =sizeof (ar->stack_buf); +memcpy (dump_tlv->tlv_data, &ar->stack_buf, dump_tlv->tlv_len); + sofar +=sizeof (*dump_tlv) + dump_tlv->tlv_len; +spin_unlock_irqrestore (&ar->crash_data_lock, flags); +WARN_ON (sofar != len);return dump_data; }
drivers/net/wireless/ath/ath10k/hw.h +1 -0
@@ -39,6 +39,7 @@#define ATH10K_FIRMWARE_MAGIC "QCA-ATH10K"#define REG_DUMP_COUNT_QCA988X 60 +#define ATH10K_FW_STACK_SIZE 4096struct ath10k_fw_ie {__le32 id;
drivers/net/wireless/ath/ath10k/pci.c +39 -0
@@ -834,6 +834,38 @@ static 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); } +static void ath10k_save_firmware_mem_helper (struct ath10k *ar,u32 sz, +unsigned char *to,u32 addr) +{ +u32 host_addr; +u32 reg_dump_area; +int ret; + + host_addr =host_interest_item_address (addr); + + ret =ath10k_pci_diag_read_mem (ar, host_addr, ®_dump_area, +sizeof (u32)); +if (ret !=0 ) { +ath10k_warn ("failed to read FW addr: %d (addr %d)\n" , + ret, addr); +return ; + } + + ret =ath10k_pci_diag_read_mem (ar, reg_dump_area, to, sz); +if (ret !=0 ) +ath10k_err ("failed to read FW memory: %d (addr %d sz %d)\n" , + ret, reg_dump_area, sz); +} + +/* Save the main firmware stack */ +static void ath10k_save_firmware_stack (struct ath10k *ar) +{ +BUILD_BUG_ON (ATH10K_FW_STACK_SIZE %4 ); +ath10k_save_firmware_mem_helper (ar,ATH10K_FW_STACK_SIZE , + ar->stack_buf,HI_ITEM (hi_stack)); +} + +static void ath10k_pci_hif_dump_area (struct ath10k *ar) {u32 reg_dump_area =0 ;
@@ -881,6 +913,13 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar) reg_dump_values[i +2 ], reg_dump_values[i + 3]); +spin_lock_irqsave (&ar->crash_data_lock, flags); + +if (!ar->crashed_since_read) +ath10k_save_firmware_stack (ar); + +spin_unlock_irqrestore (&ar->crash_data_lock, flags); +/* Dump the debug logs on the target */ host_addr =host_interest_item_address (HI_ITEM (hi_dbglog_hdr)); ret = ath10k_pci_diag_read_mem(ar, host_addr,
Signature · 1 line
1.7.11.7
PATCH v2 4/4 ath10k: Dump exception stack contents on firmware crash.
In reply to [email protected]From: Ben Greear <[email protected]>
Firmware developers can decode this and maybe figure out why the firmware crashed.
--- drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/debug.c | 8 ++++++++ drivers/net/wireless/ath/ath10k/pci.c | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/core.h +2 -0
@@ -347,6 +347,7 @@ enum ath10k_fw_error_dump_type {ATH10K_FW_ERROR_DUMP_DBGLOG =0 ,ATH10K_FW_ERROR_DUMP_REGDUMP =1 ,ATH10K_FW_ERROR_DUMP_STACK =2 , +ATH10K_FW_ERROR_DUMP_EXC_STACK =3 , ATH10K_FW_ERROR_DUMP_MAX, };
@@ -560,6 +561,7 @@ struct ath10k {struct ath10k_dbglog_entry_storage dbglog_entry_data;u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ];unsigned char stack_buf[ATH10K_FW_STACK_SIZE ]; +unsigned char exc_stack_buf[ATH10K_FW_STACK_SIZE ];#ifdef CONFIG_ATH10K_DEBUGFS struct ath10k_debug debug;
drivers/net/wireless/ath/ath10k/debug.c +8 -0
@@ -620,6 +620,7 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) len +=sizeof (*dump_tlv) +sizeof (ar->reg_dump_values); len +=sizeof (*dump_tlv) +sizeof (ar->dbglog_entry_data); len +=sizeof (*dump_tlv) +sizeof (ar->stack_buf); + len +=sizeof (*dump_tlv) +sizeof (ar->exc_stack_buf);lockdep_assert_held (&ar->conf_mutex);
@@ -693,6 +694,13 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar)memcpy (dump_tlv->tlv_data, &ar->stack_buf, dump_tlv->tlv_len); sofar +=sizeof (*dump_tlv) + dump_tlv->tlv_len; +/* Gather firmware exception (irq) stack dump */ + dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar); + dump_tlv->type =ATH10K_FW_ERROR_DUMP_EXC_STACK ; + dump_tlv->tlv_len =sizeof (ar->exc_stack_buf); +memcpy (dump_tlv->tlv_data, &ar->exc_stack_buf, dump_tlv->tlv_len); + sofar +=sizeof (*dump_tlv) + dump_tlv->tlv_len; +spin_unlock_irqrestore (&ar->crash_data_lock, flags);WARN_ON (sofar != len);
drivers/net/wireless/ath/ath10k/pci.c +10 -1
@@ -865,6 +865,13 @@ static void ath10k_save_firmware_stack(struct ath10k *ar) ar->stack_buf, HI_ITEM(hi_stack)); } +/* Save the firmware exception stack */ +static void ath10k_save_firmware_exc_stack (struct ath10k *ar) +{ +ath10k_save_firmware_mem_helper (ar,ATH10K_FW_STACK_SIZE , + ar->exc_stack_buf, +HI_ITEM (hi_err_stack)); +}static void ath10k_pci_hif_dump_area (struct ath10k *ar) {
@@ -915,8 +922,10 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)spin_lock_irqsave (&ar->crash_data_lock, flags); -if (!ar->crashed_since_read) +if (!ar->crashed_since_read) {ath10k_save_firmware_stack (ar); +ath10k_save_firmware_exc_stack (ar); + }spin_unlock_irqrestore (&ar->crash_data_lock, flags);
Signature · 1 line
1.7.11.7