Skip to content

IPC: make some pointers const and remove type-casts. No functional changes - #11103

Open
lyakh wants to merge 3 commits into
thesofproject:mainfrom
lyakh:ipc
Open

IPC: make some pointers const and remove type-casts. No functional changes#11103
lyakh wants to merge 3 commits into
thesofproject:mainfrom
lyakh:ipc

Conversation

@lyakh

@lyakh lyakh commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

remove type-casts and make read-only data guarded by the compiler. AI-aided.

The IDC layer only ever reads from msg->payload (it is memcpy'd into a
per-core scratch buffer before the target core runs, and any actual
output data is returned through a separately referenced coherent
buffer, e.g. get_attribute_remote_payload::value). Nothing writes
through this pointer, so mark it const void * to let senders pass
read-only data without casting away const.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>

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 tightens const-correctness across IPC4 bind/unbind plumbing (and related module/component APIs) to reduce unsafe casts and let the compiler enforce read-only usage, with no intended functional changes.

Changes:

  • Make IDC message payload pointers const (read-only) in both Zephyr and Posix RTOS headers.
  • Make bind_info and bind/unbind callbacks accept const pointers across component/module adapter APIs.
  • Introduce IPC4-specific connect/disconnect entrypoints and update IPC4 handlers to call them without type-casts; fix a small doc typo.

Reviewed changes

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

Show a summary per file
File Description
zephyr/include/rtos/idc.h Make idc_msg.payload const void * to reflect read-only usage.
posix/include/rtos/idc.h Same idc_msg.payload const-correctness change for Posix.
src/ipc/ipc4/helper.c Rename/connect-disconnect helpers to IPC4-specific APIs and remove caller-side casts.
src/ipc/ipc4/handler-user.c Update IPC4 bind/unbind dispatch to call new IPC4 connect/disconnect functions.
src/include/sof/schedule/dp_schedule.h Make scheduler IPC bind parameter point to const struct bind_info.
src/include/sof/ipc/topology.h Fix a minor doc punctuation typo in the connect API comment.
src/include/sof/audio/module_adapter/module/generic.h Make module bind/unbind APIs take const struct bind_info *.
src/include/sof/audio/module_adapter/library/userspace_proxy_user.h Mark bind_data as const struct bind_info * in userspace proxy params.
src/include/sof/audio/component.h Make component bind/unbind callback signatures take const struct bind_info * and mark IPC4 bind data as const.
src/include/sof/audio/component_ext.h Propagate const-correct bind/unbind signatures through component wrapper helpers.
src/include/module/module/interface.h Update module interface bind/unbind callbacks to take const struct bind_info *.
src/include/ipc4/handler.h Add public declarations for IPC4 connect/disconnect helpers.
src/debug/tester/tester.h Update tester bind/unbind callback typedefs to accept const struct bind_info *.
src/debug/tester/tester.c Update tester bind/unbind implementations to match new const signatures.
src/audio/tone/tone-ipc4.c Update tone module bind/unbind signatures for const bind info.
src/audio/module_adapter/module/generic.c Update module bind/unbind implementations for const bind info.
src/audio/module_adapter/module_adapter_ipc4.c Update IPC4 module adapter bind/unbind-related signatures for const bind info.
src/audio/module_adapter/library/userspace_proxy.c Update userspace proxy bind/unbind signatures and bind param passing for const bind info.
src/audio/mixin_mixout/mixin_mixout.c Make local IPC4 bind/unbind pointers const to match new bind_info semantics.
src/audio/kpb.c Make local IPC4 bind/unbind pointers const and update bind/unbind signatures.
src/audio/dai-zephyr.c Update unbind signature and make IPC4 bind/unbind pointer const.
src/audio/copier/dai_copier.h Update dai_zephyr_unbind() declaration to take const struct bind_info *.
src/audio/copier/copier.c Update copier bind/unbind signatures for const bind info.
Suppressed comments (2)

src/include/ipc4/handler.h:85

  • Same as ipc4_comp_connect(): ipc4_comp_disconnect() returns IPC4 status codes (0 on success, non-zero IPC4_* on error), not negative errno values, and the bind/unbind message is read-only so the parameter should be const.
 * @param ipc The global IPC context.
 * @param bu IPC4 bind-unbind data.
 * @return 0 on success or negative error.
 */
int ipc4_comp_disconnect(struct ipc *ipc, struct ipc4_module_bind_unbind *bu);

src/ipc/ipc4/helper.c:1043

  • ipc4_comp_disconnect() only reads from the IPC4 bind/unbind request; make the parameter const to prevent accidental modification and to stay consistent with ipc4/handler.h.
/* Only called from ipc4_unbind_module_instance(), which is __cold */
__cold int ipc4_comp_disconnect(struct ipc *ipc, struct ipc4_module_bind_unbind *bu)
{

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

Comment thread src/include/ipc4/handler.h Outdated
Comment thread src/ipc/ipc4/helper.c
@lyakh
lyakh force-pushed the ipc branch 2 times, most recently from ce620b8 to efc35ce Compare August 18, 2026 12:39
lyakh added 2 commits August 18, 2026 16:06
Make struct bind_info::ipc4_data a pointer to const struct
ipc4_module_bind_unbind, since bind/unbind handlers only ever read
this IPC4 payload. This required propagating const through the
second argument of struct module_interface::bind()/unbind(),
struct comp_ops::bind()/unbind(), comp_bind()/comp_unbind() and all
their implementations (copier, kpb, mixin/mixout, tone, tester,
userspace_proxy, dai_zephyr_unbind, DP scheduler IPC plumbing).

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Currently both IPC3 and IPC4 use ipc_comp_connect() and
ipc_comp_disconnect() even though their second parameter has
different types. This makes no sense since both implementations and
calling sites are different. Rename IPC4 versions to drop type-casts.

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.

2 participants