Skip to content

ipc: eliminate multiple memcpy() calls - #11059

Open
lyakh wants to merge 1 commit into
thesofproject:mainfrom
lyakh:memcpy
Open

ipc: eliminate multiple memcpy() calls#11059
lyakh wants to merge 1 commit into
thesofproject:mainfrom
lyakh:memcpy

Conversation

@lyakh

@lyakh lyakh commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Eliminate multiple instances of IPC4 data copying, use simple type- casts instead. This removes stack objects and replaces run-time copying with compile-time pointer substitution.

Copilot AI lite review requested due to automatic review settings August 5, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 reduces IPC4 message handling overhead by removing local stack copies and memcpy_s() calls for several IPC4 request headers, instead interpreting the inbound message via pointer casting and tightening some APIs with const correctness.

Changes:

  • Replaces multiple memcpy_s()-to-stack patterns with direct pointer casts for IPC4 request header access in the user IPC4 handler.
  • Updates comp_new_ipc4(), ipc4_chain_manager_create(), and ipc4_chain_dma_state() to take const IPC4 request structures.
  • Propagates the updated function signatures through relevant public headers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/ipc/ipc4/helper.c Makes IPC4 helper entry points accept const request structures (no behavioral change intended).
src/ipc/ipc4/handler-user.c Removes stack copies / memcpy_s() and switches to direct request-structure pointer access.
src/include/sof/ipc/topology.h Updates IPC4 chain DMA helper prototypes to match new const signatures.
src/include/sof/audio/component_ext.h Updates comp_new_ipc4() prototype to accept a const init-instance request.
Suppressed comments (1)

src/ipc/ipc4/handler-user.c:1436

  • In CONFIG_LIBRARY builds, config is a pointer here too, so sizeof(config) is the pointer size, not the size of struct ipc4_module_large_config. The payload pointer will be off by 4/8 bytes.
#if CONFIG_LIBRARY
		struct ipc *ipc = ipc_get();
		const char *data = (const char *)ipc->comp_data + sizeof(config);
#else
		const char *data = (const char *)MAILBOX_HOSTBOX_BASE;

Comment thread src/ipc/ipc4/handler-user.c
Eliminate multiple instances of IPC4 data copying, use simple type-
casts instead. This removes stack objects and replaces run-time
copying with compile-time pointer substitution.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.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.

3 participants