Skip to content

Debug stream text msg improvements#10845

Open
jsarha wants to merge 2 commits into
thesofproject:mainfrom
jsarha:debug_stream_text_msg_improvements
Open

Debug stream text msg improvements#10845
jsarha wants to merge 2 commits into
thesofproject:mainfrom
jsarha:debug_stream_text_msg_improvements

Conversation

@jsarha
Copy link
Copy Markdown
Contributor

@jsarha jsarha commented Jun 4, 2026

Make ds_send_text_record() a syscall to make userspace debugging easier. And export ds_msg() to allow its usage in module code.

Copilot AI review requested due to automatic review settings June 4, 2026 22:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 improves debug stream text messaging for Zephyr-based SOF builds by making ds_send_text_record() callable from user space via a syscall and by exporting ds_msg() for use from module code.

Changes:

  • Register debug_stream_text_msg.h for Zephyr syscall header generation.
  • Add ds_send_text_record() API as a Zephyr syscall (when CONFIG_USERSPACE is enabled) and introduce DS_TEXT_MSG_MAX_LEN.
  • Implement syscall plumbing (z_impl_*/z_vrfy_* + marshalling include) and export ds_msg().

Reviewed changes

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

File Description
zephyr/CMakeLists.txt Adds the header to Zephyr’s syscall generation inputs.
src/include/user/debug_stream_text_msg.h Introduces DS_TEXT_MSG_MAX_LEN and the ds_send_text_record() syscall/public prototype.
src/debug/debug_stream/debug_stream_text_msg.c Implements the syscall handler + verifier and exports ds_msg(); refactors text record sending path.

Comment thread src/debug/debug_stream/debug_stream_text_msg.c Outdated
Comment thread src/include/user/debug_stream_text_msg.h Outdated
Comment thread src/debug/debug_stream/debug_stream_text_msg.c Outdated
Comment thread src/debug/debug_stream/debug_stream_text_msg.c Outdated
Export ds_msg() to allow using it in loadable modules.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the debug_stream_text_msg_improvements branch 2 times, most recently from d9364e5 to 59795e2 Compare June 7, 2026 16:57
Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Just a quick sanity check whether the simpler boilerplate could be used. Otherwise looks ready to go.

Comment thread src/include/user/debug_stream_slot.h Outdated

#if defined(__ZEPHYR__) && defined(CONFIG_USERSPACE)
#include <zephyr/syscalls/debug_stream_slot.h>
#endif
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.

Is this really called from any non-Zephyr build? If this is Zephyr only, you could use the simpler boilet plate of having __syscall declaration always and let Zephyr build system generate the boiletplate for userspace and non-userspace builds. We can't use this for syscalls that are only used in some user-space builds, but this seems generic enough, so the simpler boilerplate could work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kv2019i Ok, what exactly are you suggesting? I searched for other syscall implementations, but all seem to follow this pattern, with minor variations.

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 I mean like "work/zephyr/include/zephyr/device.h", just mark with "__syscall" without any ifdefs.
In implementation file work/zephyr/kernel/device.c you have the z_impl_foo() always and only have the verification code under ifdefs. We can't do this for many of our added syscalls in SOF as they are not enabled fo rall user-space configs, but if something is enabled whenever CONFIG_USERSPACE is set, we can use the standard boilerplate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kv2019i it does not work with CONFIG_USERSPACE=n without #define debug_stream_slot_send_record z_impl_debug_stream_slot_send_record:

/home/oku/xcc/install/tools/RI-2022.10-linux/XtensaTools/bin/xtensa-elf-ld: modules/sof/libmodules_sof.a(debug_stream_text_msg.c.obj):(.literal.ds_msg+0x0): undefined reference to `debug_stream_slot_send_record'

What am I missing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, got it. I need to take from around:
#include <zephyr/syscalls/debug_stream_slot.h>
too.

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.

Ack, I use similar approach in #10853

Make debug_stream_slot_send_record() a Zephyr syscall. This allows
user-space threads to send debug stream records directly.

Rename the implementation to z_impl_debug_stream_slot_send_record() and
add z_vrfy_debug_stream_slot_send_record() with K_SYSCALL_MEMORY_READ
validation of the record buffer. Register the syscall header in
CMakeLists.txt.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the debug_stream_text_msg_improvements branch from 59795e2 to ca2117b Compare June 8, 2026 17:44
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