Skip to content

Commit 85ac9c8

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: avs: Allow for dumping debug window snapshot
Add new read-only debugfs entry which dumps entire content of the SRAM window 2 i.e.: the debug window. Signed-off-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 870f6e5 commit 85ac9c8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

sound/soc/intel/avs/debugfs.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,31 @@ static const struct file_operations fw_regs_fops = {
7171
.llseek = no_llseek,
7272
};
7373

74+
static ssize_t debug_window_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
75+
{
76+
struct avs_dev *adev = file->private_data;
77+
size_t size;
78+
char *buf;
79+
int ret;
80+
81+
size = adev->hw_cfg.dsp_cores * AVS_WINDOW_CHUNK_SIZE;
82+
buf = kzalloc(size, GFP_KERNEL);
83+
if (!buf)
84+
return -ENOMEM;
85+
86+
memcpy_fromio(buf, avs_sram_addr(adev, AVS_DEBUG_WINDOW), size);
87+
88+
ret = simple_read_from_buffer(to, count, ppos, buf, size);
89+
kfree(buf);
90+
return ret;
91+
}
92+
93+
static const struct file_operations debug_window_fops = {
94+
.open = simple_open,
95+
.read = debug_window_read,
96+
.llseek = no_llseek,
97+
};
98+
7499
static ssize_t probe_points_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
75100
{
76101
struct avs_dev *adev = file->private_data;
@@ -393,6 +418,7 @@ void avs_debugfs_init(struct avs_dev *adev)
393418
debugfs_create_file("strace", 0444, adev->debugfs_root, adev, &strace_fops);
394419
debugfs_create_file("trace_control", 0644, adev->debugfs_root, adev, &trace_control_fops);
395420
debugfs_create_file("fw_regs", 0444, adev->debugfs_root, adev, &fw_regs_fops);
421+
debugfs_create_file("debug_window", 0444, adev->debugfs_root, adev, &debug_window_fops);
396422

397423
debugfs_create_u32("trace_aging_period", 0644, adev->debugfs_root,
398424
&adev->aging_timer_period);

sound/soc/intel/avs/registers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
#define AVS_FW_REG_STATUS(adev) (AVS_FW_REG_BASE(adev) + 0x0)
6060
#define AVS_FW_REG_ERROR_CODE(adev) (AVS_FW_REG_BASE(adev) + 0x4)
6161

62-
#define AVS_FW_REGS_SIZE PAGE_SIZE
62+
#define AVS_WINDOW_CHUNK_SIZE PAGE_SIZE
63+
#define AVS_FW_REGS_SIZE AVS_WINDOW_CHUNK_SIZE
6364
#define AVS_FW_REGS_WINDOW 0
6465
/* DSP -> HOST communication window */
6566
#define AVS_UPLINK_WINDOW AVS_FW_REGS_WINDOW

0 commit comments

Comments
 (0)