All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Add debugfs support for skylake driver
@ 2017-06-29 12:36 Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support Guneshwor Singh
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-29 12:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, liam.r.girdwood, Vinod Koul, Guneshwor Singh,
	Patches Audio

This series introduces debugfs support for skylake driver. It helps in
debugging by providing module configurations which is loaded from topology.

It also allows to read the firmware registers which are a part of SRAM
memory area accessible by host CPU through a memory window.

Changes in v3:
- Change debugfs parent from debugfs root to ASoC platform component

Changes in v2:
- Re-ordered patch and squashed platform changes

Guneshwor Singh (1):
  ASoC: Intel: Skylake: Add sram address to sst_addr structure

Sodhi, VunnyX (1):
  ASoC: Intel: Skylake: Add support to read firmware registers

Vinod Koul (2):
  ASoC: Intel: Skylake: Add debugfs support
  ASoC: Intel: Skylake: Debugfs facility to dump module config

 sound/soc/intel/common/sst-dsp-priv.h  |   4 +
 sound/soc/intel/skylake/Makefile       |   4 +
 sound/soc/intel/skylake/bxt-sst.c      |   4 +
 sound/soc/intel/skylake/skl-debug.c    | 268 +++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-pcm.c      |   6 +-
 sound/soc/intel/skylake/skl-sst.c      |   5 +
 sound/soc/intel/skylake/skl-topology.c |   3 +
 sound/soc/intel/skylake/skl.c          |   2 +
 sound/soc/intel/skylake/skl.h          |  26 ++++
 9 files changed, 321 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-debug.c

-- 
2.13.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support
  2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
@ 2017-06-29 12:36 ` Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 2/4] ASoC: Intel: Skylake: Debugfs facility to dump module config Guneshwor Singh
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-29 12:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, liam.r.girdwood,
	Vinod Koul, Vunny Sodhi

From: Vinod Koul <vinod.koul@intel.com>

For debug, the kernel debugfs mechanism is available. We can add various
debug options for driver like module configuration read, firmware register
read etc.

This patch adds debugfs as a child to asoc plaform component and caller is
added for skylake driver to do init and cleanup of debugfs.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Vunny Sodhi <vunnyx.sodhi@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/Makefile    |  4 +++
 sound/soc/intel/skylake/skl-debug.c | 55 +++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-pcm.c   |  6 +++-
 sound/soc/intel/skylake/skl.c       |  2 ++
 sound/soc/intel/skylake/skl.h       | 16 +++++++++++
 5 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-debug.c

diff --git a/sound/soc/intel/skylake/Makefile b/sound/soc/intel/skylake/Makefile
index 60fbc9bbe473..e7d77722d560 100644
--- a/sound/soc/intel/skylake/Makefile
+++ b/sound/soc/intel/skylake/Makefile
@@ -1,6 +1,10 @@
 snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \
 skl-topology.o
 
+ifdef CONFIG_DEBUG_FS
+  snd-soc-skl-objs += skl-debug.o
+endif
+
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
 # Skylake IPC Support
diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
new file mode 100644
index 000000000000..1de300ded4e3
--- /dev/null
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -0,0 +1,55 @@
+/*
+ *  skl-debug.c - Debugfs for skl driver
+ *
+ *  Copyright (C) 2016-17 Intel Corp
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ */
+
+#include <linux/pci.h>
+#include <linux/debugfs.h>
+#include "skl.h"
+
+struct skl_debug {
+	struct skl *skl;
+	struct device *dev;
+
+	struct dentry *fs;
+};
+
+struct skl_debug *skl_debugfs_init(struct skl *skl)
+{
+	struct skl_debug *d;
+
+	d = devm_kzalloc(&skl->pci->dev, sizeof(*d), GFP_KERNEL);
+	if (!d)
+		return NULL;
+
+	/* create the root dir first */
+	d->fs = debugfs_create_dir("dsp",
+				   skl->platform->component.debugfs_root);
+	if (IS_ERR(d->fs) || !d->fs) {
+		dev_err(&skl->pci->dev, "debugfs root creation failed\n");
+		return NULL;
+	}
+
+	d->skl = skl;
+	d->dev = &skl->pci->dev;
+
+	return d;
+}
+
+void skl_debugfs_exit(struct skl_debug *d)
+{
+	debugfs_remove_recursive(d->fs);
+
+	kfree(d);
+
+}
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index e91bbcffc856..0ebea34a4988 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1249,12 +1249,16 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform)
 
 	pm_runtime_get_sync(platform->dev);
 	if ((ebus_to_hbus(ebus))->ppcap) {
+		skl->platform = platform;
+
+		/* init debugfs */
+		skl->debugfs = skl_debugfs_init(skl);
+
 		ret = skl_tplg_init(platform, ebus);
 		if (ret < 0) {
 			dev_err(platform->dev, "Failed to init topology!\n");
 			return ret;
 		}
-		skl->platform = platform;
 
 		/* load the firmwares, since all is set */
 		ops = skl_get_dsp_ops(skl->pci->device);
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index e761550c6dad..410ce83f4a49 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -866,6 +866,8 @@ static void skl_remove(struct pci_dev *pci)
 	/* codec removal, invoke bus_device_remove */
 	snd_hdac_ext_bus_device_remove(ebus);
 
+	skl_debugfs_exit(skl->debugfs);
+	skl->debugfs = NULL;
 	skl_platform_unregister(&pci->dev);
 	skl_free_dsp(skl);
 	skl_machine_device_unregister(skl);
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 2a630fcb7f08..a47779c819d5 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -42,6 +42,8 @@ struct skl_dsp_resource {
 	u32 mem;
 };
 
+struct skl_debug;
+
 struct skl {
 	struct hdac_ext_bus ebus;
 	struct pci_dev *pci;
@@ -66,6 +68,8 @@ struct skl {
 	int supend_active;
 
 	struct work_struct probe_work;
+
+	struct skl_debug *debugfs;
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
@@ -116,4 +120,16 @@ void skl_update_d0i3c(struct device *dev, bool enable);
 int skl_nhlt_create_sysfs(struct skl *skl);
 void skl_nhlt_remove_sysfs(struct skl *skl);
 
+#ifdef CONFIG_DEBUG_FS
+struct skl_debug *skl_debugfs_init(struct skl *skl);
+void skl_debugfs_exit(struct skl_debug *d);
+#else
+static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
+{
+	return NULL;
+}
+static inline void skl_debugfs_exit(struct skl_debug *d)
+{}
+#endif
+
 #endif /* __SOUND_SOC_SKL_H */
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/4] ASoC: Intel: Skylake: Debugfs facility to dump module config
  2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support Guneshwor Singh
@ 2017-06-29 12:36 ` Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 3/4] ASoC: Intel: common: Add sram address to sst_addr structure Guneshwor Singh
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-29 12:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, liam.r.girdwood,
	Vinod Koul, Vunny Sodhi

From: Vinod Koul <vinod.koul@intel.com>

Driver modules have lot of information represented in struct
skl_module_cfg. Knowing this is useful for debug, so enable
debugfs for this structure.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Vunny Sodhi <vunnyx.sodhi@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-debug.c    | 156 +++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-topology.c |   3 +
 sound/soc/intel/skylake/skl.h          |  10 +++
 3 files changed, 169 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index 1de300ded4e3..42d58295051e 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -16,14 +16,159 @@
 #include <linux/pci.h>
 #include <linux/debugfs.h>
 #include "skl.h"
+#include "skl-tplg-interface.h"
+#include "skl-topology.h"
+
+#define MOD_BUF		PAGE_SIZE
 
 struct skl_debug {
 	struct skl *skl;
 	struct device *dev;
 
 	struct dentry *fs;
+	struct dentry *modules;
 };
 
+static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
+				int max_pin, ssize_t size, bool direction)
+{
+	int i;
+	ssize_t ret = 0;
+
+	for (i = 0; i < max_pin; i++)
+		ret += snprintf(buf + size, MOD_BUF - size,
+				"%s %d\n\tModule %d\n\tInstance %d\n\t"
+				"In-used %s\n\tType %s\n"
+				"\tState %d\n\tIndex %d\n",
+				direction ? "Input Pin:" : "Output Pin:",
+				i, m_pin[i].id.module_id,
+				m_pin[i].id.instance_id,
+				m_pin[i].in_use ? "Used" : "Unused",
+				m_pin[i].is_dynamic ? "Dynamic" : "Static",
+				m_pin[i].pin_state, i);
+	return ret;
+}
+
+static ssize_t skl_print_fmt(struct skl_module_fmt *fmt, char *buf,
+					ssize_t size, bool direction)
+{
+	return snprintf(buf + size, MOD_BUF - size,
+			"%s\n\tCh %d\n\tFreq %d\n\tBit depth %d\n\t"
+			"Valid bit depth %d\n\tCh config %#x\n\tInterleaving %d\n\t"
+			"Sample Type %d\n\tCh Map %#x\n",
+			direction ? "Input Format:" : "Output Format:",
+			fmt->channels, fmt->s_freq, fmt->bit_depth,
+			fmt->valid_bit_depth, fmt->ch_cfg,
+			fmt->interleaving_style, fmt->sample_type,
+			fmt->ch_map);
+}
+
+static ssize_t module_read(struct file *file, char __user *user_buf,
+			   size_t count, loff_t *ppos)
+{
+	struct skl_module_cfg *mconfig = file->private_data;
+	char *buf;
+	ssize_t ret;
+
+	buf = kzalloc(MOD_BUF, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	ret = snprintf(buf, MOD_BUF, "Module:\n\tUUID %pUL\n\tModule id %d\n"
+			"\tInstance id %d\n\tPvt_id %d\n", mconfig->guid,
+			mconfig->id.module_id, mconfig->id.instance_id,
+			mconfig->id.pvt_id);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"Resources:\n\tMCPS %#x\n\tIBS %#x\n\tOBS %#x\t\n",
+			mconfig->mcps, mconfig->ibs, mconfig->obs);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"Module data:\n\tCore %d\n\tIn queue %d\n\t"
+			"Out queue %d\n\tType %s\n",
+			mconfig->core_id, mconfig->max_in_queue,
+			mconfig->max_out_queue,
+			mconfig->is_loadable ? "loadable" : "inbuilt");
+
+	ret += skl_print_fmt(mconfig->in_fmt, buf, ret, true);
+	ret += skl_print_fmt(mconfig->out_fmt, buf, ret, false);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"Fixup:\n\tParams %#x\n\tConverter %#x\n",
+			mconfig->params_fixup, mconfig->converter);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"Module Gateway:\n\tType %#x\n\tVbus %#x\n\tHW conn %#x\n\tSlot %#x\n",
+			mconfig->dev_type, mconfig->vbus_id,
+			mconfig->hw_conn_type, mconfig->time_slot);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"Pipeline:\n\tID %d\n\tPriority %d\n\tConn Type %d\n\t"
+			"Pages %#x\n", mconfig->pipe->ppl_id,
+			mconfig->pipe->pipe_priority, mconfig->pipe->conn_type,
+			mconfig->pipe->memory_pages);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"\tParams:\n\t\tHost DMA %d\n\t\tLink DMA %d\n",
+			mconfig->pipe->p_params->host_dma_id,
+			mconfig->pipe->p_params->link_dma_id);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"\tPCM params:\n\t\tCh %d\n\t\tFreq %d\n\t\tFormat %d\n",
+			mconfig->pipe->p_params->ch,
+			mconfig->pipe->p_params->s_freq,
+			mconfig->pipe->p_params->s_fmt);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"\tLink %#x\n\tStream %#x\n",
+			mconfig->pipe->p_params->linktype,
+			mconfig->pipe->p_params->stream);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"\tState %d\n\tPassthru %s\n",
+			mconfig->pipe->state,
+			mconfig->pipe->passthru ? "true" : "false");
+
+	ret += skl_print_pins(mconfig->m_in_pin, buf,
+			mconfig->max_in_queue, ret, true);
+	ret += skl_print_pins(mconfig->m_out_pin, buf,
+			mconfig->max_out_queue, ret, false);
+
+	ret += snprintf(buf + ret, MOD_BUF - ret,
+			"Other:\n\tDomain %d\n\tHomogenous Input %s\n\t"
+			"Homogenous Output %s\n\tIn Queue Mask %d\n\t"
+			"Out Queue Mask %d\n\tDMA ID %d\n\tMem Pages %d\n\t"
+			"Module Type %d\n\tModule State %d\n",
+			mconfig->domain,
+			mconfig->homogenous_inputs ? "true" : "false",
+			mconfig->homogenous_outputs ? "true" : "false",
+			mconfig->in_queue_mask, mconfig->out_queue_mask,
+			mconfig->dma_id, mconfig->mem_pages, mconfig->m_state,
+			mconfig->m_type);
+
+	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+
+	kfree(buf);
+	return ret;
+}
+
+static const struct file_operations mcfg_fops = {
+	.open = simple_open,
+	.read = module_read,
+	.llseek = default_llseek,
+};
+
+
+void skl_debug_init_module(struct skl_debug *d,
+			struct snd_soc_dapm_widget *w,
+			struct skl_module_cfg *mconfig)
+{
+	if (!debugfs_create_file(w->name, 0444,
+				d->modules, mconfig,
+				&mcfg_fops))
+		dev_err(d->dev, "%s: module debugfs init failed\n", w->name);
+}
+
 struct skl_debug *skl_debugfs_init(struct skl *skl)
 {
 	struct skl_debug *d;
@@ -43,7 +188,18 @@ struct skl_debug *skl_debugfs_init(struct skl *skl)
 	d->skl = skl;
 	d->dev = &skl->pci->dev;
 
+	/* now create the module dir */
+	d->modules = debugfs_create_dir("modules", d->fs);
+	if (IS_ERR(d->modules) || !d->modules) {
+		dev_err(&skl->pci->dev, "modules debugfs create failed\n");
+		goto err;
+	}
+
 	return d;
+
+err:
+	debugfs_remove_recursive(d->fs);
+	return NULL;
 }
 
 void skl_debugfs_exit(struct skl_debug *d)
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 9569f118e97e..c02da16fdfd6 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -2472,6 +2472,9 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,
 	ret = skl_tplg_get_pvt_data(tplg_w, skl, bus->dev, mconfig);
 	if (ret < 0)
 		return ret;
+
+	skl_debug_init_module(skl->debugfs, w, mconfig);
+
 bind_event:
 	if (tplg_w->event_type == 0) {
 		dev_dbg(bus->dev, "ASoC: No event handler required\n");
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index a47779c819d5..14e7778d7f80 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -23,6 +23,7 @@
 
 #include <sound/hda_register.h>
 #include <sound/hdaudio_ext.h>
+#include <sound/soc.h>
 #include "skl-nhlt.h"
 
 #define SKL_SUSPEND_DELAY 2000
@@ -120,9 +121,14 @@ void skl_update_d0i3c(struct device *dev, bool enable);
 int skl_nhlt_create_sysfs(struct skl *skl);
 void skl_nhlt_remove_sysfs(struct skl *skl);
 
+struct skl_module_cfg;
+
 #ifdef CONFIG_DEBUG_FS
 struct skl_debug *skl_debugfs_init(struct skl *skl);
 void skl_debugfs_exit(struct skl_debug *d);
+void skl_debug_init_module(struct skl_debug *d,
+			struct snd_soc_dapm_widget *w,
+			struct skl_module_cfg *mconfig);
 #else
 static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
 {
@@ -130,6 +136,10 @@ static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
 }
 static inline void skl_debugfs_exit(struct skl_debug *d)
 {}
+static inline void skl_debug_init_module(struct skl_debug *d,
+					 struct snd_soc_dapm_widget *w,
+					 struct skl_module_cfg *mconfig)
+{}
 #endif
 
 #endif /* __SOUND_SOC_SKL_H */
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/4] ASoC: Intel: common: Add sram address to sst_addr structure
  2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 2/4] ASoC: Intel: Skylake: Debugfs facility to dump module config Guneshwor Singh
@ 2017-06-29 12:36 ` Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 3/4] ASoC: Intel: Skylake: " Guneshwor Singh
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-29 12:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, liam.r.girdwood, Vinod Koul, Guneshwor Singh,
	Patches Audio

SRAM address and memory window size differ for different platforms.
So add members to sst_addr structure and initialize them in the
respective dsp_init().

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/common/sst-dsp-priv.h | 4 ++++
 sound/soc/intel/skylake/bxt-sst.c     | 4 ++++
 sound/soc/intel/skylake/skl-sst.c     | 5 +++++
 3 files changed, 13 insertions(+)

diff --git a/sound/soc/intel/common/sst-dsp-priv.h b/sound/soc/intel/common/sst-dsp-priv.h
index d13c84364c3c..8734040d64d3 100644
--- a/sound/soc/intel/common/sst-dsp-priv.h
+++ b/sound/soc/intel/common/sst-dsp-priv.h
@@ -77,6 +77,10 @@ struct sst_addr {
 	u32 dram_offset;
 	u32 dsp_iram_offset;
 	u32 dsp_dram_offset;
+	u32 sram0_base;
+	u32 sram1_base;
+	u32 w0_stat_sz;
+	u32 w0_up_sz;
 	void __iomem *lpe;
 	void __iomem *shim;
 	void __iomem *pci_cfg;
diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c
index f5e7dbb1ba39..cf11b84888b9 100644
--- a/sound/soc/intel/skylake/bxt-sst.c
+++ b/sound/soc/intel/skylake/bxt-sst.c
@@ -573,6 +573,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 	sst->fw_ops = bxt_fw_ops;
 	sst->addr.lpe = mmio_base;
 	sst->addr.shim = mmio_base;
+	sst->addr.sram0_base = BXT_ADSP_SRAM0_BASE;
+	sst->addr.sram1_base = BXT_ADSP_SRAM1_BASE;
+	sst->addr.w0_stat_sz = SKL_ADSP_W0_STAT_SZ;
+	sst->addr.w0_up_sz = SKL_ADSP_W0_UP_SZ;
 
 	sst_dsp_mailbox_init(sst, (BXT_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),
 			SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 155e456b7a3a..aba9ea11ac74 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -553,6 +553,11 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 	sst = skl->dsp;
 	sst->addr.lpe = mmio_base;
 	sst->addr.shim = mmio_base;
+	sst->addr.sram0_base = SKL_ADSP_SRAM0_BASE;
+	sst->addr.sram1_base = SKL_ADSP_SRAM1_BASE;
+	sst->addr.w0_stat_sz = SKL_ADSP_W0_STAT_SZ;
+	sst->addr.w0_up_sz = SKL_ADSP_W0_UP_SZ;
+
 	sst_dsp_mailbox_init(sst, (SKL_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),
 			SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/4] ASoC: Intel: Skylake: Add sram address to sst_addr structure
  2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
                   ` (2 preceding siblings ...)
  2017-06-29 12:36 ` [PATCH v3 3/4] ASoC: Intel: common: Add sram address to sst_addr structure Guneshwor Singh
@ 2017-06-29 12:36 ` Guneshwor Singh
  2017-06-29 12:36 ` [PATCH v3 4/4] ASoC: Intel: Skylake: Add support to read firmware registers Guneshwor Singh
  2017-06-29 12:54 ` [PATCH v3 0/4] Add debugfs support for skylake driver Singh, Guneshwor
  5 siblings, 0 replies; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-29 12:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, liam.r.girdwood, Vinod Koul, Guneshwor Singh,
	Patches Audio

SRAM address and memory window size differ for different platforms.
So add members to sst_addr structure and initialize them in the
respective dsp_init().

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/common/sst-dsp-priv.h | 4 ++++
 sound/soc/intel/skylake/bxt-sst.c     | 4 ++++
 sound/soc/intel/skylake/skl-sst.c     | 5 +++++
 3 files changed, 13 insertions(+)

diff --git a/sound/soc/intel/common/sst-dsp-priv.h b/sound/soc/intel/common/sst-dsp-priv.h
index d13c84364c3c..8734040d64d3 100644
--- a/sound/soc/intel/common/sst-dsp-priv.h
+++ b/sound/soc/intel/common/sst-dsp-priv.h
@@ -77,6 +77,10 @@ struct sst_addr {
 	u32 dram_offset;
 	u32 dsp_iram_offset;
 	u32 dsp_dram_offset;
+	u32 sram0_base;
+	u32 sram1_base;
+	u32 w0_stat_sz;
+	u32 w0_up_sz;
 	void __iomem *lpe;
 	void __iomem *shim;
 	void __iomem *pci_cfg;
diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c
index f5e7dbb1ba39..cf11b84888b9 100644
--- a/sound/soc/intel/skylake/bxt-sst.c
+++ b/sound/soc/intel/skylake/bxt-sst.c
@@ -573,6 +573,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 	sst->fw_ops = bxt_fw_ops;
 	sst->addr.lpe = mmio_base;
 	sst->addr.shim = mmio_base;
+	sst->addr.sram0_base = BXT_ADSP_SRAM0_BASE;
+	sst->addr.sram1_base = BXT_ADSP_SRAM1_BASE;
+	sst->addr.w0_stat_sz = SKL_ADSP_W0_STAT_SZ;
+	sst->addr.w0_up_sz = SKL_ADSP_W0_UP_SZ;
 
 	sst_dsp_mailbox_init(sst, (BXT_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),
 			SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 155e456b7a3a..aba9ea11ac74 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -553,6 +553,11 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 	sst = skl->dsp;
 	sst->addr.lpe = mmio_base;
 	sst->addr.shim = mmio_base;
+	sst->addr.sram0_base = SKL_ADSP_SRAM0_BASE;
+	sst->addr.sram1_base = SKL_ADSP_SRAM1_BASE;
+	sst->addr.w0_stat_sz = SKL_ADSP_W0_STAT_SZ;
+	sst->addr.w0_up_sz = SKL_ADSP_W0_UP_SZ;
+
 	sst_dsp_mailbox_init(sst, (SKL_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),
 			SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/4] ASoC: Intel: Skylake: Add support to read firmware registers
  2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
                   ` (3 preceding siblings ...)
  2017-06-29 12:36 ` [PATCH v3 3/4] ASoC: Intel: Skylake: " Guneshwor Singh
@ 2017-06-29 12:36 ` Guneshwor Singh
  2017-06-30 12:29   ` Applied "ASoC: Intel: Skylake: Add support to read firmware registers" to the asoc tree Mark Brown
  2017-06-29 12:54 ` [PATCH v3 0/4] Add debugfs support for skylake driver Singh, Guneshwor
  5 siblings, 1 reply; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-29 12:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Sodhi, Patches Audio, Babu, Takashi Iwai, Pardha Saradhi,
	Jayachandran, Guneshwor Singh, Ramesh, Mousumi Jana,
	liam.r.girdwood, Vinod Koul, Kesapragada, Sodhi, VunnyX, B

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 | 57 +++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index 42d58295051e..4d2f77f6f5dd 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -16,10 +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
 
 struct skl_debug {
 	struct skl *skl;
@@ -27,6 +32,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 +175,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;
@@ -195,6 +246,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:
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 0/4] Add debugfs support for skylake driver
  2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
                   ` (4 preceding siblings ...)
  2017-06-29 12:36 ` [PATCH v3 4/4] ASoC: Intel: Skylake: Add support to read firmware registers Guneshwor Singh
@ 2017-06-29 12:54 ` Singh, Guneshwor
  5 siblings, 0 replies; 9+ messages in thread
From: Singh, Guneshwor @ 2017-06-29 12:54 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, liam.r.girdwood, Vinod Koul, Patches Audio

On Thu, Jun 29, 2017 at 06:06:03PM +0530, Guneshwor Singh wrote:
> This series introduces debugfs support for skylake driver. It helps in
> debugging by providing module configurations which is loaded from topology.
> 
> It also allows to read the firmware registers which are a part of SRAM
> memory area accessible by host CPU through a memory window.
> 

Please ignore this, it was sent by mistake.

> Changes in v3:
> - Change debugfs parent from debugfs root to ASoC platform component
> 
> Changes in v2:
> - Re-ordered patch and squashed platform changes
> 
> Guneshwor Singh (1):
>   ASoC: Intel: Skylake: Add sram address to sst_addr structure
> 
> Sodhi, VunnyX (1):
>   ASoC: Intel: Skylake: Add support to read firmware registers
> 
> Vinod Koul (2):
>   ASoC: Intel: Skylake: Add debugfs support
>   ASoC: Intel: Skylake: Debugfs facility to dump module config
> 
>  sound/soc/intel/common/sst-dsp-priv.h  |   4 +
>  sound/soc/intel/skylake/Makefile       |   4 +
>  sound/soc/intel/skylake/bxt-sst.c      |   4 +
>  sound/soc/intel/skylake/skl-debug.c    | 268 +++++++++++++++++++++++++++++++++
>  sound/soc/intel/skylake/skl-pcm.c      |   6 +-
>  sound/soc/intel/skylake/skl-sst.c      |   5 +
>  sound/soc/intel/skylake/skl-topology.c |   3 +
>  sound/soc/intel/skylake/skl.c          |   2 +
>  sound/soc/intel/skylake/skl.h          |  26 ++++
>  9 files changed, 321 insertions(+), 1 deletion(-)
>  create mode 100644 sound/soc/intel/skylake/skl-debug.c
> 
> -- 
> 2.13.0
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Applied "ASoC: Intel: Skylake: Add support to read firmware registers" to the asoc tree
  2017-06-29 12:36 ` [PATCH v3 4/4] ASoC: Intel: Skylake: Add support to read firmware registers Guneshwor Singh
@ 2017-06-30 12:29   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2017-06-30 12:29 UTC (permalink / raw)
  Cc: Sodhi, alsa-devel, B, Babu, Patches Audio, Pardha Saradhi,
	Jayachandran, Guneshwor Singh, Ramesh, Mousumi Jana,
	liam.r.girdwood, Takashi Iwai, Mark Brown, Kesapragada, Sodhi, ,
	VunnyX, Vinod Koul

The patch

   ASoC: Intel: Skylake: Add support to read firmware registers

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From bdd0384a5ada8bb5745e5f29c10a5ba88827efad Mon Sep 17 00:00:00 2001
From: Vunny Sodhi <vunnyx.sodhi@intel.com>
Date: Fri, 30 Jun 2017 09:06:08 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Add support to read firmware registers

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: Ramesh Babu <ramesh.babu@intel.com>
Signed-off-by: Jayachandran B <jayachandran.b@intel.com>
Signed-off-by: Pardha Saradhi K <pardha.saradhi.kesapragada@intel.com>
Signed-off-by: Vunny Sodhi <vunnyx.sodhi@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-debug.c | 57 +++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index be3238c63200..75497b1fda45 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -16,10 +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
 
 struct skl_debug {
 	struct skl *skl;
@@ -27,6 +32,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 +175,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;
@@ -195,6 +246,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:
-- 
2.13.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support
  2017-06-30  3:36 [PATCH v3 0/4] " Guneshwor Singh
@ 2017-06-30  3:36 ` Guneshwor Singh
  0 siblings, 0 replies; 9+ messages in thread
From: Guneshwor Singh @ 2017-06-30  3:36 UTC (permalink / raw)
  To: alsa-devel, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, liam.r.girdwood,
	Vinod Koul, Vunny Sodhi

From: Vinod Koul <vinod.koul@intel.com>

For debug, the kernel debugfs mechanism is available. We can add various
debug options for driver like module configuration read, firmware register
read etc.

This patch adds debugfs as a child to asoc plaform component and caller is
added for skylake driver to do init and cleanup of debugfs.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Vunny Sodhi <vunnyx.sodhi@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/Makefile    |  4 +++
 sound/soc/intel/skylake/skl-debug.c | 55 +++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-pcm.c   |  6 +++-
 sound/soc/intel/skylake/skl.c       |  2 ++
 sound/soc/intel/skylake/skl.h       | 16 +++++++++++
 5 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-debug.c

diff --git a/sound/soc/intel/skylake/Makefile b/sound/soc/intel/skylake/Makefile
index 60fbc9bbe473..e7d77722d560 100644
--- a/sound/soc/intel/skylake/Makefile
+++ b/sound/soc/intel/skylake/Makefile
@@ -1,6 +1,10 @@
 snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \
 skl-topology.o
 
+ifdef CONFIG_DEBUG_FS
+  snd-soc-skl-objs += skl-debug.o
+endif
+
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
 # Skylake IPC Support
diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
new file mode 100644
index 000000000000..6bc4565773c5
--- /dev/null
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -0,0 +1,55 @@
+/*
+ *  skl-debug.c - Debugfs for skl driver
+ *
+ *  Copyright (C) 2016-17 Intel Corp
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ */
+
+#include <linux/pci.h>
+#include <linux/debugfs.h>
+#include "skl.h"
+
+struct skl_debug {
+	struct skl *skl;
+	struct device *dev;
+
+	struct dentry *fs;
+};
+
+struct skl_debug *skl_debugfs_init(struct skl *skl)
+{
+	struct skl_debug *d;
+
+	d = devm_kzalloc(&skl->pci->dev, sizeof(*d), GFP_KERNEL);
+	if (!d)
+		return NULL;
+
+	/* create the debugfs dir with platform component's debugfs as parent */
+	d->fs = debugfs_create_dir("dsp",
+				   skl->platform->component.debugfs_root);
+	if (IS_ERR(d->fs) || !d->fs) {
+		dev_err(&skl->pci->dev, "debugfs root creation failed\n");
+		return NULL;
+	}
+
+	d->skl = skl;
+	d->dev = &skl->pci->dev;
+
+	return d;
+}
+
+void skl_debugfs_exit(struct skl_debug *d)
+{
+	debugfs_remove_recursive(d->fs);
+
+	kfree(d);
+
+}
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index e91bbcffc856..0ebea34a4988 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1249,12 +1249,16 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform)
 
 	pm_runtime_get_sync(platform->dev);
 	if ((ebus_to_hbus(ebus))->ppcap) {
+		skl->platform = platform;
+
+		/* init debugfs */
+		skl->debugfs = skl_debugfs_init(skl);
+
 		ret = skl_tplg_init(platform, ebus);
 		if (ret < 0) {
 			dev_err(platform->dev, "Failed to init topology!\n");
 			return ret;
 		}
-		skl->platform = platform;
 
 		/* load the firmwares, since all is set */
 		ops = skl_get_dsp_ops(skl->pci->device);
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index e761550c6dad..410ce83f4a49 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -866,6 +866,8 @@ static void skl_remove(struct pci_dev *pci)
 	/* codec removal, invoke bus_device_remove */
 	snd_hdac_ext_bus_device_remove(ebus);
 
+	skl_debugfs_exit(skl->debugfs);
+	skl->debugfs = NULL;
 	skl_platform_unregister(&pci->dev);
 	skl_free_dsp(skl);
 	skl_machine_device_unregister(skl);
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 2a630fcb7f08..a47779c819d5 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -42,6 +42,8 @@ struct skl_dsp_resource {
 	u32 mem;
 };
 
+struct skl_debug;
+
 struct skl {
 	struct hdac_ext_bus ebus;
 	struct pci_dev *pci;
@@ -66,6 +68,8 @@ struct skl {
 	int supend_active;
 
 	struct work_struct probe_work;
+
+	struct skl_debug *debugfs;
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
@@ -116,4 +120,16 @@ void skl_update_d0i3c(struct device *dev, bool enable);
 int skl_nhlt_create_sysfs(struct skl *skl);
 void skl_nhlt_remove_sysfs(struct skl *skl);
 
+#ifdef CONFIG_DEBUG_FS
+struct skl_debug *skl_debugfs_init(struct skl *skl);
+void skl_debugfs_exit(struct skl_debug *d);
+#else
+static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
+{
+	return NULL;
+}
+static inline void skl_debugfs_exit(struct skl_debug *d)
+{}
+#endif
+
 #endif /* __SOUND_SOC_SKL_H */
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-06-30 12:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 12:36 [PATCH v3 0/4] Add debugfs support for skylake driver Guneshwor Singh
2017-06-29 12:36 ` [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support Guneshwor Singh
2017-06-29 12:36 ` [PATCH v3 2/4] ASoC: Intel: Skylake: Debugfs facility to dump module config Guneshwor Singh
2017-06-29 12:36 ` [PATCH v3 3/4] ASoC: Intel: common: Add sram address to sst_addr structure Guneshwor Singh
2017-06-29 12:36 ` [PATCH v3 3/4] ASoC: Intel: Skylake: " Guneshwor Singh
2017-06-29 12:36 ` [PATCH v3 4/4] ASoC: Intel: Skylake: Add support to read firmware registers Guneshwor Singh
2017-06-30 12:29   ` Applied "ASoC: Intel: Skylake: Add support to read firmware registers" to the asoc tree Mark Brown
2017-06-29 12:54 ` [PATCH v3 0/4] Add debugfs support for skylake driver Singh, Guneshwor
2017-06-30  3:36 [PATCH v3 0/4] " Guneshwor Singh
2017-06-30  3:36 ` [PATCH v3 1/4] ASoC: Intel: Skylake: Add debugfs support Guneshwor Singh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.