From 8a447d63897d885ba031f7dbd05f9efb88833f85 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 9 Jan 2026 19:52:16 +0200 Subject: [PATCH 1/2] audio: pipeline: IPC3 xrun IPC messages should not be sent in IPC4 builds The IPC interface to notify host of over/underruns is different between IPC3 and IPC4. The pipeline_xrun() implementation however was called in common code and could lead to corruption of the host-DSP mailboxes. In practise errors were not hit in current SOF builds as none of the DMA drivers that are used with targets using IPC4, return runtime errors in their dma_reload() implementations, so dai_report_xrun() was never called. Zephyr DMA does allow errors to be returned for reload, so correct the implementation to never send IPC3 notifications in IPC4 builds. Signed-off-by: Kai Vehmanen --- src/audio/pipeline/pipeline-xrun.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/audio/pipeline/pipeline-xrun.c b/src/audio/pipeline/pipeline-xrun.c index 3b727074ab97..9a6ccdbe9c67 100644 --- a/src/audio/pipeline/pipeline-xrun.c +++ b/src/audio/pipeline/pipeline-xrun.c @@ -29,6 +29,8 @@ LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL); */ #define NO_XRUN_RECOVERY 1 +#if CONFIG_IPC_MAJOR_3 + /* This function always returns success */ static int pipeline_comp_xrun(struct comp_dev *current, struct comp_buffer *calling_buf, @@ -49,6 +51,8 @@ static int pipeline_comp_xrun(struct comp_dev *current, return pipeline_for_each_comp(current, ctx, dir); } +#endif /* CONFIG_IPC_MAJOR_3 */ + #if NO_XRUN_RECOVERY /* recover the pipeline from a XRUN condition */ int pipeline_xrun_recover(struct pipeline *p) @@ -139,6 +143,7 @@ int pipeline_xrun_handle_trigger(struct pipeline *p, int cmd) void pipeline_xrun(struct pipeline *p, struct comp_dev *dev, int32_t bytes) { +#if CONFIG_IPC_MAJOR_3 struct pipeline_data data; struct pipeline_walk_context walk_ctx = { .comp_func = pipeline_comp_xrun, @@ -146,6 +151,7 @@ void pipeline_xrun(struct pipeline *p, struct comp_dev *dev, .skip_incomplete = true, }; struct sof_ipc_stream_posn posn; +#endif int ret; /* don't flood host */ @@ -162,6 +168,12 @@ void pipeline_xrun(struct pipeline *p, struct comp_dev *dev, pipe_err(p, "Pipelines notification about XRUN failed, ret = %d", ret); + /* + * The IPC position info reporting via window2 is only + * used for IPC3 and e.g. in IPC4 this is conflicting + * with the debug window usages (logging, debug, ..) + */ +#if CONFIG_IPC_MAJOR_3 memset(&posn, 0, sizeof(posn)); ipc_build_stream_posn(&posn, SOF_IPC_STREAM_TRIG_XRUN, dev_comp_id(dev)); @@ -172,4 +184,5 @@ void pipeline_xrun(struct pipeline *p, struct comp_dev *dev, data.p = p; walk_ctx.comp_func(dev, NULL, &walk_ctx, dev->direction); +#endif } From c39a5a94e9789a49c4c17f3c557f036de187cb94 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 9 Jan 2026 19:54:33 +0200 Subject: [PATCH 2/2] lib: mailbox: add assert to catch mailbox_stream_write() use in IPC4 To prevent any accidental use in new code, add an assert to mailbox_stream_write() against use in IPC4 builds. The "stream mailbox" is not available in IPC4 mailbox layout, so it must not be used. Signed-off-by: Kai Vehmanen --- src/include/sof/lib/mailbox.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/include/sof/lib/mailbox.h b/src/include/sof/lib/mailbox.h index 06e2659a5847..ae667f0d0c4c 100644 --- a/src/include/sof/lib/mailbox.h +++ b/src/include/sof/lib/mailbox.h @@ -100,6 +100,14 @@ void mailbox_hostbox_read(void *dest, size_t dest_size, assert(!host_read_err); } +#if CONFIG_IPC_MAJOR_4 +static inline +void mailbox_stream_write(size_t offset, const void *src, size_t bytes) +{ + /* in IPC4, the stream mailbox must not be used */ + assert(false); +} +#else static inline void mailbox_stream_write(size_t offset, const void *src, size_t bytes) { @@ -110,5 +118,6 @@ void mailbox_stream_write(size_t offset, const void *src, size_t bytes) dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_STREAM_BASE + offset), bytes); } +#endif #endif /* __SOF_LIB_MAILBOX_H__ */