IPC: make some pointers const and remove type-casts. No functional changes - #11103
Open
lyakh wants to merge 3 commits into
Open
IPC: make some pointers const and remove type-casts. No functional changes#11103lyakh wants to merge 3 commits into
const and remove type-casts. No functional changes#11103lyakh wants to merge 3 commits into
Conversation
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>
lyakh
requested review from
abonislawski,
dbaluta,
fkwasowi,
iganakov,
iuliana-prodan,
kv2019i,
lbetlej,
lgirdwood,
mmaka1,
pblaszko,
plbossart,
ranj063 and
tmleman
as code owners
August 18, 2026 11:58
Contributor
There was a problem hiding this comment.
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_infoand bind/unbind callbacks acceptconstpointers 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.
lyakh
force-pushed
the
ipc
branch
2 times, most recently
from
August 18, 2026 12:39
ce620b8 to
efc35ce
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
remove type-casts and make read-only data guarded by the compiler. AI-aided.