diff mbox

[v2,4/4] ASoC: Intel: Skylake: Add support to read firmware registers

Message ID 20170629065604.30105-5-guneshwor.o.singh@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Guneshwor Singh June 29, 2017, 6:56 a.m. UTC
From: "Sodhi, VunnyX" <vunnyx.sodhi@intel.com>

This patch adds debugfs support to read fw registers, mailbox
offsets and sram address.

Signed-off-by: Mousumi Jana <mousumix.jana@intel.com>
Signed-off-by: Babu, Ramesh <ramesh.babu@intel.com>
Signed-off-by: B, Jayachandran <jayachandran.b@intel.com>
Signed-off-by: Kesapragada, Pardha Saradhi <pardha.saradhi.kesapragada@intel.com>
Signed-off-by: Sodhi, VunnyX <vunnyx.sodhi@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-debug.c | 59 +++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

Comments

kernel test robot July 2, 2017, 12:12 p.m. UTC | #1
Hi VunnyX,

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.12-rc7 next-20170630]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Guneshwor-Singh/Add-debugfs-support-for-skylake-driver/20170630-234553
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-ws0-07021539 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from sound/soc/intel/skylake/skl-debug.c:23:0:
>> sound/soc/intel/skylake/../common/sst-dsp-priv.h:63:42: warning: 'struct sst_pdata' declared inside parameter list [enabled by default]
     int (*init)(struct sst_dsp *sst, struct sst_pdata *pdata);
                                             ^
>> sound/soc/intel/skylake/../common/sst-dsp-priv.h:63:42: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]

vim +63 sound/soc/intel/skylake/../common/sst-dsp-priv.h

a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  47  	u32 (*read)(void __iomem *addr, u32 offset);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  48  	void (*write64)(void __iomem *addr, u32 offset, u64 value);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  49  	u64 (*read64)(void __iomem *addr, u32 offset);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  50  
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  51  	/* DSP I/DRAM IO */
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  52  	void (*ram_read)(struct sst_dsp *sst, void  *dest, void __iomem *src,
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  53  		size_t bytes);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  54  	void (*ram_write)(struct sst_dsp *sst, void __iomem *dest, void *src,
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  55  		size_t bytes);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  56  
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  57  	void (*dump)(struct sst_dsp *);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  58  
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  59  	/* IRQ handlers */
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  60  	irqreturn_t (*irq_handler)(int irq, void *context);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  61  
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  62  	/* SST init and free */
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12 @63  	int (*init)(struct sst_dsp *sst, struct sst_pdata *pdata);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  64  	void (*free)(struct sst_dsp *sst);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  65  
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  66  	/* FW module parser/loader */
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  67  	int (*parse_fw)(struct sst_fw *sst_fw);
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  68  };
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  69  
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  70  /*
a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  71   * Audio DSP memory offsets and addresses.

:::::: The code at line 63 was first introduced by commit
:::::: a4b12990b68079290ab62799035afe175b4bdc23 Merge remote-tracking branches 'asoc/topic/ml26124', 'asoc/topic/of', 'asoc/topic/omap', 'asoc/topic/pxa' and 'asoc/topic/rcar' into asoc-next

:::::: TO: Mark Brown <broonie@linaro.org>
:::::: CC: Mark Brown <broonie@linaro.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Vinod Koul July 3, 2017, 3:27 a.m. UTC | #2
On Sun, Jul 02, 2017 at 08:12:07PM +0800, kbuild test robot wrote:
> Hi VunnyX,
> 
> [auto build test WARNING on asoc/for-next]
> [also build test WARNING on v4.12-rc7 next-20170630]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Guneshwor-Singh/Add-debugfs-support-for-skylake-driver/20170630-234553
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
> config: x86_64-randconfig-ws0-07021539 (attached as .config)
> compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from sound/soc/intel/skylake/skl-debug.c:23:0:
> >> sound/soc/intel/skylake/../common/sst-dsp-priv.h:63:42: warning: 'struct sst_pdata' declared inside parameter list [enabled by default]
>      int (*init)(struct sst_dsp *sst, struct sst_pdata *pdata);
>                                              ^
> >> sound/soc/intel/skylake/../common/sst-dsp-priv.h:63:42: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]

this is due to missing define, so adding the right header should fix this
warning, will send a patch for this

Thanks for reporting

> 
> vim +63 sound/soc/intel/skylake/../common/sst-dsp-priv.h
> 
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  47  	u32 (*read)(void __iomem *addr, u32 offset);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  48  	void (*write64)(void __iomem *addr, u32 offset, u64 value);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  49  	u64 (*read64)(void __iomem *addr, u32 offset);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  50  
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  51  	/* DSP I/DRAM IO */
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  52  	void (*ram_read)(struct sst_dsp *sst, void  *dest, void __iomem *src,
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  53  		size_t bytes);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  54  	void (*ram_write)(struct sst_dsp *sst, void __iomem *dest, void *src,
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  55  		size_t bytes);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  56  
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  57  	void (*dump)(struct sst_dsp *);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  58  
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  59  	/* IRQ handlers */
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  60  	irqreturn_t (*irq_handler)(int irq, void *context);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  61  
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  62  	/* SST init and free */
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12 @63  	int (*init)(struct sst_dsp *sst, struct sst_pdata *pdata);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  64  	void (*free)(struct sst_dsp *sst);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  65  
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  66  	/* FW module parser/loader */
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  67  	int (*parse_fw)(struct sst_fw *sst_fw);
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  68  };
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  69  
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  70  /*
> a4b12990 sound/soc/intel/sst-dsp-priv.h Mark Brown 2014-03-12  71   * Audio DSP memory offsets and addresses.
> 
> :::::: The code at line 63 was first introduced by commit
> :::::: a4b12990b68079290ab62799035afe175b4bdc23 Merge remote-tracking branches 'asoc/topic/ml26124', 'asoc/topic/of', 'asoc/topic/omap', 'asoc/topic/pxa' and 'asoc/topic/rcar' into asoc-next
> 
> :::::: TO: Mark Brown <broonie@linaro.org>
> :::::: CC: Mark Brown <broonie@linaro.org>
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index 98d93f284af8..2650e04d4921 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -16,8 +16,15 @@ 
 #include <linux/pci.h>
 #include <linux/debugfs.h>
 #include "skl.h"
+#include "skl-sst-dsp.h"
+#include "skl-sst-ipc.h"
 #include "skl-tplg-interface.h"
 #include "skl-topology.h"
+#include "../common/sst-dsp-priv.h"
+
+#define MOD_BUF		PAGE_SIZE
+#define FW_REG_BUF	PAGE_SIZE
+#define FW_REG_SIZE	0x60
 
 #define MOD_BUF		PAGE_SIZE
 
@@ -27,6 +34,7 @@  struct skl_debug {
 
 	struct dentry *fs;
 	struct dentry *modules;
+	u8 fw_read_buff[FW_REG_BUF];
 };
 
 static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
@@ -169,6 +177,51 @@  void skl_debug_init_module(struct skl_debug *d,
 		dev_err(d->dev, "%s: module debugfs init failed\n", w->name);
 }
 
+static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
+			       size_t count, loff_t *ppos)
+{
+	struct skl_debug *d = file->private_data;
+	struct sst_dsp *sst = d->skl->skl_sst->dsp;
+	size_t w0_stat_sz = sst->addr.w0_stat_sz;
+	void __iomem *in_base = sst->mailbox.in_base;
+	void __iomem *fw_reg_addr;
+	unsigned int offset;
+	char *tmp;
+	ssize_t ret = 0;
+
+	tmp = kzalloc(FW_REG_BUF, GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
+
+	fw_reg_addr = in_base - w0_stat_sz;
+	memset(d->fw_read_buff, 0, FW_REG_BUF);
+
+	if (w0_stat_sz > 0)
+		__iowrite32_copy(d->fw_read_buff, fw_reg_addr, w0_stat_sz >> 2);
+
+	for (offset = 0; offset < FW_REG_SIZE; offset += 16) {
+		ret += snprintf(tmp + ret, FW_REG_BUF - ret, "%#.4x: ", offset);
+		hex_dump_to_buffer(d->fw_read_buff + offset, 16, 16, 4,
+				   tmp + ret, FW_REG_BUF - ret, 0);
+		ret += strlen(tmp + ret);
+
+		/* print newline for each offset */
+		if (FW_REG_BUF - ret > 0)
+			tmp[ret++] = '\n';
+	}
+
+	ret = simple_read_from_buffer(user_buf, count, ppos, tmp, ret);
+	kfree(tmp);
+
+	return ret;
+}
+
+static const struct file_operations soft_regs_ctrl_fops = {
+	.open = simple_open,
+	.read = fw_softreg_read,
+	.llseek = default_llseek,
+};
+
 struct skl_debug *skl_debugfs_init(struct skl *skl)
 {
 	struct skl_debug *d;
@@ -194,6 +247,12 @@  struct skl_debug *skl_debugfs_init(struct skl *skl)
 		goto err;
 	}
 
+	if (!debugfs_create_file("fw_soft_regs_rd", 0444, d->fs, d,
+				 &soft_regs_ctrl_fops)) {
+		dev_err(d->dev, "fw soft regs control debugfs init failed\n");
+		goto err;
+	}
+
 	return d;
 
 err: