Skip to content

ASoC: sof: imx: add SOF probes extraction client (IPC3) - #6013

Open
ursus161 wants to merge 3 commits into
thesofproject:topic/sof-devfrom
ursus161:sof-probes-imx
Open

ursus161 wants to merge 3 commits into
thesofproject:topic/sof-devfrom
ursus161:sof-probes-imx

Conversation

@ursus161

@ursus161 ursus161 commented Nov 3, 2026 •

Copy link
Copy Markdown

SND_SOC_SOF_DEBUG_PROBES was not selectable for i.MX and no auxiliary probes client device was registered.

Add a hidden Kconfig symbol SND_SOC_SOF_IMX_PROBES, a new imx-probes.c that registers the client, allocates a coherent DMA buffer and passes its bus address to the firmware in PROBE_INIT stream_tag. A 10 ms delayed work polls the DSP write counter, copies new data into the compress buffer and calls snd_compr_fragment_elapsed().

Known limits: polling only, single stream, 32-bit DMA address.

@sofci

sofci commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@ursus161

ursus161 commented Nov 3, 2026

Copy link
Copy Markdown
Author

Hi all,

Tested this on a imx8mp-evk : 1kHz tone at 48 kHz stereo, captured via probes, decodes fine.

I am not so sure about these, please provide feedback :

  1. The address handoff : extractor_stream_tag = (u32)s->paddr in imx_probes_compr_set_params() . Would a dedicated field in the probe init payload be better?
  2. About static struct imx_probes_stream imx_stream; : Every callback reads and writes that same object. That works for one recording at a time. It may break if someone opens a second recording or reloads the module, because the old state isn't tied to the stream that created it. The fix is to store the state per stream, the way the HDA client does, so each recording owns its own copy and frees it on shutdown. Would it work better?
  3. 10ms polling timer schedule_delayed_work(&s->work, msecs_to_jiffies(IMX_PROBES_POLL_MS)); . Should I change this into a notification path?

Happy to change commit these changes.

@dbaluta @plbossart @plbossart @bardliao @sofci

Copilot AI 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.

🟡 Changes recommended

Uninitialized work cancellation and concurrent opens can trigger kernel panics or free an active DMA buffer, while incorrect buffer and restart accounting can expose stale or corrupted audio data.

5 open issues
What changed in this PR

Adds an IPC3 probe-extraction client for i.MX8, connecting the platform to the existing SOF probes infrastructure.

Changes:

  • Enables the probes client through Kconfig and build integration.
  • Adds a coherent DMA ring buffer with 10 ms polling to deliver DSP data to the compress buffer.
  • Registers the i.MX probes auxiliary device and its lifecycle callbacks.
File Description
sound/​soc/​sof/​sof-client-probes.c Adds the i.MX auxiliary-device match.
sound/​soc/​sof/​imx/​Makefile Includes the probes implementation in the i.MX8 build.
sound/​soc/​sof/​imx/​Kconfig Selects probes support for i.MX8 when debugfs is enabled.
sound/​soc/​sof/​imx/​imx8.c Hooks probes registration and unregistration into platform operations.
sound/​soc/​sof/​imx/​imx-probes.c Implements DMA allocation, polling, and compress-stream callbacks.
sound/​soc/​sof/​imx/​imx-common.h Declares the probes registration helpers.

Review effort: Balanced

Comment thread sound/soc/sof/imx/imx-probes.c Resolved
Comment thread sound/soc/sof/imx/imx-probes.c Resolved
Comment thread sound/soc/sof/imx/imx-probes.c Resolved
Comment thread sound/soc/sof/imx/imx-probes.c Resolved
Comment thread sound/soc/sof/imx/imx-probes.c Resolved
@dbaluta

dbaluta commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Do we want to have SND_SOC_SOF_IMX_PROBES enabled all the time for IMX? I wonder how Intel is doing?

Comment thread sound/soc/sof/imx/imx-probes.c Resolved
@ursus161

ursus161 commented Nov 4, 2026

Copy link
Copy Markdown
Author

Do we want to have SND_SOC_SOF_IMX_PROBES enabled all the time for IMX? I wonder how Intel is doing?

Mostly the same,

In the Intel side of things, at sound/soc/sof/intel/Kconfig:324 SND_SOC_SOF_HDA_GENERIC selects SND_SOC_SOF_HDA_PROBES with no regard to DEBUG_FS condition.

Here, SND_SOC_SOF_IMX_PROBES is hidden. SND_SOC_SOF_IMX8 selects it if DEBUG_FS.

@ursus161

ursus161 commented Nov 4, 2026

Copy link
Copy Markdown
Author

Do we want to have SND_SOC_SOF_IMX_PROBES enabled all the time for IMX? I wonder how Intel is doing?

Mostly the same,

In the Intel side of things, at sound/soc/sof/intel/Kconfig:324 SND_SOC_SOF_HDA_GENERIC selects SND_SOC_SOF_HDA_PROBES with no regard to DEBUG_FS condition.

Here, SND_SOC_SOF_IMX_PROBES is hidden. SND_SOC_SOF_IMX8 selects it if DEBUG_FS.

At second thought, we can enable the SND_SOC_SOF_IMX_PROBES without any condition, to be aligned with Intel. Will push changes soon.

@ursus161
ursus161 requested a review from dbaluta November 11, 2026 14:18
@ursus161
ursus161 marked this pull request as draft November 11, 2026 20:00
@ursus161
ursus161 marked this pull request as ready for review November 11, 2026 20:01
@ursus161
ursus161 force-pushed the sof-probes-imx branch 2 times, most recently from 796ea4d to 7433536 Compare November 17, 2026 15:16
Comment thread sound/soc/sof/sof-client-probes.c Resolved
Comment thread sound/soc/sof/sof-client-probes.c Resolved
@dbaluta

dbaluta commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

test this please

Ștefan Ghețu added 3 commits November 27, 2026 20:19
sof_probes_compr_startup() passes &priv->extractor_stream_tag to
ops->startup() and resets it to SOF_PROBES_INVALID_NODE_ID when the
call fails. The compress device can be opened more than once, so the
failing open may not be the one that owns the tag: if an extraction
stream is already running, the error path wipes its tag. Probe point
changes through debugfs then fail as if no extractor were set up,
although the stream is still active.

On HDA, hda_probes_compr_startup() returns -EBUSY when no host DMA
stream is free. Keep the tag on -EBUSY so a rejected open leaves the
running stream alone.

Fixes: 3dc0d70 ("ASoC: SOF: Convert the generic probe support to SOF client")
Signed-off-by: Ștefan Ghețu <stefan.ghetu@nxp.com>
The probe_points and probe_points_remove debugfs writes check
priv->extractor_stream_tag and then send the points add or remove
IPC. Nothing orders them against sof_probes_compr_shutdown(), which
removes all active points, sends the probe deinit IPC and resets the
tag. A write that runs while the extraction stream is shut down can
pass the tag check and then send its IPC after the probe has been
deinitialized, or leave a point connected that shutdown has already
enumerated and missed.

Add a mutex to struct sof_probes_priv, hold it in shutdown from the
point removal until the tag is reset, and take it around both
debugfs writes. The writes are split into _locked helpers so the
existing bodies stay unchanged.

Signed-off-by: Ștefan Ghețu <stefan.ghetu@nxp.com>
SND_SOC_SOF_DEBUG_PROBES was not selectable for i.MX and no
auxiliary probes client device was registered.

Add a hidden Kconfig symbol SND_SOC_SOF_IMX_PROBES, unconditionally
selected by SND_SOC_SOF_IMX8, and a new imx-probes.c that registers
the client, allocates a coherent DMA buffer and passes its bus
address to the firmware in PROBE_INIT stream_tag. A 10 ms delayed
work polls the DSP write counter, copies new data into the compress
buffer and calls snd_compr_fragment_elapsed().

Only one extraction stream is supported: a second open is rejected
with -EBUSY. The DSP read cursor is tracked separately from the byte
count reported to the compress core, the 32-bit DSP counter is
extended across wraps, data is only copied into free space of the
compress buffer and the reported count is reset on start and stop.

Signed-off-by: Ștefan Ghețu <stefan.ghetu@nxp.com>
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.

4 participants