Skip to content

ASoC: SOF: Intel: IPC: add IPC counters - #955

Closed
jajanusz wants to merge 1 commit into
thesofproject:topic/sof-devfrom
jajanusz:ipc-debug
Closed

jajanusz wants to merge 1 commit into
thesofproject:topic/sof-devfrom
jajanusz:ipc-debug

Conversation

@jajanusz

@jajanusz jajanusz commented May 16, 2019 •

Copy link
Copy Markdown

Read IPC counters provided by firmware and log them on IPC timeout to help
debug.

Intended to work with thesofproject/sof#1441

Signed-off-by: Janusz Jankowski janusz.jankowski@linux.intel.com

Comment thread sound/soc/sof/intel/hda.h
@jajanusz
jajanusz force-pushed the ipc-debug branch 2 times, most recently from daa60ce to 7ab1736 Compare May 16, 2019 21:29
@jajanusz

Copy link
Copy Markdown
Author

I've decided to actually make PR of that, because we need to increase debug capabilities. Maybe it's not ultimate solution, but something we may start with.

The problem with this one is that it's too specific - it's literally for just proving that ipc handler on FW side did its job and didn't hand in ipc handler or irq. When we will want to debug other things we won't just add more registers in FW and then dump them in SW. It's not so practical.

Maybe we can add Kconfig option to dump whole window on error? This way when debugging FW we can add whatever we want in unused registers and we will be able to see them without changes in kernel code.
It's useful not only in cases like this one, but also for example on f.e. power-ons when you want to help integration teams, but they don't have enough knowledge to provide debug info - we can give them just modified FW and get logs for things that we cannot log with traces.

We should still consider traces as default logging/debugging - memwnd registers would be used for things that cannot use traces, f.e. before traces mechanism is even set up - for now we have only trace point, but sometimes it's not sufficient.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jajanusz, see below the comments, an update is needed to avoid polluting the SOF core with Hdaudio-specific stuff, otherwise it's a good fix to add.

Comment thread sound/soc/sof/ipc.c Outdated

dev_dbg(sdev->dev, "ipc received: %u processed: %u\n",
ipc_rec, ipc_proc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be dev_err()
Also it's only supported for HDaudio so the right place to add this log is in intel/hda.c (hda_ipc_dump)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you wrote that you want it on IPC timeout so I wanted to be it closer to ipc timeout message, but yea, it's not worth polluting ipc with hda for that, so i'll move it to hda.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart Moved it to hda_ipc_dump

Read IPC counters provided by firmware and log them on IPC timeout to help
debug.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was fast, thanks @jajanusz

@RanderWang RanderWang left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, hda_ipc_dump is only for apollolake, and the literal name is a little confusing.
please change cnl_ipc_dump also, this is for cannonlake, whiskylake, and icelake.

And would like me to help to check it on btytrail and broadwell ?

@keyonjie

Copy link
Copy Markdown

I've decided to actually make PR of that, because we need to increase debug capabilities. Maybe it's not ultimate solution, but something we may start with.

The problem with this one is that it's too specific - it's literally for just proving that ipc handler on FW side did its job and didn't hand in ipc handler or irq. When we will want to debug other things we won't just add more registers in FW and then dump them in SW. It's not so practical.

Maybe we can add Kconfig option to dump whole window on error? This way when debugging FW we can add whatever we want in unused registers and we will be able to see them without changes in kernel code.

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

It's useful not only in cases like this one, but also for example on f.e. power-ons when you want to help integration teams, but they don't have enough knowledge to provide debug info - we can give them just modified FW and get logs for things that we cannot log with traces.

We should still consider traces as default logging/debugging - memwnd registers would be used for things that cannot use traces, f.e. before traces mechanism is even set up - for now we have only trace point, but sometimes it's not sufficient.

@keyonjie keyonjie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objection about the code itself since it will be printed at error case only, though I think this could be unnecessary since we already had this in the node /sys/kernel/debug/sof/regs.

@jajanusz

Copy link
Copy Markdown
Author

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

But is it whole window (4kb?) or just few registers from the beginning? Also are there all memory windows or just first one?

@jajanusz

Copy link
Copy Markdown
Author

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

But is it whole window (4kb?) or just few registers from the beginning? Also are there all memory windows or just first one?

@keyonjie If I see correctly it's in ipc_get_windows and it's called only on fw_ready. We need something that will be dumped on error also, f.e. on ipc timeout.

@jajanusz

Copy link
Copy Markdown
Author

I've decided to actually make PR of that, because we need to increase debug capabilities. Maybe it's not ultimate solution, but something we may start with.
The problem with this one is that it's too specific - it's literally for just proving that ipc handler on FW side did its job and didn't hand in ipc handler or irq. When we will want to debug other things we won't just add more registers in FW and then dump them in SW. It's not so practical.
Maybe we can add Kconfig option to dump whole window on error? This way when debugging FW we can add whatever we want in unused registers and we will be able to see them without changes in kernel code.

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

It's useful not only in cases like this one, but also for example on f.e. power-ons when you want to help integration teams, but they don't have enough knowledge to provide debug info - we can give them just modified FW and get logs for things that we cannot log with traces.
We should still consider traces as default logging/debugging - memwnd registers would be used for things that cannot use traces, f.e. before traces mechanism is even set up - for now we have only trace point, but sometimes it's not sufficient.

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

But is it whole window (4kb?) or just few registers from the beginning? Also are there all memory windows or just first one?

@keyonjie If I see correctly it's in ipc_get_windows and it's called only on fw_ready. We need something that will be dumped on error also, f.e. on ipc timeout.

Also it looks empty with default settings. Do I need to enable something in Kconfig?

@xiulipan xiulipan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jajanusz
Please also do a similar patch to sound/soc/sof/intel/cnl.c for other cAVS platforms.

Comment thread sound/soc/sof/intel/hda.c
ipc_proc = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
HDA_DSP_SRAM_REG_FW_IPC_PROCESSED_COUNT);

dev_err(sdev->dev, "error: ipc received: %u processed: %u\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dev_err(sdev->dev, "error: ipc received: %u processed: %u\n",
dev_err(sdev->dev, "error: DSP ipc received: %u processed: %u\n",

Comment thread sound/soc/sof/intel/hda.c
dev_err(sdev->dev,
"error: host status 0x%8.8x dsp status 0x%8.8x mask 0x%8.8x\n",
hipcie, hipct, hipcctl);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jajanusz
Please add some inline comments to explain what is doing here.

@jajanusz

Copy link
Copy Markdown
Author

@xiulipan I'd like rather that some driver developer answer my questions that I asked first, because on them depends if it's really needed.

@xiulipan

Copy link
Copy Markdown

@jajanusz
What is your questions here?

Maybe we can add Kconfig option to dump whole window on error?

I only see this with question mark.

To answer this, this is called debugfs to us. And you can dump the hda and dsp debugfs file

/sys/kernel/debug/sof# ls
debug  dsp  etrace  exception  fw_version  hda  inbox  ipc_flood_count  ipc_flood_duration_ms  outbox  pp  regs  stream  trace

You can just read from this, they are always readable :)

And if you have some question for driver side feel free to ask and @ me. I will be glad to answer.

@jajanusz

Copy link
Copy Markdown
Author

@xiulipan I meant all questions that I asked @keyonjie
I'll ask them again:

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

But is it whole window (4kb?) or just few registers from the beginning? Also are there all memory windows or just first one?
If I see correctly it's in ipc_get_windows and it's called only on fw_ready. We need something that will be dumped on error also, f.e. on ipc timeout.
After test run it looks empty with default settings. Do I need to enable something in Kconfig?

@keyonjie

Copy link
Copy Markdown

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

But is it whole window (4kb?) or just few registers from the beginning? Also are there all memory windows or just first one?

It's 4KB(the size come from FW_READY), the whole memory window. You can read back the latest value of it at any time after FW_READY.

@keyonjie

keyonjie commented May 20, 2019 •

Copy link
Copy Markdown

@xiulipan I meant all questions that I asked @keyonjie
I'll ask them again:

We already had this, you can get the whole dump from the node /sys/kernel/debug/sof/regs.

But is it whole window (4kb?) or just few registers from the beginning? Also are there all memory windows or just first one?
If I see correctly it's in ipc_get_windows and it's called only on fw_ready. We need something that will be dumped on error also, f.e. on ipc timeout.
After test run it looks empty with default settings. Do I need to enable something in Kconfig?

No, you don't need enable anything in Kconfig, you can read back the latest value of it at any time after FW_READY:

test-Bobba:/root/# hexdump /sys/kernel/debug/sof/regs
0000000 0005 0000 d006 0dea 4000 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 0000 0000
*
0001000

@jajanusz

Copy link
Copy Markdown
Author

@plbossart @keyonjie Right, looks like we can use /sys/kernel/debug/sof/regs to get these values after FW_READY and AFAIK they are not needed before FW_READY, so we can drop this PR.

However we may still need some way to dump these values before FW_READY, for FW boot debugging. I don't know how kernel developers look at things like this, but maybe we can add some Kconfig option to dump registers on every error straight to the dmesg in case when error occurs before FW_READY.

@jajanusz jajanusz closed this May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants