Skip to content

Commit

Permalink
ath10k: add firmware crash counters
Browse files Browse the repository at this point in the history
Add three counters related to firmware crashes or resets.

Usage:

# cat /sys/kernel/debug/ieee80211/phy0/ath10k/fw_reset_stats
fw_crash_counter                2
fw_warm_reset_counter           43
fw_cold_reset_counter           0
#

kvalo: split into it's own patch, add debugfs file and add locking

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  • Loading branch information
Ben Greear authored and Kalle Valo committed Oct 1, 2014
1 parent 5326849 commit f51dbe7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/net/wireless/ath/ath10k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,13 @@ struct ath10k {
bool utf_monitor;
} testmode;

struct {
/* protected by data_lock */
u32 fw_crash_counter;
u32 fw_warm_reset_counter;
u32 fw_cold_reset_counter;
} stats;

/* must be last */
u8 drv_priv[0] __aligned(sizeof(void *));
};
Expand Down
44 changes: 44 additions & 0 deletions drivers/net/wireless/ath/ath10k/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,47 @@ static const struct file_operations fops_fw_stats = {
.llseek = default_llseek,
};

static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
int ret, len, buf_len;
char *buf;

buf_len = 500;
buf = kmalloc(buf_len, GFP_KERNEL);
if (!buf)
return -ENOMEM;

spin_lock_bh(&ar->data_lock);

len = 0;
len += scnprintf(buf + len, buf_len - len,
"fw_crash_counter\t\t%d\n", ar->stats.fw_crash_counter);
len += scnprintf(buf + len, buf_len - len,
"fw_warm_reset_counter\t\t%d\n",
ar->stats.fw_warm_reset_counter);
len += scnprintf(buf + len, buf_len - len,
"fw_cold_reset_counter\t\t%d\n",
ar->stats.fw_cold_reset_counter);

spin_unlock_bh(&ar->data_lock);

ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);

kfree(buf);

return ret;
}

static const struct file_operations fops_fw_reset_stats = {
.open = simple_open,
.read = ath10k_debug_fw_reset_stats_read,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

/* This is a clean assert crash in firmware. */
static int ath10k_debug_fw_assert(struct ath10k *ar)
{
Expand Down Expand Up @@ -1331,6 +1372,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar,
&fops_fw_stats);

debugfs_create_file("fw_reset_stats", S_IRUSR, ar->debug.debugfs_phy,
ar, &fops_fw_reset_stats);

debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar,
&fops_wmi_services);

Expand Down
14 changes: 14 additions & 0 deletions drivers/net/wireless/ath/ath10k/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,8 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k *ar)

spin_lock_bh(&ar->data_lock);

ar->stats.fw_crash_counter++;

crash_data = ath10k_debug_get_new_fw_crash_data(ar);

if (crash_data)
Expand Down Expand Up @@ -1692,6 +1694,12 @@ static int ath10k_pci_warm_reset(struct ath10k *ar)

ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset\n");

spin_lock_bh(&ar->data_lock);

ar->stats.fw_warm_reset_counter++;

spin_unlock_bh(&ar->data_lock);

/* debug */
val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
PCIE_INTR_CAUSE_ADDRESS);
Expand Down Expand Up @@ -2308,6 +2316,12 @@ static int ath10k_pci_cold_reset(struct ath10k *ar)

ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cold reset\n");

spin_lock_bh(&ar->data_lock);

ar->stats.fw_cold_reset_counter++;

spin_unlock_bh(&ar->data_lock);

/* Put Target, including PCIe, into RESET. */
val = ath10k_pci_reg_read32(ar, SOC_GLOBAL_RESET_ADDRESS);
val |= 1;
Expand Down

0 comments on commit f51dbe7

Please sign in to comment.