Skip to content

Debug stream debugfs - #5154

Open
jsarha wants to merge 5 commits into
thesofproject:topic/sof-devfrom
jsarha:debug-stream-debugfs
Open

Debug stream debugfs#5154
jsarha wants to merge 5 commits into
thesofproject:topic/sof-devfrom
jsarha:debug-stream-debugfs

Conversation

@jsarha

Copy link
Copy Markdown
Collaborator

This commit simply maps the identified debug-stream debug window slot as a debugfs file.

Comment threadsound/soc/sof/ipc4-debug-stream.c Outdated
Comment threadsound/soc/sof/ipc4-debug-stream.c Outdated
Comment threadsound/soc/sof/ipc4-debug-stream.h Outdated
Comment threadsound/soc/sof/ipc4-debug-stream.c Outdated
Comment threadsound/soc/sof/ipc4-debug-stream.c Outdated
Comment threadsound/soc/sof/ipc4-debug-stream.h Outdated

@ujfalusiujfalusi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jsarha, what I would do is:
rename the ipc4-telemetry.c to ipc4-debugfs.c or something generic and use this to export the raw slots on the needed base.
You can have a single exported function as entry point, you can even move here the sof_ipc4_find_debug_slot_offset_by_type() function...

I know, mtrace is also uses debug slot, but it has been special cased out...

The ipc4-telemetry.h should remain as it is.

@jsarha
jsarhaforce-pushed the debug-stream-debugfs branch from 672baba to 68be79aCompareAugust 30, 2024 07:24
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@jsarha, what I would do is: rename the ipc4-telemetry.c to ipc4-debugfs.c or something generic and use this to export the raw slots on the needed base. You can have a single exported function as entry point, you can even move here the sof_ipc4_find_debug_slot_offset_by_type() function...

I know, mtrace is also uses debug slot, but it has been special cased out...

The ipc4-telemetry.h should remain as it is.

@ujfalusi I took a shot at this. I still try make sure the zephyr tool can still read the execption file.

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@ujfalusi@kv2019i , according to my tests the exception debugfs file works just as well after this change as it did before. That is, neither version works. I have no idea where the problem is, but I am quite sure this version is equivalent to the older version, so I'd hope to get this merged.

@lgirdwood

Copy link
Copy Markdown
Member

@jsarha@ujfalusi ping - can we unblock ?

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@jsarha@ujfalusi ping - can we unblock ?

This is not as important anymore as before, as the latest debug_stream.py is able to access its debug-window-slot directly using cavstool.py functions. However, I still think the debugfs file is a cleaner way to do this, so I still think this PR is valid.

@lgirdwood

Copy link
Copy Markdown
Member

@jsarha@ujfalusi ping - can we unblock ?

This is not as important anymore as before, as the latest debug_stream.py is able to access its debug-window-slot directly using cavstool.py functions. However, I still think the debugfs file is a cleaner way to do this, so I still think this PR is valid.

ok, we can park now and see how well existing tools work - if slow or inconsistent we can continue here.

ujfalusi
ujfalusi previously approved these changes Feb 11, 2025
lgirdwood
lgirdwood previously approved these changes Feb 13, 2025
@lgirdwood

Copy link
Copy Markdown
Member

@jsarha@ujfalusi ping - can we unblock ?

This is not as important anymore as before, as the latest debug_stream.py is able to access its debug-window-slot directly using cavstool.py functions. However, I still think the debugfs file is a cleaner way to do this, so I still think this PR is valid.

ok, we can park now and see how well existing tools work - if slow or inconsistent we can continue here.

I think this is useful in situations where no Python runtime is available. @ranj063@ujfalusi@bardliao lets move forward with this.
@jsarha some conflicts.

@jsarha
jsarha dismissed stale reviews from lgirdwood and ujfalusi via 2bd0077June 25, 2025 15:00
@jsarha
jsarhaforce-pushed the debug-stream-debugfs branch from 68be79a to 2bd0077CompareJune 25, 2025 15:00
@jsarha
jsarha requested a review from lyakh as a code ownerJune 25, 2025 15:00
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

Rephrased the first commit message a bit and resurrected ipc4-telemetry.h in the last commit (and updated the message accordingly), which is currently actually used. The code still works with debug_stream.py.

@lgirdwoodlgirdwood 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.

LGTM.

Comment threadsound/soc/sof/ipc4-pcm.c
lyakh
lyakh previously approved these changes Jun 26, 2025
Comment threadsound/soc/sof/ipc4-pcm.c
bardliao
bardliao previously approved these changes Jun 30, 2025
Comment threadsound/soc/sof/ipc4-debug-slot-debugfs.c Outdated
Comment threadsound/soc/sof/ipc4-debug-slot-debugfs.c Outdated
Comment threadsound/soc/sof/Makefile Outdated
@jsarha
jsarha dismissed stale reviews from bardliao and lgirdwood via 7d84e22July 1, 2025 19:49
@jsarha
jsarhaforce-pushed the debug-stream-debugfs branch from b9782ad to 7d84e22CompareJuly 1, 2025 19:49
@jsarha

jsarha commented Jul 1, 2025

Copy link
Copy Markdown
CollaboratorAuthor

@lyakh is this Ok now?

@bardliao , @lgirdwood only appled three last suggestions from Guennadi (Copyright 2024-2025), free in only one place sof_debug_slot_debugfs_entry_read(), and rename sof_ipc4_create_debug_slot_debugfs_node() to sof_ipc4_create_debug_slot_ro_debugfs_node() . Could you check those and reaprove if Ok.

lyakh
lyakh previously approved these changes Jul 2, 2025
bardliao
bardliao previously approved these changes Jul 2, 2025
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@lgirdwood should we still get this merged? @ujfalusi should I rebase, the PR getting old, again?

@bardliao

Copy link
Copy Markdown
Collaborator

@jsarha Is this PR still valid?

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@jsarha Is this PR still valid?

Yes it is, or at least it was. But its not mandatory as debug_stream.py is able to use cavstool.py 's /dev/kmem code to get access to the debug window slot in question.

@bardliao

Copy link
Copy Markdown
Collaborator

@jsarha Can you resolve the conflicts? Then we can merge it.

Jyri Sarha added 4 commits July 29, 2026 16:57
Adds sof_ipc4_create_debug_slot_ro_debugfs_node() -function for
mapping a SOF Intel ipc4 debug window slot as debugfs file. The actual
slot is specified with slot_type parameter. The alternatives are
defined in include/sound/sof/ipc4/header.h and the slot is found with
sof_ipc4_find_debug_slot_offset_by_type(). It also takes the
data_offset parameter that specifies where the payload data in the
slot begins. The portion that is mapped to the debugfs file is
everything after the offset. The last parameter is the name of the
file.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Add new debug window slot type for debug-stream protocol. For details see
src/debug/debug_stream/debug_stream_slot.h under SOF sources [1].
[1] https://github.com/thesofproject/sof
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Maps debug-stream debug window slot as read-only debugfs file with
sof_ipc4_create_debug_slot_ro_debugfs_node() -function.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
… file
Remove sof_ipc4_create_exception_debugfs_node() and ipc4-telemetry.c,
and use sof_ipc4_create_debug_slot_ro_debugfs_node() instead for
mapping "exception" debugfs file.
In running system the SOF_IPC4_DEBUG_SLOT_TELEMETRY is used for
telemetry data, but if configured, Zephyr exception data is dumped in
the same debug window slot, right after the separator word.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha
jsarha dismissed stale reviews from bardliao and lyakh via 8969765July 29, 2026 15:21
@jsarha
jsarhaforce-pushed the debug-stream-debugfs branch from 7d84e22 to 8969765CompareJuly 29, 2026 15:21
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@jsarha Can you resolve the conflicts? Then we can merge it.

@bardliao I've rebased and tested it now.

bardliao
bardliao previously approved these changes Jul 30, 2026
@bardliao

Copy link
Copy Markdown
Collaborator

@lyakh Would you like to approve this PR again? So that we will take your Reviewed-by tag

lgirdwood
lgirdwood previously approved these changes Jul 31, 2026
sof_ipc4_find_debug_slot_offset_by_type() prints a dev_dbg message
every time a slot type is not found. When debugfs files are polled
while the DSP is suspended, this fires on every access and spams the
kernel log.
Use dev_dbg_ratelimited() to suppress repeated messages.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
CopilotAI lite review requested due to automatic review settings August 13, 2026 16:28
@jsarha
jsarha dismissed stale reviews from lgirdwood and bardliao via cb3e72aAugust 13, 2026 16:28

CopilotAI 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.

Pull request overview

This PR updates the SOF IPC4 debug-window tooling by exposing the firmware “debug stream” slot (and reworking the existing exception/telemetry slot exposure) via dedicated read-only debugfs nodes.

Changes:

  • Add a generic IPC4 debug-slot → debugfs mapping helper and use it to create exception and debug_stream debugfs files at FW-ready time.
  • Remove the older IPC4 telemetry-specific debugfs implementation in favor of the new generic helper.
  • Add the IPC4 debug-slot type constant for the debug stream slot.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
sound/soc/sof/MakefileSwap IPC4 telemetry debugfs object for the new generic debug-slot debugfs object.
sound/soc/sof/ipc4.cCreate debugfs nodes for telemetry/exception and debug stream slots; rate-limit missing-slot debug logging.
sound/soc/sof/ipc4-telemetry.hDrop the now-removed exception debugfs node creation prototype.
sound/soc/sof/ipc4-telemetry.cRemove telemetry-specific debugfs implementation (replaced by generic helper).
sound/soc/sof/ipc4-priv.hAdd prototype for the new generic debug-slot debugfs node helper.
sound/soc/sof/ipc4-debug-slot-debugfs.cNew generic debug-slot debugfs read implementation.
include/sound/sof/ipc4/header.hDefine SOF_IPC4_DEBUG_SLOT_DEBUG_STREAM slot type.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +69 to +89
void sof_ipc4_create_debug_slot_ro_debugfs_node(struct snd_sof_dev *sdev, u32 slot_type,
size_t data_offset, const char *name)
{
struct debug_slot_fs_ud *ud;

ud = devm_kzalloc(sdev->dev, sizeof(*ud), GFP_KERNEL);
if (!ud)
return;

ud->dfse.type = SOF_DFSENTRY_TYPE_IOMEM;
ud->dfse.size = SOF_IPC4_DEBUG_SLOT_SIZE;
ud->dfse.access_type = SOF_DEBUGFS_ACCESS_ALWAYS;
ud->dfse.sdev = sdev;

ud->slot_type = slot_type;
ud->data_offset = data_offset;

list_add(&ud->dfse.list, &sdev->dfsentry_list);

debugfs_create_file(name, 0444, sdev->debugfs_root, ud, &sof_debug_stream_fops);
}
Comment threadsound/soc/sof/ipc4.c
}

sof_ipc4_create_exception_debugfs_node(sdev);
/* sizeof(u32)is for skiping the first separator magic number */
Comment threadsound/soc/sof/ipc4.c
}

dev_dbg(sdev->dev, "Slot type %#x is not available in debug window\n", slot_type);
dev_dbg_ratelimited(sdev->dev, "Slot type %#x is not available in debug window\n", slot_type);
Sign up for freeto 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.

7 participants

@jsarha@lgirdwood@bardliao@plbossart@lyakh@ujfalusi