Skip to content

Commit

Permalink
ath10k: Re-enable debugfs access to firmware crashdumps.
Browse files Browse the repository at this point in the history
DEV_COREDUMP is not enabled in OpenWrt, and I could not figure out
how to do so.  So, just re-enable ath10k ability to grab the crashdump
out of debugfs.  It is easier to find the dumps through debugfs anyway.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Oct 26, 2023
1 parent 5c9964a commit 0ef57d0
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/ath/ath10k/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ obj-$(CONFIG_ATH10K) += ath10k_core.o
ath10k_core-y += mac.o \
debug.o \
core.o \
coredump.o \
htc.o \
htt.o \
htt_rx.o \
Expand All @@ -21,7 +22,6 @@ ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o
ath10k_core-$(CONFIG_THERMAL) += thermal.o
ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o
ath10k_core-$(CONFIG_PM) += wow.o
ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
ath10k_core-$(CONFIG_ATH10K_CE) += ce.o

obj-$(CONFIG_ATH10K_PCI) += ath10k_pci.o
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/ath/ath10k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1541,9 +1541,10 @@ struct ath10k {

u32 pktlog_filter;

#ifdef CONFIG_DEV_COREDUMP
#if ((defined CONFIG_DEV_COREDUMP) || defined (CONFIG_ATH10K_DEBUGFS))
struct {
struct ath10k_fw_crash_data *fw_crash_data;
struct ath10k_dump_file_data* dump; /* for debugfs */
} coredump;
#endif

Expand Down
25 changes: 25 additions & 0 deletions drivers/net/wireless/ath/ath10k/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "debug.h"
#include "hw.h"

#if ((defined CONFIG_DEV_COREDUMP) || defined (CONFIG_ATH10K_DEBUGFS))

static const struct ath10k_mem_section qca6174_hw21_register_sections[] = {
{0x800, 0x810},
{0x820, 0x82C},
Expand Down Expand Up @@ -1691,7 +1693,23 @@ int ath10k_coredump_submit(struct ath10k *ar)
return -ENODATA;
}

#ifdef CONFIG_ATH10K_DEBUGFS
#ifdef CONFIG_DEV_COREDUMP
if (ar->coredump.dump)
vfree(ar->coredump.dump); /* guess nothing read the last one, clean it up. */
ar->coredump.dump = vzalloc(le32_to_cpu(dump->len)); /* second one for debugfs */
if (ar->coredump.dump) {
memcpy(ar->coredump.dump, dump, le32_to_cpu(dump->len));
}
#else
/* no coredump use what we have already allocated */
ar->coredump.dump = dump;
#endif
#endif

#ifdef CONFIG_DEV_COREDUMP
dev_coredumpv(ar->dev, dump, le32_to_cpu(dump->len), GFP_KERNEL);
#endif

return 0;
}
Expand Down Expand Up @@ -1732,6 +1750,7 @@ void ath10k_coredump_unregister(struct ath10k *ar)
struct ath10k_fw_crash_data *crash_data = ar->coredump.fw_crash_data;

vfree(crash_data->ramdump_buf);
crash_data->ramdump_buf = NULL;
}

void ath10k_coredump_destroy(struct ath10k *ar)
Expand All @@ -1744,4 +1763,10 @@ void ath10k_coredump_destroy(struct ath10k *ar)

vfree(ar->coredump.fw_crash_data);
ar->coredump.fw_crash_data = NULL;

vfree(ar->coredump.dump);
ar->coredump.dump = NULL;
}


#endif /* debugfs or coredump */
5 changes: 2 additions & 3 deletions drivers/net/wireless/ath/ath10k/coredump.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ struct ath10k_hw_mem_layout {
/* FIXME: where to put this? */
extern unsigned long ath10k_coredump_mask;

#ifdef CONFIG_DEV_COREDUMP

#if ((defined CONFIG_DEV_COREDUMP) || defined (CONFIG_ATH10K_DEBUGFS))
int ath10k_coredump_submit(struct ath10k *ar);
struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar);
int ath10k_coredump_create(struct ath10k *ar);
Expand All @@ -193,7 +192,7 @@ void ath10k_coredump_destroy(struct ath10k *ar);
const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout(struct ath10k *ar);
const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar);

#else /* CONFIG_DEV_COREDUMP */
#else /* CONFIG_DEV_COREDUMP || CONFIG_ATH10K_DEBUGFS */

static inline int ath10k_coredump_submit(struct ath10k *ar)
{
Expand Down
46 changes: 46 additions & 0 deletions drivers/net/wireless/ath/ath10k/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "hif.h"
#include "wmi-ops.h"
#include "mac.h"
#include "coredump.h"

/* ms */
#define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000
Expand Down Expand Up @@ -1774,6 +1775,48 @@ static const struct file_operations fops_chip_id = {
.llseek = default_llseek,
};

static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
{
struct ath10k *ar = inode->i_private;

/*ath10k_warn(ar, "fw_crash_dump debugfs file is deprecated, please use /sys/class/devcoredump instead."); */
if (ar->coredump.dump) {
file->private_data = ar->coredump.dump;
ar->coredump.dump = NULL; /* dump_release will free the mem */
return 0;
}
else {
return -ENODATA;
}
}

static ssize_t ath10k_fw_crash_dump_read(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k_dump_file_data *dump_file = file->private_data;

return simple_read_from_buffer(user_buf, count, ppos,
dump_file,
le32_to_cpu(dump_file->len));
}

static int ath10k_fw_crash_dump_release(struct inode *inode,
struct file *file)
{
vfree(file->private_data);

return 0;
}

static const struct file_operations fops_fw_crash_dump = {
.open = ath10k_fw_crash_dump_open,
.read = ath10k_fw_crash_dump_read,
.release = ath10k_fw_crash_dump_release,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

static ssize_t ath10k_reg_addr_read(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
Expand Down Expand Up @@ -4370,6 +4413,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("simulate_fw_crash", 0600, ar->debug.debugfs_phy, ar,
&fops_simulate_fw_crash);

debugfs_create_file("fw_crash_dump", 0400, ar->debug.debugfs_phy, ar,
&fops_fw_crash_dump);

debugfs_create_file("misc", 0400, ar->debug.debugfs_phy, ar,
&fops_misc);

Expand Down

0 comments on commit 0ef57d0

Please sign in to comment.