ath10k: provide firmware crash info via debugfs.
PATCH 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.
---
Changes from RFC: Fixed spacing and naming and some other requests. Did not change everything Michal asked for.
Also, added a bunch of info to the file header to have better chance of understanding what hardware/firmware/kernel and such is being reported. Version field will let us update the file format as needed...whatever decodes it can take different action based on the version, etc.
drivers/net/wireless/ath/ath10k/core.h | 73 ++++++++++++++++ drivers/net/wireless/ath/ath10k/debug.c | 144 ++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/debug.h | 25 ++++++ drivers/net/wireless/ath/ath10k/pci.c | 82 +++++++++++++++++- 4 files changed, 321 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +73 -0
@@ -41,6 +41,11 @@#define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)#define ATH10K_NUM_CHANS 38 +/* Duplicates define in pci.h, if there is ever mis-match we should +* get a compile error. Cannot just include pci.h here. +*/ +#define REG_DUMP_COUNT_QCA988X 60 +/* Antenna noise floor */ #define ATH10K_DEFAULT_NOISE_FLOOR -95
@@ -338,6 +343,68 @@ enum ath10k_dev_flags { ATH10K_FLAG_CORE_REGISTERED, }; +/** +* enum ath10k_fw_error_dump_type - types of data in the dump file +* @ATH10K_FW_ERROR_DUMP_DBGLOG: Recent firmware debug log entries +* @ATH10K_FW_ERROR_DUMP_CRASH: Crash dump in binary format +*/ +enum ath10k_fw_error_dump_type { +ATH10K_FW_ERROR_DUMP_DBGLOG =0 , +ATH10K_FW_ERROR_DUMP_REGDUMP =1 , + +ATH10K_FW_ERROR_DUMP_MAX , +}; + + +struct ath10k_tlv_dump_data { +u32 type;/* see ath10k_fw_error_dump_type above */ +u32 tlv_len;/* in bytes */ +u8 tlv_data[];/* Pad to 32-bit boundaries as needed. */ +} __packed; + +struct ath10k_dump_file_data { +/* Dump file information */ +u32 len; +u32 magic;/* 0x01020304, tells us byte-order of host if we care */ +u32 version;/* File dump version, 1 for now. */ + +/* Some info we can get from ath10k struct that might help. */ +u32 chip_id; +u32 target_version; +u8 fw_version_major; +u8 unused8;/* pad fw_version_major */ +u16 unused16;/* pad fw_version_major */ +u32 fw_version_minor; +u16 fw_version_release; +u16 fw_version_build; +u32 phy_capability; +u32 hw_min_tx_power; +u32 hw_max_tx_power; +u32 ht_cap_info; +u32 vht_cap_info; +u32 num_rf_chains; +char fw_ver[64 ];/* Firmware version string */ + +/* Kernel related information */ +u32 kernel_ver_code;/* LINUX_VERSION_CODE */ +char kernel_ver[64 ];/* VERMAGIC_STRING */ + +u8 unused[64 ];/* Room for growth w/out changing binary format */ + +struct ath10k_tlv_dump_data data;/* more may follow */ +} __packed; + +/* This will store at least the last 128 entries. Each dbglog message +* is a max of 7 32-bit integers in length, but the length can be less +* than that as well. +*/ +#define ATH10K_DBGLOG_DATA_LEN (128 * 7 * 4) +struct ath10k_dbglog_entry_storage { +u32 next_idx;/* Where to write next chunk of data */ +u8 data[ATH10K_DBGLOG_DATA_LEN ]; +}; + +struct ath10k {struct ath_common ath_common;struct ieee80211_hw *hw;
@@ -488,6 +555,12 @@ struct ath10k {struct dfs_pattern_detector *dfs_detector; +/* Used for crash-dump storage */ +/* Don't over-write dump info until someone reads the data. */ +bool crashed_since_read; +struct ath10k_dbglog_entry_storage dbglog_entry_data; +u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ]; +#ifdef CONFIG_ATH10K_DEBUGFS struct ath10k_debug debug;#endif
drivers/net/wireless/ath/ath10k/debug.c +144 -0
162 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/debug.h +25 -0
@@ -19,6 +19,7 @@#define _DEBUG_H_#include <linux/types.h> +#include "pci.h" #include "trace.h" enum ath10k_debug_mask {
@@ -110,4 +111,28 @@ static inline void ath10k_dbg_dump(enum ath10k_debug_mask mask, { }#endif /* CONFIG_ATH10K_DEBUG */ + + +/* 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; + +void ath10k_dbg_save_fw_dbg_buffer (struct ath10k *ar,u8 *buffer,int len); +#endif /* _DEBUG_H_ */
drivers/net/wireless/ath/ath10k/pci.c +79 -3
112 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 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 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 | 3 +++ drivers/net/wireless/ath/ath10k/debug.c | 11 ++++++++++- drivers/net/wireless/ath/ath10k/pci.c | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/core.h +3 -0
@@ -45,6 +45,7 @@* get a compile error. Cannot just include pci.h here. */ #define REG_DUMP_COUNT_QCA988X 60 +#define ATH10K_FW_STACK_SIZE 4096/* Antenna noise floor */ #define ATH10K_DEFAULT_NOISE_FLOOR -95
@@ -351,6 +352,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 , };
@@ -560,6 +562,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 +10 -1
@@ -601,6 +601,7 @@ EXPORT_SYMBOL(ath10k_dbg_save_fw_dbg_buffer);static struct ath10k_dump_file_data *ath10k_build_dump_file (struct ath10k *ar) {unsigned int len = (sizeof (ar->dbglog_entry_data) + +sizeof (ar->stack_buf) +sizeof (ar->reg_dump_values));unsigned int sofar =0 ;char *buf;
@@ -614,7 +615,7 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) sofar += hdr_len;/* So we can add headers to the data dump */ - len +=2 *sizeof (*dump_tlv); + len +=3 *sizeof (*dump_tlv);/* This is going to get big when we start dumping FW RAM and such, * so go ahead and use vmalloc.
@@ -662,6 +663,14 @@ 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; + +WARN_ON (sofar != len);return dump_data; }
drivers/net/wireless/ath/ath10k/pci.c +35 -0
@@ -833,6 +833,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 %8 ); +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 ;
@@ -877,6 +909,9 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar) reg_dump_values[i +2 ], reg_dump_values[i + 3]); +if (!ar->crashed_since_read) +ath10k_save_firmware_stack (ar); +/* Dump the debug logs on the target */ host_addr =host_interest_item_address (HI_ITEM (hi_dbglog_hdr)); if (ath10k_pci_diag_read_mem(ar, host_addr,
Signature · 1 line
1.7.11.7
PATCH 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 | 10 +++++++++- drivers/net/wireless/ath/ath10k/pci.c | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +2 -0
@@ -353,6 +353,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, };
@@ -563,6 +564,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 +9 -1
@@ -602,6 +602,7 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) {unsigned int len = (sizeof (ar->dbglog_entry_data) +sizeof (ar->stack_buf) + +sizeof (ar->exc_stack_buf) +sizeof (ar->reg_dump_values));unsigned int sofar =0 ;char *buf;
@@ -615,7 +616,7 @@ static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) sofar += hdr_len;/* So we can add headers to the data dump */ - len +=3 *sizeof (*dump_tlv); + len +=4 *sizeof (*dump_tlv);/* This is going to get big when we start dumping FW RAM and such, * so go ahead and use vmalloc.
@@ -670,6 +671,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; +WARN_ON (sofar != len);return dump_data; }
drivers/net/wireless/ath/ath10k/pci.c +10 -1
@@ -864,6 +864,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) {
@@ -909,8 +916,10 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar) reg_dump_values[i +2 ], reg_dump_values[i + 3]); -if (!ar->crashed_since_read) +if (!ar->crashed_since_read) {ath10k_save_firmware_stack (ar); +ath10k_save_firmware_exc_stack (ar); + }/* Dump the debug logs on the target */ host_addr =host_interest_item_address (HI_ITEM (hi_dbglog_hdr));
Signature · 1 line
1.7.11.7
Quoted 9 lines · [email protected] writes:
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.
Signed-off-by Ben Greear <[email protected]>
My first comments, more later. But my first impression is that I like this, we just need to sort out some implementation issues.
kbuild found some warnings:
drivers/net/wireless/ath/ath10k/debug.c:725:2: error: implicit declaration of function 'vfree' [-Werror=implicit-function-declaration] drivers/net/wireless/ath/ath10k/debug.c:624:2: error: implicit declaration of function 'vmalloc' [-Werror=implicit-function-declaration] drivers/net/wireless/ath/ath10k/debug.c:624:6: warning: assignment makes pointer from integer without a cast [enabled by default]
The naming of structures and functions are a bit too long, but I'll comment on that later. That's easy to change as the last thing.
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 358
Quoted 13 lines
drivers/net/wireless/ath/ath10k/core.h +13
-0+/** +* enum ath10k_fw_error_dump_type - types of data in the dump file +* @ATH10K_FW_ERROR_DUMP_DBGLOG: Recent firmware debug log entries +* @ATH10K_FW_ERROR_DUMP_CRASH: Crash dump in binary format +*/ +enum ath10k_fw_error_dump_type { +ATH10K_FW_ERROR_DUMP_DBGLOG =0 , +ATH10K_FW_ERROR_DUMP_REGDUMP =1 , + +ATH10K_FW_ERROR_DUMP_MAX , +}; + +
Extra newline.
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 369
Quoted 11 lines
drivers/net/wireless/ath/ath10k/core.h +11
-0+struct ath10k_tlv_dump_data { +u32 type;/* see ath10k_fw_error_dump_type above */ +u32 tlv_len;/* in bytes */ +u8 tlv_data[];/* Pad to 32-bit boundaries as needed. */ +} __packed; + +struct ath10k_dump_file_data { +/* Dump file information */ +u32 len; +u32 magic;/* 0x01020304, tells us byte-order of host if we care */ +u32 version;/* File dump version, 1 for now. */
Actually I would prefer to have magic first and have ASCII string as string, for example "ATH10K-FW-DUMP".
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 373
Quoted 3 lines
drivers/net/wireless/ath/ath10k/core.h +3
-0+/* Some info we can get from ath10k struct that might help. */ +u32 chip_id; +u32 target_version;
bus_type or something like that would be good to add already now.
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 376
Quoted 3 lines
drivers/net/wireless/ath/ath10k/core.h +3
-0+u8 fw_version_major; +u8 unused8;/* pad fw_version_major */ +u16 unused16;/* pad fw_version_major */
I don't see any point of using u8 or u16. Would it be simpler just to use u32 for everything?
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 386
Quoted 10 lines
drivers/net/wireless/ath/ath10k/core.h +10
-0+u32 fw_version_minor; +u16 fw_version_release; +u16 fw_version_build; +u32 phy_capability; +u32 hw_min_tx_power; +u32 hw_max_tx_power; +u32 ht_cap_info; +u32 vht_cap_info; +u32 num_rf_chains; +char fw_ver[64 ];/* Firmware version string */
Can we reuse ETHTOOL_FWVERS_LEN? cfg80211 already uses that.
#define ETHTOOL_FWVERS_LEN 32
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 392
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0+/* Kernel related information */ +u32 kernel_ver_code;/* LINUX_VERSION_CODE */ +char kernel_ver[64 ];/* VERMAGIC_STRING */ + +u8 unused[64 ];/* Room for growth w/out changing binary format */
Maybe 128 bytes, just so that we don't need to change it for some time?
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 394
Quoted 1 line
drivers/net/wireless/ath/ath10k/core.h +1
-0+struct ath10k_tlv_dump_data data;/* more may follow */
I would prefer:
u8 data[0];
So that this struct is only about the header.
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 401
Quoted 7 lines
drivers/net/wireless/ath/ath10k/core.h +7
-0+} __packed; + +/* This will store at least the last 128 entries. Each dbglog message +* is a max of 7 32-bit integers in length, but the length can be less +* than that as well. +*/ +#define ATH10K_DBGLOG_DATA_LEN (128 * 7 * 4)
Empty line after the define.
drivers/net/wireless/ath/ath10k/core.h struct ath10k { · line 562
Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0@@ -488,6 +555,12 @@ struct ath10k {struct dfs_pattern_detector *dfs_detector; +/* Used for crash-dump storage */ +/* Don't over-write dump info until someone reads the data. */ +bool crashed_since_read; +struct ath10k_dbglog_entry_storage dbglog_entry_data; +u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ];
I think these should be in struct ath10k_debug.
Quoted 15 lines
drivers/net/wireless/ath/ath10k/debug.c +2
-0@@ -17,6 +17,8 @@#include <linux/module.h> #include <linux/debugfs.h> +#include <linux/version.h> +#include <linux/vermagic.h> #include "core.h" #include "debug.h" @@ -577,6 +579,145 @@ static const struct file_operations fops_chip_id = { .llseek = default_llseek,
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 589
Quoted 10 lines
drivers/net/wireless/ath/ath10k/debug.c +8
-0}; +void ath10k_dbg_save_fw_dbg_buffer (struct ath10k *ar,u8 *buffer,int len) +{ +int i; +int z = ar->dbglog_entry_data.next_idx; + +/* Don't save any new logs until user-space reads this. */ +if (ar->crashed_since_read) +return ;
Locking? If this functions depends on something, please document that with lockdep_assert_held().
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 596
Quoted 6 lines
drivers/net/wireless/ath/ath10k/debug.c +6
-0+for (i =0 ; i < len; i++) { + ar->dbglog_entry_data.data[z] = buffer[i]; + z++; +if (z >=ATH10K_DBGLOG_DATA_LEN ) + z =0 ; + }
Empty line here.
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 603
Quoted 7 lines
drivers/net/wireless/ath/ath10k/debug.c +7
-0+ ar->dbglog_entry_data.next_idx = z; +} +EXPORT_SYMBOL (ath10k_dbg_save_fw_dbg_buffer); + +static struct ath10k_dump_file_data *ath10k_build_dump_file (struct ath10k *ar) +{ + unsigned int len = (sizeof(ar->dbglog_entry_data)
Unneeded parenthesis.
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 609
Quoted 6 lines
drivers/net/wireless/ath/ath10k/debug.c +6
-0+ + sizeof(ar->reg_dump_values)); +unsigned int sofar =0 ; +char *buf; +struct ath10k_tlv_dump_data *dump_tlv; +struct ath10k_dump_file_data *dump_data; +int hdr_len =sizeof (*dump_data) -sizeof (dump_data->data);
I prefer separating variable declarations and definitions.
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 617
Quoted 8 lines
drivers/net/wireless/ath/ath10k/debug.c +8
-0+ +lockdep_assert_held (&ar->conf_mutex); + + len += hdr_len; + sofar += hdr_len; + +/* So we can add headers to the data dump */ + len +=2 *sizeof (*dump_tlv);
This is a bit awkward way of defining the length. Something like this would be easier to read:
len = sizeof (*dump_tlv) + sizeof(ar->dbglog_entry_data);
len += sizeof (*dump_tlv) + sizeof(ar->reg_dump_values));
Quoted 18 lines
drivers/net/wireless/ath/ath10k/debug.c +18
-0+ +/* This is going to get big when we start dumping FW RAM and such, +* so go ahead and use vmalloc. +*/ + buf =vmalloc (len); +if (!buf) +return NULL ; + +memset (buf,0 , len); + dump_data = (struct ath10k_dump_file_data *)(buf); + dump_data->len = len; + dump_data->magic =0x01020304 ; + dump_data->version =1 ; + dump_data->chip_id = ar->chip_id; + dump_data->target_version = ar->target_version; + dump_data->fw_version_major = ar->fw_version_major; + dump_data->fw_version_minor = ar->fw_version_minor; + dump_data->fw_version_release = ar->fw_version_release;
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 645
Quoted 10 lines
drivers/net/wireless/ath/ath10k/debug.c +10
-0+ dump_data->fw_version_build = ar->fw_version_build; + dump_data->phy_capability = ar->phy_capability; + dump_data->hw_min_tx_power = ar->hw_min_tx_power; + dump_data->hw_max_tx_power = ar->hw_max_tx_power; + dump_data->ht_cap_info = ar->ht_cap_info; + dump_data->vht_cap_info = ar->vht_cap_info; + dump_data->num_rf_chains = ar->num_rf_chains; + +strncpy (dump_data->fw_ver, ar->hw->wiphy->fw_version, +sizeof (dump_data->fw_ver) -1 );
BUILD_BUG_ON(sizeof(dump_data->fw_ver) != sizeof(ar->hw->wiphy->fw_version))?
And wouldn't strlcpy() be safer?
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 647
Quoted 1 line
drivers/net/wireless/ath/ath10k/debug.c +1
-0+ dump_data->kernel_ver_code =LINUX_VERSION_CODE ;
checkpatch actually complains about this:
drivers/net/wireless/ath/ath10k/debug.c:649: WARNING: LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged
But I guess there's nothing we can do for that.
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 649
Quoted 2 lines
drivers/net/wireless/ath/ath10k/debug.c +2
-0+strncpy (dump_data->kernel_ver,VERMAGIC_STRING , +sizeof (dump_data->kernel_ver) -1 );
strlcpy()?
Quoted 15 lines
drivers/net/wireless/ath/ath10k/debug.c +15
-0+/* Gather dbg-log */ + dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar); + dump_tlv->type =ATH10K_FW_ERROR_DUMP_DBGLOG ; + dump_tlv->tlv_len =sizeof (ar->dbglog_entry_data); +memcpy (dump_tlv->tlv_data, &ar->dbglog_entry_data, dump_tlv->tlv_len); + sofar +=sizeof (*dump_tlv) + dump_tlv->tlv_len; + +/* Gather crash-dump */ + dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar); + dump_tlv->type =ATH10K_FW_ERROR_DUMP_REGDUMP ; + dump_tlv->tlv_len =sizeof (ar->reg_dump_values); +memcpy (dump_tlv->tlv_data, &ar->reg_dump_values, dump_tlv->tlv_len); + sofar +=sizeof (*dump_tlv) + dump_tlv->tlv_len; + +return dump_data;
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 675
Quoted 10 lines
drivers/net/wireless/ath/ath10k/debug.c +10
-0+} + +static int ath10k_fw_error_dump_open (struct inode *inode,struct file *file) +{ +struct ath10k *ar = inode->i_private; +int ret; +struct ath10k_dump_file_data *dump; + +if (!ar) +return -EINVAL ;
Is this cheak necessary? In what cases is i_private NULL?
drivers/net/wireless/ath/ath10k/debug.h line 22
Quoted 7 lines
drivers/net/wireless/ath/ath10k/debug.h +1
-0@@ -19,6 +19,7 @@#define _DEBUG_H_#include <linux/types.h> +#include "pci.h"
debug.h shouldn't access pci.h directly. All access should happen through hif.
Quoted 17 lines
drivers/net/wireless/ath/ath10k/debug.h +11
-0enum ath10k_debug_mask {@@ -110,4 +111,28 @@ static inline void ath10k_dbg_dump(enum ath10k_debug_mask mask, { }#endif /* CONFIG_ATH10K_DEBUG */ + + +/* 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 */
drivers/net/wireless/ath/ath10k/debug.h static inline void ath10k_dbg_dump(enum ath10k_debug_mask mask, · line 134
Quoted 10 lines
drivers/net/wireless/ath/ath10k/debug.h +10
-0+u32 bufsize; +u32 length; +u32 count; +u32 free; +} __packed; + +struct ath10k_fw_dbglog_hdr { +u32 dbuf;/* pointer to dbglog_buf_s */ +u32 dropped; +} __packed;
Should these be in hw.h?
drivers/net/wireless/ath/ath10k/pci.c line 22
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +0
-1@@ -19,7 +19,7 @@#include <linux/module.h> #include <linux/interrupt.h> #include <linux/spinlock.h> -#include <linux/bitops.h>
Why remove bitops.h?
Have to stop here, more later.
Signature · 1 line
Kalle Valo
Quoted 6 lines · Kalle Valo
Quoted 6 lines
drivers/net/wireless/ath/ath10k/core.h +6
-0+struct ath10k_tlv_dump_data { +u32 type;/* see ath10k_fw_error_dump_type above */ +u32 tlv_len;/* in bytes */ +u8 tlv_data[];/* Pad to 32-bit boundaries as needed. */ +} __packed; +
Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 369
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0+struct ath10k_dump_file_data { +/* Dump file information */ +u32 len; +u32 magic;/* 0x01020304, tells us byte-order of host if we care */ +u32 version;/* File dump version, 1 for now. */ Actually I would prefer to have magic first and have ASCII string as string, for example "ATH10K-FW-DUMP".
I'd like magic number to stay, was planning to use it to detect byte ordering (ie, dumps might come from various different platforms, to be decoded on some different platform).
I will add the string, however.
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 373
Quoted 3 lines
drivers/net/wireless/ath/ath10k/core.h +3
-0+/* Some info we can get from ath10k struct that might help. */ +u32 chip_id; +u32 target_version;
bus_typeor something like that would be good to add already now.
Can you be more specific on what info you want here? I don't see any mention of bus_type in the ath10k dir.
Quoted 13 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 386
Quoted 10 lines
drivers/net/wireless/ath/ath10k/core.h +10
-0+u32 fw_version_minor; +u16 fw_version_release; +u16 fw_version_build; +u32 phy_capability; +u32 hw_min_tx_power; +u32 hw_max_tx_power; +u32 ht_cap_info; +u32 vht_cap_info; +u32 num_rf_chains; +char fw_ver[64 ];/* Firmware version string */ Can we reuse
ETHTOOL_FWVERS_LEN? cfg80211 already uses that.
Quoted 1 line
#define
ETHTOOL_FWVERS_LEN32
I prefer not to..that way, firmware format will remain the same even if the kernel changes the fwvers-len some day.
Quoted 7 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 392
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0+/* Kernel related information */ +u32 kernel_ver_code;/* LINUX_VERSION_CODE */ +char kernel_ver[64 ];/* VERMAGIC_STRING */ + +u8 unused[64 ];/* Room for growth w/out changing binary format */ Maybe 128 bytes, just so that we don't need to change it for some time?
certainly.
Quoted 11 lines
drivers/net/wireless/ath/ath10k/core.h struct ath10k { · line 562
Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0@@ -488,6 +555,12 @@ struct ath10k {struct dfs_pattern_detector *dfs_detector; +/* Used for crash-dump storage */ +/* Don't over-write dump info until someone reads the data. */ +bool crashed_since_read; +struct ath10k_dbglog_entry_storage dbglog_entry_data; +u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ];I think these should be in struct
ath10k_debug.
I did not do this because I figure we will want ethtool support w/out forcing debugfs to be enabled someday soon.
Quoted 11 lines
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 589
Quoted 8 lines
drivers/net/wireless/ath/ath10k/debug.c +8
-0+void ath10k_dbg_save_fw_dbg_buffer (struct ath10k *ar,u8 *buffer,int len) +{ +int i; +int z = ar->dbglog_entry_data.next_idx; + +/* Don't save any new logs until user-space reads this. */ +if (ar->crashed_since_read) +return ;Locking? If this functions depends on something, please document that with
lockdep_assert_held().
To be honest, I was going to ignore locking and assume that firmware will not crash that often. Worst case would be a garbled crash dump as there is no memory allocation involved in gathering the crash, and the length of the crash dump will not change based on anything in the crash logic.
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer. If so, any idea if we can do the reads of the target's memory while holding a spin-lock, or would I need some temporary buffers and only lock while copying that in to the storage in the 'ar'?
Quoted 9 lines
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 603
Quoted 7 lines
drivers/net/wireless/ath/ath10k/debug.c +7
-0+ ar->dbglog_entry_data.next_idx = z; +} +EXPORT_SYMBOL (ath10k_dbg_save_fw_dbg_buffer); + +static struct ath10k_dump_file_data *ath10k_build_dump_file (struct ath10k *ar) +{ + unsigned int len = (sizeof(ar->dbglog_entry_data)Unneeded parenthesis.
Makes things line up nicely in xemacs auto-indent, but will fix.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 17 lines · Ben Greear
Quoted 6 lines · Kalle Valo
Quoted 6 lines
drivers/net/wireless/ath/ath10k/core.h +6
-0+struct ath10k_tlv_dump_data { +u32 type;/* see ath10k_fw_error_dump_type above */ +u32 tlv_len;/* in bytes */ +u8 tlv_data[];/* Pad to 32-bit boundaries as needed. */ +} __packed; +Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 369
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0+struct ath10k_dump_file_data { +/* Dump file information */ +u32 len; +u32 magic;/* 0x01020304, tells us byte-order of host if we care */ +u32 version;/* File dump version, 1 for now. */ Actually I would prefer to have magic first and have ASCII string as string, for example "ATH10K-FW-DUMP".
Quoted 3 lines
I'd like magic number to stay, was planning to use it to detect byte ordering (ie, dumps might come from various different platforms, to be decoded on some different platform).
If you want to know the endianess, I would prefer to do it the proper way, for example something like this:
#ifdef __BIG_ENDIAN
dump_data->big_endian = 1;
#else
dump_data->big_endian = 0;#endif
Quoted 8 lines
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 373
Quoted 3 lines
drivers/net/wireless/ath/ath10k/core.h +3
-0+/* Some info we can get from ath10k struct that might help. */ +u32 chip_id; +u32 target_version;
bus_typeor something like that would be good to add already now.Can you be more specific on what info you want here? I don't see any mention of
bus_typein the ath10k dir.
I was thinking of adding a new field named "bus_type" which will contain just zero for now. This is so that we don't need to make any changes to the format if/when we add a new bus along with pci.
Quoted 13 lines
Quoted 13 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 386
Quoted 10 lines
drivers/net/wireless/ath/ath10k/core.h +10
-0+u32 fw_version_minor; +u16 fw_version_release; +u16 fw_version_build; +u32 phy_capability; +u32 hw_min_tx_power; +u32 hw_max_tx_power; +u32 ht_cap_info; +u32 vht_cap_info; +u32 num_rf_chains; +char fw_ver[64 ];/* Firmware version string */ Can we reuse
ETHTOOL_FWVERS_LEN? cfg80211 already uses that.
Quoted 4 lines
Quoted 1 line
#define
ETHTOOL_FWVERS_LEN32I prefer not to..that way, firmware format will remain the same even if the kernel changes the fwvers-len some day.
That is defined in the ethtool user space interface so changing that would break a lot of things. And also used by cfg80211 and other drivers. I would prefer to be consistent here and use ETHTOOL_FWVERS_LEN.
Quoted 12 lines
Quoted 11 lines
drivers/net/wireless/ath/ath10k/core.h struct ath10k { · line 562
Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0@@ -488,6 +555,12 @@ struct ath10k {struct dfs_pattern_detector *dfs_detector; +/* Used for crash-dump storage */ +/* Don't over-write dump info until someone reads the data. */ +bool crashed_since_read; +struct ath10k_dbglog_entry_storage dbglog_entry_data; +u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ];I think these should be in struct
ath10k_debug.
Quoted 2 lines
I did not do this because I figure we will want ethtool support w/out forcing debugfs to be enabled someday soon.
When we add ethtool support, it's easy to move these back. And then we need to move the code out from debug.c anyway.
Quoted 12 lines
Quoted 11 lines
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 589
Quoted 8 lines
drivers/net/wireless/ath/ath10k/debug.c +8
-0+void ath10k_dbg_save_fw_dbg_buffer (struct ath10k *ar,u8 *buffer,int len) +{ +int i; +int z = ar->dbglog_entry_data.next_idx; + +/* Don't save any new logs until user-space reads this. */ +if (ar->crashed_since_read) +return ;Locking? If this functions depends on something, please document that with
lockdep_assert_held().
Quoted 5 lines
To be honest, I was going to ignore locking and assume that firmware will not crash that often. Worst case would be a garbled crash dump as there is no memory allocation involved in gathering the crash, and the length of the crash dump will not change based on anything in the crash logic.
Ignoring locking means that in few years we have a big mess in our hands. I prefer to do the locking right from day one.
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check ar->data_lock can be used.
Quoted 3 lines
If so, any idea if we can do the reads of the target's memory while holding a spin-lock, or would I need some temporary buffers and only lock while copying that in to the storage in the 'ar'?
I don't see why you would need special locks for reading target's memory. If there is something needed, pci.c should handle that. Michal?
Signature · 1 line
Kalle Valo
Quoted 1 line · Kalle Valo
Ben Greear <[email protected]> writes:
[...]
Quoted 6 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.
Quoted 6 lines
Quoted 3 lines
If so, any idea if we can do the reads of the target's memory while holding a spin-lock, or would I need some temporary buffers and only lock while copying that in to the storage in the 'ar'?
I don't see why you would need special locks for reading target's memory. If there is something needed,
pci.cshould handle that. Michal?
By definition the diagnostic window access must be serialized. We don't do this with locks now but rely ON driver states/sequences. We might have some problems lurking there already but I'd need to analyze it to tell for sure.
Calling pci_diag_* functions while holding a spinlock should otherwise be fine because these functions use mdelay() and poll the diagnostic window copy engine pipe.
Using ar->data_lock for a pci transport specific requirement (the diagnostic window) seems wrong though.
Michał
Quoted 13 lines · Michal Kazior
Quoted 1 line · Kalle Valo
Ben Greear <[email protected]> writes:
[...]
Quoted 10 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.Quoted 3 lines
If so, any idea if we can do the reads of the target's memory while holding a spin-lock, or would I need some temporary buffers and only lock while copying that in to the storage in the 'ar'?
Quoted 7 lines
Quoted 2 lines
I don't see why you would need special locks for reading target's memory. If there is something needed,
pci.cshould handle that. Michal?By definition the diagnostic window access must be serialized. We don't do this with locks now but rely ON driver states/sequences. We might have some problems lurking there already but I'd need to analyze it to tell for sure.
Should that serialisation happen within pci.c?
Quoted 6 lines
Calling pci_diag_* functions while holding a spinlock should otherwise be fine because these functions use
mdelay()and poll the diagnostic window copy engine pipe.Using
ar->data_lockfor a pci transport specific requirement (the diagnostic window) seems wrong though.
I agree. I did not mean using data_lock to serialise the pci code.
Signature · 1 line
Kalle Valo
Quoted 18 lines · Kalle Valo
Quoted 16 lines · Michal Kazior
Quoted 1 line · Kalle Valo
Ben Greear <[email protected]> writes:
[...]
Quoted 12 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.Quoted 3 lines
If so, any idea if we can do the reads of the target's memory while holding a spin-lock, or would I need some temporary buffers and only lock while copying that in to the storage in the 'ar'?
I don't see why you would need special locks for reading target's memory. If there is something needed,
pci.cshould handle that. Michal?
Quoted 6 lines
Quoted 4 lines
By definition the diagnostic window access must be serialized. We don't do this with locks now but rely ON driver states/sequences. We might have some problems lurking there already but I'd need to analyze it to tell for sure.
Should that serialisation happen within
pci.c?
You can but that's not a requirement I guess. E.g. exchange_bmi_msg hif callback requires the caller to serialize calls.
Michał
Quoted 23 lines · Kalle Valo
Quoted 17 lines · Ben Greear
Quoted 6 lines · Kalle Valo
Quoted 6 lines
drivers/net/wireless/ath/ath10k/core.h +6
-0+struct ath10k_tlv_dump_data { +u32 type;/* see ath10k_fw_error_dump_type above */ +u32 tlv_len;/* in bytes */ +u8 tlv_data[];/* Pad to 32-bit boundaries as needed. */ +} __packed; +Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 369
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0+struct ath10k_dump_file_data { +/* Dump file information */ +u32 len; +u32 magic;/* 0x01020304, tells us byte-order of host if we care */ +u32 version;/* File dump version, 1 for now. */ Actually I would prefer to have magic first and have ASCII string as string, for example "ATH10K-FW-DUMP".
Quoted 3 lines
I'd like magic number to stay, was planning to use it to detect byte ordering (ie, dumps might come from various different platforms, to be decoded on some different platform).
Quoted 8 lines
If you want to know the endianess, I would prefer to do it the proper way, for example something like this:
#ifdef __BIG_ENDIAN dump_data->big_endian = 1; #else dump_data->big_endian = 0;#endif
Ok.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 373
Quoted 3 lines
drivers/net/wireless/ath/ath10k/core.h +3
-0+/* Some info we can get from ath10k struct that might help. */ +u32 chip_id; +u32 target_version;
bus_typeor something like that would be good to add already now.
Quoted 6 lines
Quoted 2 lines
Can you be more specific on what info you want here? I don't see any mention of
bus_typein the ath10k dir.I was thinking of adding a new field named "
bus_type" which will contain just zero for now. This is so that we don't need to make any changes to the format if/when we add a new bus along with pci.
Sure, will do.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
drivers/net/wireless/ath/ath10k/core.h enum ath10k_dev_flags { · line 386
Quoted 10 lines
drivers/net/wireless/ath/ath10k/core.h +10
-0+u32 fw_version_minor; +u16 fw_version_release; +u16 fw_version_build; +u32 phy_capability; +u32 hw_min_tx_power; +u32 hw_max_tx_power; +u32 ht_cap_info; +u32 vht_cap_info; +u32 num_rf_chains; +char fw_ver[64 ];/* Firmware version string */ Can we reuse
ETHTOOL_FWVERS_LEN? cfg80211 already uses that.#define
ETHTOOL_FWVERS_LEN32
Quoted 7 lines
Quoted 2 lines
I prefer not to..that way, firmware format will remain the same even if the kernel changes the fwvers-len some day.
That is defined in the ethtool user space interface so changing that would break a lot of things. And also used by cfg80211 and other drivers. I would prefer to be consistent here and use
ETHTOOL_FWVERS_LEN.
Ok.
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/net/wireless/ath/ath10k/core.h struct ath10k { · line 562
Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.h +5
-0@@ -488,6 +555,12 @@ struct ath10k {struct dfs_pattern_detector *dfs_detector; +/* Used for crash-dump storage */ +/* Don't over-write dump info until someone reads the data. */ +bool crashed_since_read; +struct ath10k_dbglog_entry_storage dbglog_entry_data; +u32 reg_dump_values[REG_DUMP_COUNT_QCA988X ];I think these should be in struct
ath10k_debug.
Quoted 5 lines
Quoted 2 lines
I did not do this because I figure we will want ethtool support w/out forcing debugfs to be enabled someday soon.
When we add ethtool support, it's easy to move these back. And then we need to move the code out from
debug.canyway.
Well, it seems like needless churn and makes it harder to follow 'git blame' when you move big chunks around.
We would not have to move the code out of debug.c, but if you do want it moved, lets pick that place now and just put it there to begin with.
Quoted 18 lines
Quoted 12 lines
Quoted 11 lines
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 589
Quoted 8 lines
drivers/net/wireless/ath/ath10k/debug.c +8
-0+void ath10k_dbg_save_fw_dbg_buffer (struct ath10k *ar,u8 *buffer,int len) +{ +int i; +int z = ar->dbglog_entry_data.next_idx; + +/* Don't save any new logs until user-space reads this. */ +if (ar->crashed_since_read) +return ;Locking? If this functions depends on something, please document that with
lockdep_assert_held().Quoted 5 lines
To be honest, I was going to ignore locking and assume that firmware will not crash that often. Worst case would be a garbled crash dump as there is no memory allocation involved in gathering the crash, and the length of the crash dump will not change based on anything in the crash logic.
Quoted 8 lines
Ignoring locking means that in few years we have a big mess in our hands. I prefer to do the locking right from day one.
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.
I think it has to be a spin-lock because the crash dump is gathered in the irq handler, so I can't use a mutex as far as I know...
I'll work on adding such a lock today.
Quoted 6 lines
Quoted 3 lines
If so, any idea if we can do the reads of the target's memory while holding a spin-lock, or would I need some temporary buffers and only lock while copying that in to the storage in the 'ar'?
I don't see why you would need special locks for reading target's memory. If there is something needed,
pci.cshould handle that. Michal?
I was concerned something might sleep, but I can do some testing with lockdep enabled and hopefully it will find any issues of that nature.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 11 lines · Ben Greear
Quoted 7 lines · Kalle Valo
Quoted 2 lines · Ben Greear
I did not do this because I figure we will want ethtool support w/out forcing debugfs to be enabled someday soon.
When we add ethtool support, it's easy to move these back. And then we need to move the code out from
debug.canyway.Well, it seems like needless churn and makes it harder to follow 'git blame' when you move big chunks around.
I don't care about 'git blame', the actual code is far more important to me. If git blame is so important, someone else can improve 'git blame' to detect moving code chunks.
Quoted 3 lines
We would not have to move the code out of
debug.c, but if you do want it moved, lets pick that place now and just put it there to begin with.
Code in debug.c should have the data it owns in struct ath10k_debug.
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.I think it has to be a spin-lock because the crash dump is gathered in the irq handler, so I can't use a mutex as far as I know...
I'll work on adding such a lock today.
I asked why add a _new_ spinlock as ar->data_lock is already a spinlock.
Signature · 1 line
Kalle Valo
Quoted 18 lines · Kalle Valo
Quoted 11 lines · Ben Greear
Quoted 7 lines · Kalle Valo
Quoted 2 lines · Ben Greear
I did not do this because I figure we will want ethtool support w/out forcing debugfs to be enabled someday soon.
When we add ethtool support, it's easy to move these back. And then we need to move the code out from
debug.canyway.Well, it seems like needless churn and makes it harder to follow 'git blame' when you move big chunks around.
I don't care about 'git blame', the actual code is far more important to me. If git blame is so important, someone else can improve 'git blame' to detect moving code chunks.
Quoted 5 lines
Quoted 3 lines
We would not have to move the code out of
debug.c, but if you do want it moved, lets pick that place now and just put it there to begin with.Code in
debug.cshould have the data it owns in structath10k_debug.
Ok, I'll move the data structs to the debug logic for next version of the patch.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.
Quoted 6 lines
Quoted 4 lines
I think it has to be a spin-lock because the crash dump is gathered in the irq handler, so I can't use a mutex as far as I know...
I'll work on adding such a lock today.
I asked why add a _new_ spinlock as
ar->data_lockis already a spinlock.
Surely we do not want to impede traffic flow just to dump debug info?
And, it is easier to review a specific spinlock rather than use one big global-ish lock and have to review every use of that lock for issues.
My -v2 had a new spinlock for this new debug data. I'll move it into the debug struct with the other new data fields for next version.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 9 lines · Ben Greear
Quoted 8 lines · Kalle Valo
Quoted 6 lines · Ben Greear
Quoted 5 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I think it has to be a spin-lock because the crash dump is gathered in the irq handler, so I can't use a mutex as far as I know...
I'll work on adding such a lock today.
I asked why add a _new_ spinlock as
ar->data_lockis already a spinlock.Surely we do not want to impede traffic flow just to dump debug info?
I don't see data_lock being used anywhere in hotpath, but of course I might have missed something. Anyway, if for optimisation reasons we need to introduce a new lock that should happen for a specific case in hot path. Handling firmware debug log events is not in that category.
Quoted 2 lines
And, it is easier to review a specific spinlock rather than use one big global-ish lock and have to review every use of that lock for issues.
Sure, it's easier for you to just add a new lock and then forget :) But not for me who would have to maintain 20 different locks for years to come. My view is that a new lock should be added on very exceptional cases and with good justifications.
Signature · 1 line
Kalle Valo
Quoted 25 lines · Kalle Valo
Quoted 9 lines · Ben Greear
Quoted 8 lines · Kalle Valo
Quoted 6 lines · Ben Greear
Quoted 5 lines
Quoted 2 lines
I'm a bit leery of adding spin-locks in the dump routine just for this, but I can add and use a new spin-lock if you prefer.
Why a new spinlock? I didn't review the locking requirements, but I would first check
ar->data_lockcan be used.Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I think it has to be a spin-lock because the crash dump is gathered in the irq handler, so I can't use a mutex as far as I know...
I'll work on adding such a lock today.
I asked why add a _new_ spinlock as
ar->data_lockis already a spinlock.Surely we do not want to impede traffic flow just to dump debug info?
I don't see
data_lockbeing used anywhere in hotpath, but of course I might have missed something. Anyway, if for optimisation reasons we need to introduce a new lock that should happen for a specific case in hot path. Handling firmware debug log events is not in that category.
Quoted 7 lines
Quoted 2 lines
And, it is easier to review a specific spinlock rather than use one big global-ish lock and have to review every use of that lock for issues.
Sure, it's easier for you to just add a new lock and then forget :) But not for me who would have to maintain 20 different locks for years to come. My view is that a new lock should be added on very exceptional cases and with good justifications.
I have the opposite opinion on what makes it easy to maintain locks, but I'll switch to the data-spinlock as you suggest.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 9 lines · [email protected] writes:
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.
Signed-off-by Ben Greear <[email protected]>
[...]
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 649
Quoted 3 lines
drivers/net/wireless/ath/ath10k/debug.c +3
-0+ dump_data->kernel_ver_code =LINUX_VERSION_CODE ; +strncpy (dump_data->kernel_ver,VERMAGIC_STRING , +sizeof (dump_data->kernel_ver) -1 );
Other thing nice to have here is the kernel timestamp in the kernel log "[123456.4321]". How difficult would it be to add that to the dump?
Signature · 1 line
Kalle Valo
Quoted 12 lines · Kalle Valo
Quoted 9 lines · [email protected] writes:
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.
Signed-off-by Ben Greear <[email protected]>
Quoted 8 lines
[...]
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 649
Quoted 3 lines
drivers/net/wireless/ath/ath10k/debug.c +3
-0+ dump_data->kernel_ver_code =LINUX_VERSION_CODE ; +strncpy (dump_data->kernel_ver,VERMAGIC_STRING , +sizeof (dump_data->kernel_ver) -1 );Other thing nice to have here is the kernel timestamp in the kernel log "[123456.4321]". How difficult would it be to add that to the dump?
It's easy to get the time-of-day, if that is what you mean.
I'll add that...
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 15 lines · Ben Greear
Quoted 14 lines · Kalle Valo
Quoted 9 lines · [email protected] writes:
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.
Signed-off-by Ben Greear <[email protected]>[...]
Quoted 8 lines
Quoted 6 lines
drivers/net/wireless/ath/ath10k/debug.c static const struct file_operations fops_chip_id = { · line 649
Quoted 3 lines
drivers/net/wireless/ath/ath10k/debug.c +3
-0+ dump_data->kernel_ver_code =LINUX_VERSION_CODE ; +strncpy (dump_data->kernel_ver,VERMAGIC_STRING , +sizeof (dump_data->kernel_ver) -1 );Other thing nice to have here is the kernel timestamp in the kernel log "[123456.4321]". How difficult would it be to add that to the dump?
It's easy to get the time-of-day, if that is what you mean.
That's actually seconds from boot, not wall time:
[ 0.000000] tsc: Fast TSC calibration using PIT [ 0.000000] tsc: Detected 2793.393 MHz processor [ 0.000004] Calibrating delay loop (skipped), value calculated using timer frequency.. 5586.78 BogoMIP S (lpj=27933930) [ 0.000009] pid_max: default: 32768 minimum: 301 [ 0.000016] ACPI: Core revision 20140214 [ 0.023399] ACPI: All ACPI Tables successfully acquired
There's function print_time() which prints the time and the timestamp apparently comes from local_clock().
Signature · 1 line
Kalle Valo
Quoted 9 lines · [email protected] writes:
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.
Signed-off-by Ben Greear <[email protected]>
Review part 2.
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 884
Quoted 9 lines
drivers/net/wireless/ath/ath10k/pci.c +5
-0@@ -875,6 +877,80 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar) reg_dump_values[i +2 ], reg_dump_values[i + 3]); +/* Dump the debug logs on the target */ + host_addr =host_interest_item_address (HI_ITEM (hi_dbglog_hdr)); +if (ath10k_pci_diag_read_mem (ar, host_addr, + ®_dump_area,sizeof (u32)) !=0 ) { +ath10k_warn ("failed to read hi_dbglog_hdr\n" );
Please print the error code.
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 889
Quoted 5 lines
drivers/net/wireless/ath/ath10k/pci.c +5
-0+ goto save_regs_and_restart; + } + +ath10k_err ("target register Debug Log Location: 0x%08X\n" , + reg_dump_area);
Is this needed? I think this more like debug log material than something we should report to the user.
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 894
Quoted 4 lines
drivers/net/wireless/ath/ath10k/pci.c +4
-0+ ret =ath10k_pci_diag_read_mem (ar, reg_dump_area, + &dbg_hdr,sizeof (dbg_hdr)); +if (ret !=0 ) { +ath10k_err ("failed to dump Debug Log Area\n" );
ath10k_warn("failed to dump debug log area: %d\n", ret);
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 899
Quoted 5 lines
drivers/net/wireless/ath/ath10k/pci.c +5
-0+ goto save_regs_and_restart; + } + +ath10k_err ("Debug Log Header, dbuf: 0x%x dropped: %i\n" , + dbg_hdr.dbuf, dbg_hdr.dropped);
ath10k_dbg()?
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 902
Quoted 3 lines
drivers/net/wireless/ath/ath10k/pci.c +3
-0+ dbufp = dbg_hdr.dbuf; + i =0 ; +while (dbufp) {
for (i = 0; dbufp > 0; i++)?
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 903
Quoted 1 line
drivers/net/wireless/ath/ath10k/pci.c +1
-0+struct ath10k_fw_dbglog_buf dbuf;
Please move to the beginning of the function.
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 909
Quoted 5 lines
drivers/net/wireless/ath/ath10k/pci.c +5
-0+ ret =ath10k_pci_diag_read_mem (ar, dbufp, + &dbuf,sizeof (dbuf)); +if (ret !=0 ) { +ath10k_err ("failed to read Debug Log Area: 0x%x\n" , + dbufp);
ath10k_warn("failed to read debug log area: %d\n");
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 916
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +7
-0+ goto save_regs_and_restart; + } + +/* We have a buffer of data */ +ath10k_err ("[%i] next: 0x%x buf: 0x%x sz: %i len: %i count: %i free: %i\n" , + i, dbuf.next, dbuf.buffer, dbuf.bufsize, dbuf.length, + dbuf.count, dbuf.free);
ath10k_dbg()?
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 917
Quoted 1 line
drivers/net/wireless/ath/ath10k/pci.c +1
-0+if (dbuf.buffer && dbuf.length) {
I would prefer inverse here to keep the indentation clean, something like:
if (dbuf.buffer == 0 || dbug.length == 0)
goto next;
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 918
Quoted 1 line
drivers/net/wireless/ath/ath10k/pci.c +1
-0+u8 *buffer =kmalloc (dbuf.length,GFP_ATOMIC );
Should we have a maximum for the length so that we don't allocate insane amounts of memory by accident?
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 920
Quoted 1 line
drivers/net/wireless/ath/ath10k/pci.c +1
-0+if (buffer) {
Again I would prefer the inverse:
if (!buf)
break;
I assume there's no sense continuing here if kmalloc fails and better just bail out.
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 926
Quoted 6 lines
drivers/net/wireless/ath/ath10k/pci.c +6
-0+ ret =ath10k_pci_diag_read_mem (ar, dbuf.buffer, + buffer, + dbuf.length); +if (ret !=0 ) { +ath10k_err ("failed to read Debug Log buffer: 0x%x\n" , + dbuf.buffer);
ath10k_warn("failed to read debug log buffer: %d\n", ret);
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 933
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +7
-0+kfree (buffer); + goto save_regs_and_restart; + } + +ath10k_dbg_save_fw_dbg_buffer (ar, buffer, + dbuf.length); +kfree (buffer);
Instead of doing atomic allocations multiple times in a loop, would it be better to allocate just one buffer before the loop and free it afterwards?
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 946
Quoted 13 lines
drivers/net/wireless/ath/ath10k/pci.c +13
-0+ } + } + dbufp = dbuf.next; +if (dbufp == dbg_hdr.dbuf) { +/* It is a circular buffer it seems, bail if next +* is head +*/ +break ; + } + i++; + }/* While we have a debug buffer to read */ + +save_regs_and_restart:
exit_save_regs:
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 951
Quoted 5 lines
drivers/net/wireless/ath/ath10k/pci.c +5
-0+if (!ar->crashed_since_read) { + ar->crashed_since_read = true; +memcpy (ar->reg_dump_values, reg_dump_values, +sizeof (ar->reg_dump_values)); + }
How is the locking handled in this function?
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 953
Quoted 1 line
drivers/net/wireless/ath/ath10k/pci.c +1
-0+do_restart:
exit:
Quoted 2 lines
drivers/net/wireless/ath/ath10k/pci.c +0
-0queue_work (ar->workqueue, &ar->restart_work); }
Signature · 1 line
Kalle Valo
Quoted 11 lines · Kalle Valo
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 933
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +7
-0+kfree (buffer); + goto save_regs_and_restart; + } + +ath10k_dbg_save_fw_dbg_buffer (ar, buffer, + dbuf.length); +kfree (buffer);Instead of doing atomic allocations multiple times in a loop, would it be better to allocate just one buffer before the loop and free it afterwards?
There is no hard guarantee that the buffer lengths are the same, so I think it needs to remain as is. Would rather not crap out because firmware suddenly got more clever...
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 14 lines · Ben Greear
Quoted 11 lines · Kalle Valo
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 933
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +7
-0+kfree (buffer); + goto save_regs_and_restart; + } + +ath10k_dbg_save_fw_dbg_buffer (ar, buffer, + dbuf.length); +kfree (buffer);Instead of doing atomic allocations multiple times in a loop, would it be better to allocate just one buffer before the loop and free it afterwards?
Quoted 3 lines
There is no hard guarantee that the buffer lengths are the same, so I think it needs to remain as is. Would rather not crap out because firmware suddenly got more clever...
This is related to my earlier comment about having a max len for the buffers. So why not come up with a sane max length, allocate once a temporary buffer of that length and use the same buffer in the loop?
Signature · 1 line
Kalle Valo
Quoted 16 lines · Kalle Valo
Quoted 14 lines · Ben Greear
Quoted 11 lines · Kalle Valo
drivers/net/wireless/ath/ath10k/pci.c static void ath10k_pci_hif_dump_area(struct ath10k *ar) · line 933
Quoted 7 lines
drivers/net/wireless/ath/ath10k/pci.c +7
-0+kfree (buffer); + goto save_regs_and_restart; + } + +ath10k_dbg_save_fw_dbg_buffer (ar, buffer, + dbuf.length); +kfree (buffer);Instead of doing atomic allocations multiple times in a loop, would it be better to allocate just one buffer before the loop and free it afterwards?
Quoted 7 lines
Quoted 3 lines
There is no hard guarantee that the buffer lengths are the same, so I think it needs to remain as is. Would rather not crap out because firmware suddenly got more clever...
This is related to my earlier comment about having a max len for the buffers. So why not come up with a sane max length, allocate once a temporary buffer of that length and use the same buffer in the loop?
I can fix it at a 4k chunk if you want. Current firmware uses around 2k chunk I believe, and only two buffers, so either way it's not a lot of work for CPU.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 8 lines · Ben Greear
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Instead of doing atomic allocations multiple times in a loop, would it be better to allocate just one buffer before the loop and free it afterwards?
There is no hard guarantee that the buffer lengths are the same, so I think it needs to remain as is. Would rather not crap out because firmware suddenly got more clever...
Quoted 6 lines
Quoted 3 lines
This is related to my earlier comment about having a max len for the buffers. So why not come up with a sane max length, allocate once a temporary buffer of that length and use the same buffer in the loop?
I can fix it at a 4k chunk if you want. Current firmware uses around 2k chunk I believe, and only two buffers, so either way it's not a lot of work for CPU.
I think we should have a max chunk size in ath10k anyway and using one buffer makes sense in that case.
Signature · 1 line
Kalle Valo