ASoC: Intel: avs: Allow for dumping FW_REGS area
authorCezary Rojewski <cezary.rojewski@intel.com>
Fri, 2 Dec 2022 15:28:40 +0000 (16:28 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 5 Dec 2022 14:05:32 +0000 (14:05 +0000)
SRAM0 window begins with a block of memory, usually of size PAGE_SIZE,
dedicated to the base firmware registers. When debugging firmware, it is
desirable to be able to dump them at will.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221202152841.672536-16-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/avs/debugfs.c

index e7b0b99..e9042d4 100644 (file)
@@ -48,6 +48,29 @@ void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsig
        wake_up(&adev->trace_waitq);
 }
 
+static ssize_t fw_regs_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
+{
+       struct avs_dev *adev = file->private_data;
+       char *buf;
+       int ret;
+
+       buf = kzalloc(AVS_FW_REGS_SIZE, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
+       memcpy_fromio(buf, avs_sram_addr(adev, AVS_FW_REGS_WINDOW), AVS_FW_REGS_SIZE);
+
+       ret = simple_read_from_buffer(to, count, ppos, buf, AVS_FW_REGS_SIZE);
+       kfree(buf);
+       return ret;
+}
+
+static const struct file_operations fw_regs_fops = {
+       .open = simple_open,
+       .read = fw_regs_read,
+       .llseek = no_llseek,
+};
+
 static ssize_t probe_points_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
 {
        struct avs_dev *adev = file->private_data;
@@ -369,6 +392,7 @@ void avs_debugfs_init(struct avs_dev *adev)
 
        debugfs_create_file("strace", 0444, adev->debugfs_root, adev, &strace_fops);
        debugfs_create_file("trace_control", 0644, adev->debugfs_root, adev, &trace_control_fops);
+       debugfs_create_file("fw_regs", 0444, adev->debugfs_root, adev, &fw_regs_fops);
 
        debugfs_create_u32("trace_aging_period", 0644, adev->debugfs_root,
                           &adev->aging_timer_period);