Skip to content

Conversation

@kv2019i
Copy link
Collaborator

@kv2019i kv2019i commented Aug 3, 2022

probe logging: add backend for logging via probes

Work in progress code that routes Zephyr logs via the logging
subsystem to SOF probe extraction point.

Lot of hardcodes still in this version, but this is tested to work
with Linux SOF driver, crecord and sof/tools/probes for decoding.

Example usage in Linux:

term1# crecord -c3 -d0 -b8192 -f4 -FS32_LE -R48000 -C4 /tmp/extract.dat
term2# echo 0,3,0 > /sys/kernel/debug/sof/probe_points
term1# <terminate crecord>
term1# sof-probes -p /tmp/extract.dat
term1# cat buffer_999999.wav

@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 3, 2022

FYI @teburd

@lgirdwood
Copy link
Member

@kv2019i we should be able to make this scriptable in sof-tools. We do need a separate demux tool though that can split pcm/log/trace data by slot into individual files.

@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 4, 2022

@lgirdwood wrote:

@kv2019i we should be able to make this scriptable in sof-tools. We do need a separate demux tool though that can split pcm/log/trace data by slot into individual files.

sof/tools/probes/probes_main.c is that demux tool, so we have that already.

We might need a more integrated tool. One developer requirement is to observe "live" logs from the FW and the current palette of tools forces to cut the logging to see any decoded logs. So potentially we need a more unified tool that combines probe point configuration, reading data from compress PCM and calling log decoders (e.g. the zephyr/mipi tool for syst catalog). In the end, developer wants to see live logs in human-readable format on her console. FYI @marc-hb @jsarha @pjdobrowolski

@lgirdwood
Copy link
Member

We might need a more integrated tool. One developer requirement is to observe "live" logs from the FW and the current palette of tools forces to cut the logging to see any decoded logs. So potentially we need a more unified tool that combines probe point configuration, reading data from compress PCM and calling log decoders (e.g. the zephyr/mipi tool for syst catalog). In the end, developer wants to see live logs in human-readable format on her console. FYI @marc-hb @jsarha @pjdobrowolski

ok, we can update the existing tool to strip the container for slot N and send it's stdout to log/trace tool stdin as a cmd line option.

@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch from 99994aa to 04c5fc4 Compare August 9, 2022 16:34
@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 9, 2022

V2 update:

  • fixed a few glaring bugs
  • some cleanup to code
  • renamed special buffer-id to 999999 (99 could be used in fairly typical topologies)

@kv2019i kv2019i requested a review from ujfalusi August 9, 2022 16:36
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@kv2019i what are the next steps now ?

@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 10, 2022

@lgirdwood wrote:

@kv2019i what are the next steps now ?

I'm close to complete an update that gets rid of the buffer-id overload, and simplifies the interface between logger and probe code. Thanks @ujfalusi for the feedback for the interface!

Originally I was thinking that I keep this as draft until @jsarha and @abonislawski have the IPC4 updates ready, and then we merge probes logging as a IPC4 only feature. But, but, the latest versions starts to be so clean, so maybe we start with a IPC3 probes logging imlementation first. This can be used to kick off user-space tool development and testing, and then when the IPC4 work is ready, we can add that on top. I'll push a new PR update today.

@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch from 04c5fc4 to f9556b7 Compare August 10, 2022 17:17
@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 10, 2022

V3 updated:

  • much cleaner implementation (direct hook callback, no need to go via comp_buffer, audio_stream and others)
  • small ABI change to add a new probe purpose type
  • open: the probe_dma_buf.avail field make the code a bit clumsy.. with audio probes this was not a problem as the probed data was nicely aligned with DMA minimum aligned transfer size, but with logs, the code becomes a bit messy... can be cleaned up
  • open: need to figure whether there is a good header/format to use for logging probe data... now setting format with zeros and our SOF probes decoder is happy with this
  • open: reliability issues -- occasional hits a Zephyr panic, needs more testing

@kv2019i kv2019i added the ABI ABI change involved label Aug 10, 2022
@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch from f9556b7 to 905a857 Compare August 10, 2022 17:27
@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch from 905a857 to 8770007 Compare August 11, 2022 14:54
@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 11, 2022

V4 update:

  • functionality now ready
  • interface changes ready, needs a slight update to the demux tool -> probe-app: add support for non-audio probe buffers #6130
  • adds a new Kconfig for the backend (only available in Zephyr builds)
  • fix XTOS SOF build
  • split generic probe_task() fixes to a separate commit
  • todo: cleanup related to "probe.purpose" checks (raised in review)
  • todo: double-check the logic to manage "avail checks" in probe_task()
  • todo: add probe logging to as a default for Intel platforms (at least), and disable dma-trace

@kv2019i kv2019i changed the title [RFC] probe logging: add backend for logging via probes probe: add backend for logging via probes Aug 11, 2022
@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch from 8770007 to 4276d25 Compare August 12, 2022 13:53
@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 12, 2022

V5 updated:

  • no longer draft, ready for review
  • tested with multiple log formats (text, dictionary, mipi -syst)
  • a few major bugfixes that caused the logging to end in FW panic
  • places for further cleanup:
    - the DMA buffer handling code is still a bit messy
    - the configurability via Kconfig is limited compared to upstream Zephyr logging backends
  • work needed with "crecord" tool (not related to this PR)
    - logs stay buffered in kernel for a long time
    - drain is apparently not working, so end of log stream is lost due to Linux kernel issue, possible related to [RFC]: Add support for drain operation on compress streams linux#3808

@kv2019i kv2019i marked this pull request as ready for review August 12, 2022 14:05
@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch from 4276d25 to 2d4450a Compare August 12, 2022 15:29
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

LGTM, and I see it picks up the buffer ID change from @lyakh PR too.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add TRACE here too (we can do in 1 ABI bump) as LOG and TRACE are different things in Zephyr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood I can add if it's ok to have it without matching implementation in this PR.

@jsarha
Copy link
Contributor

jsarha commented Aug 15, 2022

term1# crecord -c3 -d0 -b8192 -f4 -FS32_LE -R48000 -C4 /tmp/extract.dat
term2# echo 0,3,0 > /sys/kernel/debug/sof/probe_points
term1#
term1# sof-probes -p /tmp/extract.dat
term1# cat buffer_999999.wav

I wonder what I am missing. The echo steps does not produce an error and the probe point is there:
root@jhary:~# cat /sys/kernel/debug/sof/probe_points
Id: 0x00000000 Purpose: 3 Node id: 0x2

Still there is no data captured by crecord ("We read 8192, DSP sent 0" all the time), and obviously nothing when I try to extract the capture. I have this branch and "CONFIG_LOG_BACKEND_SOF_PROBE=y" in my confing in addition to old probes options (PCM probes work), should I need something more?

@kv2019i kv2019i force-pushed the topic/probeslogging-ipc3 branch 2 times, most recently from abcc223 to 2b0e74a Compare August 16, 2022 12:10
@kv2019i
Copy link
Collaborator Author

kv2019i commented Aug 16, 2022

V6 uploaded:

  • moved the backend code from sof/src/trace/ to sof/src/logging/
  • addressed comments by @lyakh and @lgirdwood

Modify probe task to support cases where the amount of available data is
not multiple of the DMA copy size, or wraps around in the DMA
buffer.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Implement a Zephyr logging backend which routes the logs via SOF
probes interface.

Tested with Linux SOF driver, crecord and sof/tools/probes for decoding.

The patch modifies the probes IPC3 interface, adding a new probe purpose
field (PROBE_PURPOSE_LOGGING, 0x3) to specify probe extraction for
logging. A field for system trace (as is also reserved (PROBE_PURPOSE_TRACING).

Example usage in Linux:

 term1# crecord -c3 -d0 -b8192 -f4 -FS32_LE -R48000 -C4 /tmp/extract.dat
 term2# echo 0,3,0 > /sys/kernel/debug/sof/probe_points
 term1# <terminate crecord>
 term1# sof-probes -p /tmp/extract.dat
 term1# cat buffer_0.bin

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@lgirdwood lgirdwood merged commit c3d1228 into thesofproject:main Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ABI ABI change involved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants