[v2,2/2] ASoC: SOF: mediatek: add adsp debug dump

Message ID 20230523025933.30494-3-trevor.wu@mediatek.com
State New
Headers
Series ASoC: SOF: add mt8188 audio support |

Commit Message

Trevor Wu (吳文良) May 23, 2023, 2:59 a.m. UTC
  Add mt8188 and mt8186 .dbg_dump callback to print some information when
DSP panic occurs.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Yaochun Hung <yc.hung@mediatek.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/soc/sof/mediatek/mt8186/mt8186.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
  

Comments

Mark Brown May 30, 2023, 2:12 p.m. UTC | #1
On Tue, May 23, 2023 at 10:59:33AM +0800, Trevor Wu wrote:
> Add mt8188 and mt8186 .dbg_dump callback to print some information when
> DSP panic occurs.

This breaks an x86_64 allmodconfig build:

/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c: In function ‘mt8186_adsp_dump’:
/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:483:56: error: ‘DSP_PDEBUGDATA’ undeclared (first use in this function); did you mean ‘DSP_PDEBUGPC’?
  483 |         dbg_data = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGDATA);
      |                                                        ^~~~~~~~~~~~~~
      |                                                        DSP_PDEBUGPC
/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:483:56: note: each undeclared identifier is reported only once for each function it appears in
/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:484:56: error: ‘DSP_PDEBUGINST’ undeclared (first use in this function); did you mean ‘DSP_PDEBUGPC’?
  484 |         dbg_inst = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGINST);
      |                                                        ^~~~~~~~~~~~~~
      |                                                        DSP_PDEBUGPC
/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:485:59: error: ‘DSP_PDEBUGLS0STAT’ undeclared (first use in this function)
  485 |         dbg_ls0stat = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGLS0STAT);
      |                                                           ^~~~~~~~~~~~~~~~~
/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:486:58: error: ‘DSP_PDEBUGSTATUS’ undeclared (first use in this function); did you mean ‘DSP_PDEBUGPC’?
  486 |         dbg_status = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGSTATUS);
      |                                                          ^~~~~~~~~~~~~~~~
      |                                                          DSP_PDEBUGPC
/build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:487:57: error: ‘DSP_PFAULTINFO’ undeclared (first use in this function)
  487 |         faultinfo = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PFAULTINFO);
      |                                                         ^~~~~~~~~~~~~~
  
Trevor Wu (吳文良) June 1, 2023, 2:29 a.m. UTC | #2
On Tue, 2023-05-30 at 15:12 +0100, Mark Brown wrote:
> On Tue, May 23, 2023 at 10:59:33AM +0800, Trevor Wu wrote:
> > Add mt8188 and mt8186 .dbg_dump callback to print some information
> > when
> > DSP panic occurs.
> 
> This breaks an x86_64 allmodconfig build:
> 
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c: In
> function ‘mt8186_adsp_dump’:
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:483:56:
> error: ‘DSP_PDEBUGDATA’ undeclared (first use in this function); did
> you mean ‘DSP_PDEBUGPC’?
>   483 |         dbg_data = snd_sof_dsp_read(sdev, DSP_REG_BAR,
> DSP_PDEBUGDATA);
>       |                                                        ^~~~~~
> ~~~~~~~~
>       |                                                        DSP_PD
> EBUGPC
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:483:56:
> note: each undeclared identifier is reported only once for each
> function it appears in
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:484:56:
> error: ‘DSP_PDEBUGINST’ undeclared (first use in this function); did
> you mean ‘DSP_PDEBUGPC’?
>   484 |         dbg_inst = snd_sof_dsp_read(sdev, DSP_REG_BAR,
> DSP_PDEBUGINST);
>       |                                                        ^~~~~~
> ~~~~~~~~
>       |                                                        DSP_PD
> EBUGPC
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:485:59:
> error: ‘DSP_PDEBUGLS0STAT’ undeclared (first use in this function)
>   485 |         dbg_ls0stat = snd_sof_dsp_read(sdev, DSP_REG_BAR,
> DSP_PDEBUGLS0STAT);
>       |                                                           ^~~
> ~~~~~~~~~~~~~~
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:486:58:
> error: ‘DSP_PDEBUGSTATUS’ undeclared (first use in this function);
> did you mean ‘DSP_PDEBUGPC’?
>   486 |         dbg_status = snd_sof_dsp_read(sdev, DSP_REG_BAR,
> DSP_PDEBUGSTATUS);
>       |                                                          ^~~~
> ~~~~~~~~~~~~
>       |                                                          DSP_
> PDEBUGPC
> /build/stage/linux/sound/soc/sof/mediatek/mt8186/mt8186.c:487:57:
> error: ‘DSP_PFAULTINFO’ undeclared (first use in this function)
>   487 |         faultinfo = snd_sof_dsp_read(sdev, DSP_REG_BAR,
> DSP_PFAULTINFO);
>       |                                                         ^~~~~
> ~~~~~~~~~


Sorry, I didn't notice that I missed the header which possibly caused
by the wrong format-patch command. I checked the same patch in v1, and
the header was included in the series. I will send v3 to resolve the
problem.

Thanks,
Trevor
  

Patch

diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c
index cc91c2928fb6..3e0ea0e109e2 100644
--- a/sound/soc/sof/mediatek/mt8186/mt8186.c
+++ b/sound/soc/sof/mediatek/mt8186/mt8186.c
@@ -24,6 +24,7 @@ 
 #include "../../sof-of-dev.h"
 #include "../../sof-audio.h"
 #include "../adsp_helper.h"
+#include "../mtk-adsp-common.h"
 #include "mt8186.h"
 #include "mt8186-clk.h"
 
@@ -473,6 +474,26 @@  static snd_pcm_uframes_t mt8186_pcm_pointer(struct snd_sof_dev *sdev,
 	return pos;
 }
 
+static void mt8186_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
+{
+	u32 dbg_pc, dbg_data, dbg_inst, dbg_ls0stat, dbg_status, faultinfo;
+
+	/* dump debug registers */
+	dbg_pc = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGPC);
+	dbg_data = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGDATA);
+	dbg_inst = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGINST);
+	dbg_ls0stat = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGLS0STAT);
+	dbg_status = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PDEBUGSTATUS);
+	faultinfo = snd_sof_dsp_read(sdev, DSP_REG_BAR, DSP_PFAULTINFO);
+
+	dev_info(sdev->dev, "adsp dump : pc %#x, data %#x, dbg_inst %#x,",
+		 dbg_pc, dbg_data, dbg_inst);
+	dev_info(sdev->dev, "ls0stat %#x, status %#x, faultinfo %#x",
+		 dbg_ls0stat, dbg_status, faultinfo);
+
+	mtk_adsp_dump(sdev, flags);
+}
+
 static struct snd_soc_dai_driver mt8186_dai[] = {
 {
 	.name = "SOF_DL1",
@@ -555,6 +576,7 @@  static struct snd_sof_dsp_ops sof_mt8186_ops = {
 	.num_drv	= ARRAY_SIZE(mt8186_dai),
 
 	/* Debug information */
+	.dbg_dump = mt8186_adsp_dump,
 	.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
 
 	/* PM */