From 7225643e4246b4ba96c826f0cacfe7e95fcc398b Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Sun, 22 Nov 2026 18:01:06 +0000 Subject: [PATCH 01/16] audio: buffers/ipc4: add DP-to-DP component binding Binding two DP (Data Processing) scheduled components was previously rejected with IPC4_INVALID_REQUEST because both sides required a secondary ring buffer. Add support for DP-to-DP component binding under CONFIG_DP_TO_DP_BIND. In a DP-to-DP connection, a single shared ring buffer is created and attached as a secondary buffer on both the source and sink sides of the intermediate comp_buffer. The upstream DP module writes directly to the ring buffer sink API, and the downstream DP module reads directly from its source API with no intermediate LL-cycle copy. The DP module virtual memory region backing the ring buffer is refcounted so that it remains valid across component lifetimes, and audio buffer reset and free operations ensure the shared secondary buffer is not reset or freed twice. Signed-off-by: Seppo Ingalsuo Signed-off-by: Liam Girdwood --- src/audio/buffers/audio_buffer.c | 44 ++++++++++++++++------ src/audio/buffers/ring_buffer.c | 11 +++++- src/include/sof/audio/audio_buffer.h | 7 ++++ src/ipc/ipc4/helper.c | 56 +++++++++++++++++++++------- zephyr/Kconfig | 9 +++++ 5 files changed, 101 insertions(+), 26 deletions(-) diff --git a/src/audio/buffers/audio_buffer.c b/src/audio/buffers/audio_buffer.c index 1ecf8472dd65..0b0b22a191fe 100644 --- a/src/audio/buffers/audio_buffer.c +++ b/src/audio/buffers/audio_buffer.c @@ -24,8 +24,16 @@ int audio_buffer_attach_secondary_buffer(struct sof_audio_buffer *buffer, bool at_input, struct sof_audio_buffer *secondary_buffer) { +#ifdef CONFIG_DP_TO_DP_BIND + /* check per-side: allow attaching on both sides (needed for DP-to-DP) */ + if (at_input && buffer->secondary_buffer_sink) + return -EINVAL; + if (!at_input && buffer->secondary_buffer_source) + return -EINVAL; +#else if (buffer->secondary_buffer_sink || buffer->secondary_buffer_source) return -EINVAL; +#endif /* secondary buffer must share audio params with the primary buffer */ secondary_buffer->audio_stream_params = buffer->audio_stream_params; @@ -48,6 +56,19 @@ int audio_buffer_sync_secondary_buffer(struct sof_audio_buffer *buffer, size_t l struct sof_source *data_src; struct sof_sink *data_dst; +#ifdef CONFIG_DP_TO_DP_BIND + if (buffer->secondary_buffer_sink && + buffer->secondary_buffer_sink == buffer->secondary_buffer_source) { + /* + * DP-to-DP case: a single shared ring_buffer is attached on both sides. + * The source DP writes directly to the ring_buffer sink API, and the + * sink DP reads directly from the ring_buffer source API. + * No copying is needed during the LL cycle. + */ + return 0; + } +#endif + if (buffer->secondary_buffer_sink) { /* * audio_buffer sink API is shadowed, that means there's a secondary_buffer @@ -95,7 +116,12 @@ void audio_buffer_free(struct sof_audio_buffer *buffer) CORE_CHECK_STRUCT(buffer); #if CONFIG_PIPELINE_2_0 audio_buffer_free(buffer->secondary_buffer_sink); +#ifdef CONFIG_DP_TO_DP_BIND + if (buffer->secondary_buffer_source != buffer->secondary_buffer_sink) + audio_buffer_free(buffer->secondary_buffer_source); +#else audio_buffer_free(buffer->secondary_buffer_source); +#endif #endif /* CONFIG_PIPELINE_2_0 */ /* "virtual destructor": free the buffer internals and buffer memory */ buffer->ops->free(buffer); @@ -203,18 +229,14 @@ uint32_t audio_buffer_sink_get_lft(struct sof_sink *sink) return us_in_buffer; /* - * TODO, Currently there's no DP to DP connection - * >>> the code below is never accessible and won't work because of cache incoherence <<< - * - * to make DP to DP connection possible: + * NOTE: DP-to-DP connections are now supported via a single shared ring_buffer + * attached as secondary buffer on both sides of a comp_buffer. * - * 1) module data must be ALWAYS located in non cached memory alias, allowing - * cross core access to params like period (needed below) and calling - * module_get_deadline for the next module, regardless of cores the modules are - * running on - * 2) comp_buffer must be removed from all pipeline code, replaced with a generic abstract - * class audio_buffer - allowing using comp_buffer and ring_buffer without current - * "hybrid buffer" solution + * Future improvements: + * 1) module data should be in non-cached memory alias for reliable + * cross-core access to params like period and deadlines + * 2) comp_buffer should be replaced with generic audio_buffer + * throughout pipeline code (Pipeline 2.0) */ } diff --git a/src/audio/buffers/ring_buffer.c b/src/audio/buffers/ring_buffer.c index fde594d32424..1a6ada30d874 100644 --- a/src/audio/buffers/ring_buffer.c +++ b/src/audio/buffers/ring_buffer.c @@ -88,7 +88,6 @@ static inline void ring_buffer_writeback_shared(struct ring_buffer *ring_buffer, dcache_writeback_region(ptr, size); } - /** * @brief remove the queue from the list, free memory */ @@ -105,6 +104,16 @@ __cold static void ring_buffer_free(struct sof_audio_buffer *audio_buffer) sof_ctx_free(alloc, (__sparse_force void *)ring_buffer->_data_buffer); sof_ctx_free(alloc, ring_buffer); + +#ifdef CONFIG_DP_TO_DP_BIND + /* + * When CONFIG_DP_TO_DP_BIND is enabled, ipc4_comp_connect() takes an extra vregion + * reference for each ring_buffer created from a module vregion. The alloc ctx of a DP + * module lives inside its vregion and is freed by the last vregion_put(). + */ + if (alloc && alloc->vreg) + vregion_put(alloc->vreg); +#endif } static void ring_buffer_reset(struct sof_audio_buffer *audio_buffer) diff --git a/src/include/sof/audio/audio_buffer.h b/src/include/sof/audio/audio_buffer.h index f16a50ccd43d..3f9bca2be124 100644 --- a/src/include/sof/audio/audio_buffer.h +++ b/src/include/sof/audio/audio_buffer.h @@ -368,9 +368,16 @@ void audio_buffer_reset(struct sof_audio_buffer *buffer) if (buffer->secondary_buffer_sink && buffer->secondary_buffer_sink->ops->reset) buffer->secondary_buffer_sink->ops->reset(buffer->secondary_buffer_sink); +#ifdef CONFIG_DP_TO_DP_BIND + if (buffer->secondary_buffer_source && + buffer->secondary_buffer_source != buffer->secondary_buffer_sink && + buffer->secondary_buffer_source->ops->reset) + buffer->secondary_buffer_source->ops->reset(buffer->secondary_buffer_source); +#else if (buffer->secondary_buffer_source && buffer->secondary_buffer_source->ops->reset) buffer->secondary_buffer_source->ops->reset(buffer->secondary_buffer_source); #endif +#endif } /* Audio-buffer wrappers for the source-sink API */ diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 6bf259695403..bae99f86cb0e 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -772,18 +772,22 @@ __cold int ipc4_comp_connect(struct ipc *ipc, const struct ipc4_module_bind_unbi struct mod_alloc_ctx *alloc; #if CONFIG_ZEPHYR_DP_SCHEDULER - if (source->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP && - sink->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) { + bool src_is_dp = source->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP; + bool sink_is_dp = sink->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP; +#ifdef CONFIG_DP_TO_DP_BIND + bool dp_to_dp = src_is_dp && sink_is_dp; +#else + if (src_is_dp && sink_is_dp) { tr_err(&ipc_tr, "DP to DP binding is not supported: can't bind %x to %x", src_id, sink_id); return IPC4_INVALID_REQUEST; } - +#endif struct comp_dev *dp; - if (sink->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) + if (sink_is_dp) dp = sink; - else if (source->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) + else if (src_is_dp) dp = source; else dp = NULL; @@ -874,8 +878,8 @@ __cold int ipc4_comp_connect(struct ipc *ipc, const struct ipc4_module_bind_unbi * * size = 2*max(obs of source module, ibs of destination module) * (obs and ibs is single buffer size) - * in case of DP -> LL - * size = 2*ibs of destination (LL) module. DP queue will handle obs of DP module + * in case of DP -> LL or DP -> DP + * size = 2*ibs of destination module. DP queue will handle obs of DP module */ if (source->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL) buf_size = MAX(ibs, obs) * 2; @@ -910,12 +914,13 @@ __cold int ipc4_comp_connect(struct ipc *ipc, const struct ipc4_module_bind_unbi #if CONFIG_ZEPHYR_DP_SCHEDULER struct ring_buffer *ring_buffer = NULL; - if (sink->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP || - source->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) { + if (src_is_dp || sink_is_dp) { struct processing_module *srcmod = comp_mod(source); struct module_data *src_module_data = &srcmod->priv; struct processing_module *dstmod = comp_mod(sink); struct module_data *dst_module_data = &dstmod->priv; + bool is_shared = audio_buffer_is_shared(&buffer->audio_buffer); + uint32_t buf_id = buf_get_id(buffer); /* * Handle cases where the size of the ring buffer depends on the @@ -927,16 +932,39 @@ __cold int ipc4_comp_connect(struct ipc *ipc, const struct ipc4_module_bind_unbi */ ring_buffer = ring_buffer_create(dp, MAX(ibs, dst_module_data->mpd.in_buff_size), MAX(obs, src_module_data->mpd.out_buff_size), - audio_buffer_is_shared(&buffer->audio_buffer), - buf_get_id(buffer)); + is_shared, buf_id); if (!ring_buffer) { buffer_free(buffer); return IPC4_OUT_OF_MEMORY; } - /* data destination module needs to use ring_buffer */ - audio_buffer_attach_secondary_buffer(&buffer->audio_buffer, dp == source, - &ring_buffer->audio_buffer); +#ifdef CONFIG_DP_TO_DP_BIND + /* + * Keep the DP module vregion alive for the lifetime of this ring_buffer + * (dropped in ring_buffer_free()) since source and sink DP modules can be + * torn down independently. + */ + if (ring_buffer->audio_buffer.alloc) + vregion_get(ring_buffer->audio_buffer.alloc->vreg); + + if (dp_to_dp) { + /* + * DP-to-DP binding: both source and sink are DP modules. + * A single shared ring_buffer is attached on both sides + * of the comp_buffer, so source DP writes directly to it + * and sink DP reads directly from it without copying. + */ + audio_buffer_attach_secondary_buffer(&buffer->audio_buffer, true, + &ring_buffer->audio_buffer); + audio_buffer_attach_secondary_buffer(&buffer->audio_buffer, false, + &ring_buffer->audio_buffer); + } else +#endif + { + /* data destination module needs to use ring_buffer */ + audio_buffer_attach_secondary_buffer(&buffer->audio_buffer, dp == source, + &ring_buffer->audio_buffer); + } } #endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 148374c533a8..76a01ac44458 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -321,6 +321,15 @@ config ZEPHYR_DP_SCHEDULER_MIN_STACK_SIZE ext_init payload. If the stack size requested in the IPC is smaller than this, then the value defined here takes over. +config DP_TO_DP_BIND + bool "Support DP to DP component binding" + default y + depends on ZEPHYR_DP_SCHEDULER + help + Enable binding between two Data Processing (DP) scheduled components. + This allows connecting DP modules together (e.g. DP source to DP sink) + via intermediate buffering. + config CROSS_CORE_STREAM bool "Enable cross-core connected pipelines" default y if IPC_MAJOR_4 From d24b603af2cc1c37bd6c341dbbed7642cebe99e1 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:06 +0000 Subject: [PATCH 02/16] ipc4: helper: guard NULL module_data in ipc4_comp_connect() When source or sink component is not a processing_module (such as a host copier or non-module comp_dev), comp_mod() returns NULL. Guard src_module_data and dst_module_data before accessing mpd.in_buff_size and mpd.out_buff_size to prevent NULL pointer dereferences when configuring DP ring buffers. Signed-off-by: Liam Girdwood --- src/ipc/ipc4/helper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index bae99f86cb0e..b5dbf7beb06e 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -916,9 +916,11 @@ __cold int ipc4_comp_connect(struct ipc *ipc, const struct ipc4_module_bind_unbi if (src_is_dp || sink_is_dp) { struct processing_module *srcmod = comp_mod(source); - struct module_data *src_module_data = &srcmod->priv; + struct module_data *src_module_data = srcmod ? &srcmod->priv : NULL; struct processing_module *dstmod = comp_mod(sink); - struct module_data *dst_module_data = &dstmod->priv; + struct module_data *dst_module_data = dstmod ? &dstmod->priv : NULL; + uint32_t dst_in_buff_size = dst_module_data ? dst_module_data->mpd.in_buff_size : 0; + uint32_t src_out_buff_size = src_module_data ? src_module_data->mpd.out_buff_size : 0; bool is_shared = audio_buffer_is_shared(&buffer->audio_buffer); uint32_t buf_id = buf_get_id(buffer); @@ -930,8 +932,8 @@ __cold int ipc4_comp_connect(struct ipc *ipc, const struct ipc4_module_bind_unbi * is only for the ring buffer. The size of intermediate buffer created above is * unchanged. */ - ring_buffer = ring_buffer_create(dp, MAX(ibs, dst_module_data->mpd.in_buff_size), - MAX(obs, src_module_data->mpd.out_buff_size), + ring_buffer = ring_buffer_create(dp, MAX(ibs, dst_in_buff_size), + MAX(obs, src_out_buff_size), is_shared, buf_id); if (!ring_buffer) { buffer_free(buffer); From 0a3c326643cb5c06c48a4ac6e54a9b9deec749dd Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Sun, 22 Nov 2026 18:01:06 +0000 Subject: [PATCH 03/16] schedule: zephyr_dp_schedule: use a mutex for the per-core DP lock The DP lock is taken by the LL thread on every tick in scheduler_dp_ll_tick() and by each DP thread after every run. Using a k_sem has no priority inheritance, so when a DP thread holding the lock is preempted by other DP threads, the cooperative high-priority LL thread stalls until the holder runs again. With several busy DP modules active (such as multiple WoV detector pipelines), using a k_mutex lets the lock holder inherit the LL priority so LL max latency drops without DMA xruns. Signed-off-by: Peter Ujfalusi Signed-off-by: Liam Girdwood --- src/include/sof/schedule/zephyr_dp_schedule.h | 2 +- src/kernel/schedule/zephyr_dp_schedule-kernel.c | 5 +++-- src/schedule/zephyr_dp_schedule.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/include/sof/schedule/zephyr_dp_schedule.h b/src/include/sof/schedule/zephyr_dp_schedule.h index 94685b3cb2de..29e10aca963f 100644 --- a/src/include/sof/schedule/zephyr_dp_schedule.h +++ b/src/include/sof/schedule/zephyr_dp_schedule.h @@ -130,7 +130,7 @@ struct scheduler_dp_task_memory { #endif /* CONFIG_SOF_USERSPACE_APPLICATION */ /** @brief Per-core DP scheduler locks, see scheduler_dp_lock(). */ -extern struct k_sem dp_lock[CONFIG_MP_MAX_NUM_CPUS]; +extern struct k_mutex dp_lock[CONFIG_MP_MAX_NUM_CPUS]; /** * @brief DP scheduler ops, see struct scheduler_ops. diff --git a/src/kernel/schedule/zephyr_dp_schedule-kernel.c b/src/kernel/schedule/zephyr_dp_schedule-kernel.c index 81e5dad1a3a7..2f495c1c0be2 100644 --- a/src/kernel/schedule/zephyr_dp_schedule-kernel.c +++ b/src/kernel/schedule/zephyr_dp_schedule-kernel.c @@ -43,14 +43,15 @@ DECLARE_TR_CTX(dp_tr, SOF_UUID(dp_sched_uuid), LOG_LEVEL_INFO); * src/schedule/zephyr_dp_schedule.c */ -#define DP_LOCK_INIT(i, _) Z_SEM_INITIALIZER(dp_lock[i], 1, 1) +/* k_mutex, not k_sem: priority inheritance keeps a preempted DP holder from stalling LL */ +#define DP_LOCK_INIT(i, _) Z_MUTEX_INITIALIZER(dp_lock[i]) #define DP_LOCK_INIT_LIST LISTIFY(CONFIG_MP_MAX_NUM_CPUS, DP_LOCK_INIT, (,)) /* User threads don't need access to this array. Access is performed from * the kernel space via a syscall. Array must be placed in special section * to be qualified as initialized by the gen_kobject_list.py script. */ -STRUCT_SECTION_ITERABLE_ARRAY(k_sem, dp_lock, CONFIG_MP_MAX_NUM_CPUS) = { DP_LOCK_INIT_LIST }; +STRUCT_SECTION_ITERABLE_ARRAY(k_mutex, dp_lock, CONFIG_MP_MAX_NUM_CPUS) = { DP_LOCK_INIT_LIST }; void scheduler_dp_grant(k_tid_t thread_id, uint16_t core) { diff --git a/src/schedule/zephyr_dp_schedule.c b/src/schedule/zephyr_dp_schedule.c index 38d228d4b609..ae0580b9b695 100644 --- a/src/schedule/zephyr_dp_schedule.c +++ b/src/schedule/zephyr_dp_schedule.c @@ -41,13 +41,13 @@ extern struct tr_ctx dp_tr; */ unsigned int scheduler_dp_lock(uint16_t core) { - k_sem_take(&dp_lock[core], K_FOREVER); + k_mutex_lock(&dp_lock[core], K_FOREVER); return core; } void scheduler_dp_unlock(unsigned int key) { - k_sem_give(&dp_lock[key]); + k_mutex_unlock(&dp_lock[key]); } #if CONFIG_SOF_USERSPACE_APPLICATION && CONFIG_SOF_USERSPACE_LL From 7f4868ec7aad4d225be43f3540a1efa01266e639 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Sun, 22 Nov 2026 18:01:06 +0000 Subject: [PATCH 04/16] audio: module_adapter: pass SIZE_MAX to audio_buffer_sync_secondary_buffer() The limit parameter of audio_buffer_sync_secondary_buffer() is of type size_t. Pass SIZE_MAX instead of UINT_MAX for unlimited input copy to match the parameter type and avoid size mismatches on 64-bit platforms. Signed-off-by: Seppo Ingalsuo Signed-off-by: Liam Girdwood --- src/audio/module_adapter/module_adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 1257d15978b9..59c44f7e5608 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -604,7 +604,7 @@ static int module_adapter_copy_ring_buffers(struct comp_dev *dev) /* input - we need to copy data from audio_stream (as source) * to ring_buffer (as sink) */ - err = audio_buffer_sync_secondary_buffer(&buffer->audio_buffer, UINT_MAX); + err = audio_buffer_sync_secondary_buffer(&buffer->audio_buffer, SIZE_MAX); if (err) { comp_err(dev, "LL to DP copy error status: %d", err); From b4b9244c68db1d416249031c79c53eac7dc89739 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Sun, 22 Nov 2026 18:01:17 +0000 Subject: [PATCH 05/16] audio: module_adapter: set DP sink params left unset by legacy consumers In WoV pipelines, DP modules (such as ECNS or keyword detectors) may feed legacy LL comp_driver components (e.g. KPB or a WoV arbiter) that do not populate their input buffer audio_stream_params at bind time. During the IPC4 INIT -> PREPARE state transition, module_adapter_calculate_dp_period() queries sink frame_bytes and rate, hitting a zero rate / divide-by-zero or missing period calculation if params remain unset. Before calculating the DP period in module_adapter_prepare(), propagate mod->stream_params to any sink buffer whose audio_stream rate is still zero. Signed-off-by: Peter Ujfalusi Signed-off-by: Liam Girdwood --- src/audio/module_adapter/module_adapter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 59c44f7e5608..4c4fc5fff6cb 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -493,6 +493,12 @@ int module_adapter_prepare(struct comp_dev *dev) * Second example is a module with variable data rate on output (like MPEG encoder) */ if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) { + /* legacy comp_driver consumers don't set their input buffer params at bind */ + comp_dev_for_each_consumer(dev, sink) { + if (!audio_stream_get_rate(&sink->stream) && mod->stream_params) + buffer_set_params(sink, mod->stream_params, BUFFER_UPDATE_FORCE); + } + /* calculate DP period if a module didn't */ if (!dev->period) module_adapter_calculate_dp_period(dev); From f92a5bfc25d1862f756bf79f19875ef7bd099db7 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 06/16] audio: module_adapter: skip virtual detect sinks in DP period calculation In WoV multi-detector pipelines, keyword detectors (such as microWakeWord) can have an active dummy/virtual detect sink connected only for graph/route completeness while reporting detection events over IPC/notifier rather than producing an audio stream (frame_bytes == 0 or rate == 0). During the IPC4 INIT -> PREPARE -> ACTIVE pipeline state transition, module_adapter_prepare() invokes module_adapter_calculate_dp_period() on every connected sink. Without skipping sinks that carry no audio format, (frame_bytes * rate) evaluates to zero and causes a divide-by-zero fault before the WoV pipeline can enter COMP_STATE_PREPARE / COMP_STATE_ACTIVE. Skipping non-audio sinks lets the existing source/module period fallback complete pipeline preparation cleanly. Signed-off-by: Seppo Ingalsuo Signed-off-by: Liam Girdwood --- src/audio/module_adapter/module_adapter.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 4c4fc5fff6cb..a5112bca75ec 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -422,12 +422,21 @@ static void module_adapter_calculate_dp_period(struct comp_dev *dev) unsigned int period = UINT32_MAX; for (int i = 0; i < mod->num_of_sinks; i++) { + unsigned int frame_bytes = sink_get_frame_bytes(mod->sinks[i]); + unsigned int rate = sink_get_rate(mod->sinks[i]); + + /* Skip virtual/event-only detect sinks with no audio format so WoV + * pipelines prepare without dividing by zero (period comes from + * source or dev->period during INIT -> PREPARE). + */ + if (!frame_bytes || !rate) + continue; + /* calculate time required the module to provide OBS data portion - a period * use 64bit integers to avoid overflows */ unsigned int sink_period = 1000000ULL * sink_get_min_free_space(mod->sinks[i]) / - (sink_get_frame_bytes(mod->sinks[i]) * - sink_get_rate(mod->sinks[i])); + (frame_bytes * rate); /* note the minimal period for the module */ if (period > sink_period) period = sink_period; From d6a84361de70bfe8f6b548253bd4bdad4cd9d8a1 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 07/16] zephyr: edf_schedule: cancel delayed work in schedule_edf_task_free() Cancel any pending z_delayed_work when freeing an EDF scheduler task to prevent a queued delayed work callback from firing on a cleared task during pipeline teardown. Signed-off-by: Liam Girdwood --- zephyr/edf_schedule.c | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/edf_schedule.c b/zephyr/edf_schedule.c index 3578b3dd6c7d..005c70196832 100644 --- a/zephyr/edf_schedule.c +++ b/zephyr/edf_schedule.c @@ -87,6 +87,7 @@ static int schedule_edf_task_running(void *data, struct task *task) static int schedule_edf_task_free(void *data, struct task *task) { + k_work_cancel_delayable(&task->z_delayed_work); task->state = SOF_TASK_STATE_FREE; task->ops.run = NULL; task->data = NULL; From 792377dd112ee6997767d73d2da4c25626633af2 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 08/16] audio: pipeline: log comp_prepare failure and export pipeline_schedule_cancel() Log the failing component ID in pipeline_comp_prepare() when prepare fails, guard NULL pipe_task pointers in pipeline_schedule_copy() and pipeline_schedule_cancel(), and export pipeline_schedule_cancel() for synchronous hostless pipeline state transitions. Signed-off-by: Liam Girdwood --- src/audio/pipeline/pipeline-params.c | 7 ++++++- src/audio/pipeline/pipeline-schedule.c | 7 ++++--- src/include/sof/audio/pipeline.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/audio/pipeline/pipeline-params.c b/src/audio/pipeline/pipeline-params.c index 8a2166b19769..1e40a16174a3 100644 --- a/src/audio/pipeline/pipeline-params.c +++ b/src/audio/pipeline/pipeline-params.c @@ -285,8 +285,13 @@ static int pipeline_comp_prepare(struct comp_dev *current, return err; err = comp_prepare(current); - if (err < 0 || err == PPL_STATUS_PATH_STOP) + if (err < 0 || err == PPL_STATUS_PATH_STOP) { + if (err < 0) { + pipe_err(current->pipeline, "comp_prepare for comp 0x%x failed %d", + dev_comp_id(current), err); + } return err; + } return pipeline_for_each_comp(current, ctx, dir); } diff --git a/src/audio/pipeline/pipeline-schedule.c b/src/audio/pipeline/pipeline-schedule.c index 63b9fd979088..f4d60bbe2a42 100644 --- a/src/audio/pipeline/pipeline-schedule.c +++ b/src/audio/pipeline/pipeline-schedule.c @@ -56,9 +56,10 @@ SOF_DEFINE_REG_UUID(dp_task); #endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ -static void pipeline_schedule_cancel(struct pipeline *p) +void pipeline_schedule_cancel(struct pipeline *p) { - schedule_task_cancel(p->pipe_task); + if (p->pipe_task) + schedule_task_cancel(p->pipe_task); /* enable system agent panic, when there are no longer * DMA driven pipelines @@ -655,7 +656,7 @@ void pipeline_schedule_copy(struct pipeline *p, uint64_t start) * when we attempt to start B, we don't need to schedule pipeline C - * it's already running. */ - if (task_is_active(p->pipe_task)) + if (!p->pipe_task || task_is_active(p->pipe_task)) return; if (p->sched_next && task_is_active(p->sched_next->pipe_task)) diff --git a/src/include/sof/audio/pipeline.h b/src/include/sof/audio/pipeline.h index 9409eaec0236..4068845b61e7 100644 --- a/src/include/sof/audio/pipeline.h +++ b/src/include/sof/audio/pipeline.h @@ -421,6 +421,7 @@ int pipeline_comp_dp_task_init(struct comp_dev *comp); * \param[in] start Pipeline start time in microseconds. */ void pipeline_schedule_copy(struct pipeline *p, uint64_t start); +void pipeline_schedule_cancel(struct pipeline *p); /** * \brief Triggers pipeline's scheduling component. From 73af4bb44ef12c59af60f0ad607a23f8b57ec8bb Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 09/16] ipc4: handler: support hostless pipelines and COMP_STATE_PREPARE Support internal/hostless WoV processing pipelines that lack a host or DAI endpoint copier by executing trigger/reset transitions synchronously when !pipeline_is_endpoint(), and handle COMP_STATE_PREPARE and COMP_STATE_SUSPEND transitions in ipc4_pipeline_prepare() and ipc4_pipeline_trigger(). Signed-off-by: Liam Girdwood --- src/ipc/ipc4/handler-user.c | 160 ++++++++++++++++++++++++++++++++---- 1 file changed, 142 insertions(+), 18 deletions(-) diff --git a/src/ipc/ipc4/handler-user.c b/src/ipc/ipc4/handler-user.c index cf5d4bb84df2..c013a9432cce 100644 --- a/src/ipc/ipc4/handler-user.c +++ b/src/ipc/ipc4/handler-user.c @@ -115,16 +115,41 @@ static int ipc4_pcm_params(struct ipc_comp_dev *pcm_dev) return err; } +static struct comp_dev *pipeline_get_endpoint_comp(struct ipc_comp_dev *ppl_icd) +{ + if (!ppl_icd || !ppl_icd->pipeline) + return NULL; + + struct pipeline *p = ppl_icd->pipeline; + + if (p->source_comp && p->source_comp->direction == SOF_IPC_STREAM_PLAYBACK) + return p->source_comp; + + if (p->sink_comp) + return p->sink_comp; + + return p->source_comp; +} + +static bool pipeline_is_endpoint(struct pipeline *p) +{ + return (p->source_comp && (dev_comp_type(p->source_comp) == SOF_COMP_HOST || + dev_comp_type(p->source_comp) == SOF_COMP_DAI)) || + (p->sink_comp && (dev_comp_type(p->sink_comp) == SOF_COMP_HOST || + dev_comp_type(p->sink_comp) == SOF_COMP_DAI)); +} + static struct ipc_comp_dev *pipeline_get_host_dev(struct ipc_comp_dev *ppl_icd) { struct ipc_comp_dev *host_dev; struct ipc *ipc = ipc_get(); int host_id; - if (!ppl_icd->pipeline->source_comp || !ppl_icd->pipeline->sink_comp) { - ipc_cmd_err(&ipc_tr, "pipeline %d: source/sink comp freed", ppl_icd->id); + if (!ppl_icd || !ppl_icd->pipeline) + return NULL; + + if (!ppl_icd->pipeline->source_comp || !ppl_icd->pipeline->sink_comp) return NULL; - } /* If the source component's direction is not set but the sink's direction is, * this block will copy the direction from the sink to the source component and @@ -154,8 +179,8 @@ static struct ipc_comp_dev *pipeline_get_host_dev(struct ipc_comp_dev *ppl_icd) host_id = ppl_icd->pipeline->sink_comp->ipc_config.id; host_dev = ipc_get_comp_by_id(ipc, host_id); - if (!host_dev) - ipc_cmd_err(&ipc_tr, "comp host with ID %d not found", host_id); + if (!host_dev || dev_comp_type(host_dev->cd) != SOF_COMP_HOST) + return NULL; return host_dev; } @@ -210,20 +235,57 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) /* init params when pipeline is complete or reset */ switch (status) { + case COMP_STATE_INIT: + tr_dbg(&ipc_tr, "pipeline %d: running from init", ppl_icd->id); + ret = ipc4_pipeline_complete(ipc, ppl_icd->id, cmd); + if (ret < 0) + return IPC4_INVALID_REQUEST; + host = pipeline_get_host_dev(ppl_icd); + if (host) { + ret = ipc4_pcm_params(host); + if (ret < 0) + tr_err(&ipc_tr, "pipeline %d: ipc4_pcm_params failed %d", ppl_icd->id, ret); + } else { + struct comp_dev *cd = pipeline_get_endpoint_comp(ppl_icd); + + if (cd && cd->pipeline) { + ret = pipeline_prepare(cd->pipeline, cd); + if (ret < 0) + tr_err(&ipc_tr, "pipeline %d: prepare failed %d", ppl_icd->id, ret); + else + ret = 0; + } + } + break; case COMP_STATE_ACTIVE: case COMP_STATE_PAUSED: + case COMP_STATE_PREPARE: + case COMP_STATE_PRE_ACTIVE: + case COMP_STATE_SUSPEND: /* No action needed */ break; case COMP_STATE_READY: host = pipeline_get_host_dev(ppl_icd); - if (!host) - return IPC4_INVALID_RESOURCE_ID; - - tr_dbg(&ipc_tr, "pipeline %d: set params", ppl_icd->id); - ret = ipc4_pcm_params(host); + if (host) { + tr_info(&ipc_tr, "pipeline %d: set params host comp 0x%x", ppl_icd->id, host->id); + ret = ipc4_pcm_params(host); + if (ret < 0) { + tr_err(&ipc_tr, "pipeline %d: ipc4_pcm_params failed %d", ppl_icd->id, ret); + } + } else { + struct comp_dev *cd = pipeline_get_endpoint_comp(ppl_icd); + + if (cd && cd->pipeline) { + ret = pipeline_prepare(cd->pipeline, cd); + if (ret < 0) + tr_err(&ipc_tr, "pipeline %d: prepare failed %d", ppl_icd->id, ret); + else + ret = 0; + } + } break; default: - ipc_cmd_err(&ipc_tr, + tr_err(&ipc_tr, "pipeline %d: Invalid state for RUNNING: %d", ppl_icd->id, status); return IPC4_INVALID_REQUEST; @@ -238,6 +300,9 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) case COMP_STATE_READY: case COMP_STATE_ACTIVE: case COMP_STATE_PAUSED: + case COMP_STATE_PREPARE: + case COMP_STATE_PRE_ACTIVE: + case COMP_STATE_SUSPEND: /* No action needed */ break; default: @@ -282,12 +347,13 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) pipeline_set_eos(ppl_icd->pipeline, false); - return ret; + return 0; } int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *delayed) { struct ipc_comp_dev *host; + struct comp_dev *trigger_cd = NULL; int status; int ret; @@ -298,19 +364,24 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela if (status == COMP_STATE_INIT) return 0; - host = pipeline_get_host_dev(ppl_icd); - if (!host) + trigger_cd = pipeline_get_endpoint_comp(ppl_icd); + if (!trigger_cd) return IPC4_INVALID_RESOURCE_ID; + host = pipeline_get_host_dev(ppl_icd); + switch (cmd) { case SOF_IPC4_PIPELINE_STATE_RUNNING: /* init params when pipeline is complete or reset */ switch (status) { case COMP_STATE_ACTIVE: + case COMP_STATE_PRE_ACTIVE: /* nothing to do if the pipeline is already running */ return 0; + case COMP_STATE_INIT: case COMP_STATE_READY: case COMP_STATE_PREPARE: + case COMP_STATE_SUSPEND: cmd = COMP_TRIGGER_PRE_START; break; case COMP_STATE_PAUSED: @@ -327,6 +398,9 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela switch (status) { case COMP_STATE_ACTIVE: case COMP_STATE_PAUSED: + case COMP_STATE_PREPARE: + case COMP_STATE_PRE_ACTIVE: + case COMP_STATE_SUSPEND: cmd = COMP_TRIGGER_STOP; break; default: @@ -338,6 +412,7 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela case COMP_STATE_INIT: case COMP_STATE_READY: case COMP_STATE_PAUSED: + case COMP_STATE_SUSPEND: return 0; default: cmd = COMP_TRIGGER_PAUSE; @@ -363,8 +438,51 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela */ dbg_path_hot_confirm(); - /* trigger the component */ - ret = pipeline_trigger(host->cd->pipeline, host->cd, cmd); + bool is_endpoint = pipeline_is_endpoint(trigger_cd->pipeline); + + if (!is_endpoint) { + /* + * Hostless internal pipelines (e.g. background keyword detection or internal + * processing chains feeding arbiters or modules without a host or DAI copier) + * have no host DMA or DAI hardware to delay IPC replies. + * Execute the trigger and reset synchronously inline. + */ + ret = pipeline_trigger_run(trigger_cd->pipeline, trigger_cd, cmd); + if (ret < 0) { + ipc_cmd_err(&ipc_tr, "pipeline %d: trigger cmd %d failed with: %d", + ppl_icd->id, cmd, ret); + return IPC4_PIPELINE_STATE_NOT_SET; + } + + switch (cmd) { + case COMP_TRIGGER_PRE_START: + case COMP_TRIGGER_START: + case COMP_TRIGGER_PRE_RELEASE: + case COMP_TRIGGER_RELEASE: + trigger_cd->pipeline->status = COMP_STATE_ACTIVE; + pipeline_schedule_copy(trigger_cd->pipeline, 0); + break; + case COMP_TRIGGER_PAUSE: + pipeline_schedule_cancel(trigger_cd->pipeline); + trigger_cd->pipeline->status = COMP_STATE_PAUSED; + break; + case COMP_TRIGGER_STOP: + pipeline_schedule_cancel(trigger_cd->pipeline); + trigger_cd->pipeline->status = COMP_STATE_READY; + ret = pipeline_reset(trigger_cd->pipeline, trigger_cd); + if (ret < 0 && ret != PPL_STATUS_PATH_STOP) + return IPC4_INVALID_REQUEST; + break; + default: + break; + } + + *delayed = false; + return 0; + } + + /* trigger the endpoint component (host or DAI) */ + ret = pipeline_trigger(trigger_cd->pipeline, trigger_cd, cmd); if (ret < 0) { ipc_cmd_err(&ipc_tr, "pipeline %d: trigger cmd %d failed with: %d", ppl_icd->id, cmd, ret); @@ -381,9 +499,15 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela * Otherwise, the pipeline will be reset after the STOP trigger * has finished executing in the pipeline task. */ - ret = pipeline_reset(host->cd->pipeline, host->cd); - if (ret < 0) + struct comp_dev *reset_cd = host ? host->cd : trigger_cd; + + ret = pipeline_reset(reset_cd->pipeline, reset_cd); + if (ret < 0 && ret != PPL_STATUS_PATH_STOP) ret = IPC4_INVALID_REQUEST; + else + ret = 0; + } else { + ret = 0; } return ret; From 5b03191faac1a51bc171d2a5841d36228052517f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 10/16] lib, audio: add NULL guards during DAI, DMA, and copier teardown Guard NULL pointers in dai_put(), sof_dma_put(), dai_common_free(), dai_free(), and copier_dai_free(), and clear released buffer/DAI/DMA pointers after freeing to prevent double-free or NULL dereference on partial pipeline teardown. Signed-off-by: Liam Girdwood --- src/audio/copier/copier_dai.c | 16 ++++++++++++---- src/audio/dai-zephyr.c | 27 +++++++++++++++++++++++---- src/kernel/lib/dai-kernel.c | 6 ++++++ src/kernel/lib/dma-kernel.c | 3 +++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/audio/copier/copier_dai.c b/src/audio/copier/copier_dai.c index 508972b4773c..a4c88554c4a6 100644 --- a/src/audio/copier/copier_dai.c +++ b/src/audio/copier/copier_dai.c @@ -424,13 +424,21 @@ __cold void copier_dai_free(struct processing_module *mod) assert_can_be_cold(); for (int i = 0; i < cd->endpoint_num; i++) { - dai_common_free(cd->dd[i]); - mod_free(mod, cd->dd[i]->gain_data); - mod_free(mod, cd->dd[i]); + if (cd->dd[i]) { + if (cd->dd[i]->gain_data) { + mod_free(mod, cd->dd[i]->gain_data); + cd->dd[i]->gain_data = NULL; + } + dai_common_free(cd->dd[i]); + mod_free(mod, cd->dd[i]); + cd->dd[i] = NULL; + } } /* only dai have multi endpoint case */ - if (cd->multi_endpoint_buffer) + if (cd->multi_endpoint_buffer) { buffer_free(cd->multi_endpoint_buffer); + cd->multi_endpoint_buffer = NULL; + } } int copier_dai_prepare(struct comp_dev *dev, struct copier_data *cd) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 2cbdfe998a2c..197bc73e4e21 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -794,22 +794,36 @@ __cold void dai_common_free(struct dai_data *dd) { assert_can_be_cold(); + if (!dd) + return; + #ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS io_perf_monitor_release_slot(dd->io_perf_dai_byte_count); #endif telemetry_unregister_dai(dd); - if (dd->group) + if (dd->group) { dai_group_put(dd->group); + dd->group = NULL; + } dai_dma_release_channel(dd); - sof_dma_put(dd->dma); + if (dd->dma) { + sof_dma_put(dd->dma); + dd->dma = NULL; + } dai_release_llp_slot(dd); - dai_put(dd->dai); + if (dd->dai) { + dai_put(dd->dai); + dd->dai = NULL; + } - sof_heap_free(dd->alloc_ctx.heap, dd->dai_spec_config); + if (dd->dai_spec_config) { + sof_heap_free(dd->alloc_ctx.heap, dd->dai_spec_config); + dd->dai_spec_config = NULL; + } #if CONFIG_UAOL_INTEL_ADSP uaol_free(dd); @@ -822,6 +836,11 @@ __cold static void dai_free(struct comp_dev *dev) assert_can_be_cold(); + if (!dd) { + comp_free_device(dev); + return; + } + if (dd->group) notifier_unregister(dev, dd->group, NOTIFIER_ID_DAI_TRIGGER); diff --git a/src/kernel/lib/dai-kernel.c b/src/kernel/lib/dai-kernel.c index e12cabe8141e..cc1711aee0fe 100644 --- a/src/kernel/lib/dai-kernel.c +++ b/src/kernel/lib/dai-kernel.c @@ -263,6 +263,9 @@ __cold void dai_put(struct dai *dai) assert_can_be_cold(); + if (!dai) + return; + #ifdef CONFIG_SOF_USERSPACE_LL heap = zephyr_ll_user_heap(); #endif @@ -335,6 +338,9 @@ __cold void dai_put(struct dai *dai) assert_can_be_cold(); + if (!dai) + return; + key = k_spin_lock(&dai->lock); if (--dai->sref == 0) { ret = dai_remove(dai); diff --git a/src/kernel/lib/dma-kernel.c b/src/kernel/lib/dma-kernel.c index 32e76a433395..03270c20e698 100644 --- a/src/kernel/lib/dma-kernel.c +++ b/src/kernel/lib/dma-kernel.c @@ -178,6 +178,9 @@ __cold void z_impl_sof_dma_put(struct sof_dma *dma) assert_can_be_cold(); + if (!dma) + return; + key = k_spin_lock(dma_lock(dma)); if (*dma_sref(dma) <= 0) { tr_err(&dma_tr, "dma_put(), dma = %p not in use", dma); From 0f964d360b8a1499e1d21cccbce264b2c4e5b013 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 11/16] ipc: ipc-helper: reset component before freeing if not in ready state Stop active components and reset non-ready components in ipc_comp_free() so dynamically torn down modules release DMA/DAI and memory resources cleanly before freeing. Signed-off-by: Liam Girdwood --- src/ipc/ipc-helper.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index c8e82587edf7..9e0514c6d651 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -316,7 +316,14 @@ __cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id) if (!cpu_is_me(icd->core)) return ipc_process_on_core(icd->core, false); - /* check state */ + /* check state: if not ready, stop and reset to release resources before freeing */ + if (icd->cd->state != COMP_STATE_READY) { + if (icd->cd->state == COMP_STATE_ACTIVE) + comp_trigger(icd->cd, COMP_TRIGGER_STOP); + comp_reset(icd->cd); + comp_set_state(icd->cd, COMP_TRIGGER_RESET); + } + if (icd->cd->state != COMP_STATE_READY) { tr_err(&ipc_tr, "comp id: 0x%x state is %d cannot be freed", comp_id, icd->cd->state); From 9b0f3a6a5cb9d5e3a407c7cccf4e6dacbdd13a05 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 12/16] lib: notifier: wait for completion of remote core notifications Use IDC_BLOCKING in notifier_event() so back-to-back cross-core notifications to the same remote core cannot reuse a queued IDC work item and overwrite notify_data before delivery. Signed-off-by: Seppo Ingalsuo Signed-off-by: Liam Girdwood --- src/lib/notifier.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/notifier.c b/src/lib/notifier.c index cbc9ff5cd7f8..c6e5a08b45cb 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -172,7 +172,10 @@ void notifier_event(const void *caller, enum notify_id type, uint32_t core_mask, dcache_writeback_region((__sparse_force void __sparse_cache *) notify_data->data, data_size); - idc_send_msg(¬ify_msg, IDC_NON_BLOCKING); + /* Wait for completion: back-to-back events to the same core would + * otherwise reuse a queued IDC work item and overwrite notify_data. + */ + idc_send_msg(¬ify_msg, IDC_BLOCKING); } } } From 44d7281ad160a190baed24516fa12e0ec168bfa9 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 13/16] lib: agent: guard against NULL system agent in sa_set_panic_on_delay() Return early in sa_set_panic_on_delay() if sof_get()->sa is NULL when pipelines change state before system agent initialization completes. Signed-off-by: Seppo Ingalsuo Signed-off-by: Liam Girdwood --- src/include/sof/lib/agent.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/include/sof/lib/agent.h b/src/include/sof/lib/agent.h index 6aaa740761f2..793181eaf624 100644 --- a/src/include/sof/lib/agent.h +++ b/src/include/sof/lib/agent.h @@ -42,6 +42,9 @@ static inline void sa_set_panic_on_delay(bool enabled) { struct sa *sa = sof_get()->sa; + if (!sa) + return; + if (enabled) atomic_add(&sa->panic_cnt, 1); else From 6713c7ec91481f433301f3908624e7accce0c5eb Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 14/16] audio: host-zephyr: increase minimum no-bytes warning interval Increase SOF_MIN_NO_BYTES_INTERVAL_MS from 20 ms to 1000 ms to prevent XRUN warning bursts from flooding the trace buffer during steady-state or WoV transitions. Signed-off-by: Seppo Ingalsuo Signed-off-by: Liam Girdwood --- src/audio/host-zephyr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index de55b8d073ac..238e3d4bd09a 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -415,7 +415,7 @@ static int host_get_status(struct comp_dev *dev, struct host_data *hd, struct dm } /* Minimum time between 2 consecutive "no bytes to copy" messages in milliseconds */ -#define SOF_MIN_NO_BYTES_INTERVAL_MS 20 +#define SOF_MIN_NO_BYTES_INTERVAL_MS 1000 static inline bool host_handle_eos(struct host_data *hd, struct comp_dev *dev, uint32_t avail_samples) From 1b955da2facadf5fa6efe5488922bcf6ed69779f Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 15/16] audio: intel_uaol: only advertise UAOL links that answered Count only UAOL links whose uaol_get_capabilities() call succeeded, pack link_caps[] from index 0, and size the returned TLV to match instead of advertising unresponsive links with zeroed capabilities. Signed-off-by: Peter Ujfalusi Signed-off-by: Liam Girdwood --- src/kernel/audio/intel_uaol-kernel.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/kernel/audio/intel_uaol-kernel.c b/src/kernel/audio/intel_uaol-kernel.c index 788bf49893ec..99aa2942d93d 100644 --- a/src/kernel/audio/intel_uaol-kernel.c +++ b/src/kernel/audio/intel_uaol-kernel.c @@ -37,6 +37,7 @@ __cold void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type) struct uaol_capabilities dev_cap; struct ipc4_uaol_capabilities *caps = (struct ipc4_uaol_capabilities *)tuple->value; size_t caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[dev_count]); + size_t link_count = 0; size_t i; int ret; @@ -44,19 +45,27 @@ __cold void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type) memset(caps, 0, caps_size); - caps->link_count = dev_count; + /* Only advertise links that answered. uaol_get_capabilities() fails when + * the host has not offloaded link control to the DSP (UAOLCTL.OFLEN), in + * which case the link's segment registers are not readable here. + */ for (i = 0; i < dev_count; i++) { ret = uaol_get_capabilities(uaol_devs[i], &dev_cap); if (ret) continue; - caps->link_caps[i].input_streams_supported = dev_cap.input_streams; - caps->link_caps[i].output_streams_supported = dev_cap.output_streams; - caps->link_caps[i].bidirectional_streams_supported = dev_cap.bidirectional_streams; - caps->link_caps[i].max_tx_fifo_size = dev_cap.max_tx_fifo_size; - caps->link_caps[i].max_rx_fifo_size = dev_cap.max_rx_fifo_size; + caps->link_caps[link_count].input_streams_supported = dev_cap.input_streams; + caps->link_caps[link_count].output_streams_supported = dev_cap.output_streams; + caps->link_caps[link_count].bidirectional_streams_supported = + dev_cap.bidirectional_streams; + caps->link_caps[link_count].max_tx_fifo_size = dev_cap.max_tx_fifo_size; + caps->link_caps[link_count].max_rx_fifo_size = dev_cap.max_rx_fifo_size; + link_count++; } + caps->link_count = link_count; + caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[link_count]); + tlv_value_set(tuple, type, caps_size, caps); } #endif /* !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY */ From bee305611bc106a5469b348791be32d25370f375 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 22 Nov 2026 18:01:54 +0000 Subject: [PATCH 16/16] sof_ri_info: add PTL Intel debug signing key Recognize the PTL Intel debug signing key in sof_ri_info.py. Signed-off-by: Liam Girdwood --- tools/sof_ri_info/sof_ri_info.py | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index 3b09ffb1ec40..25141a666ace 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -738,6 +738,56 @@ 0x63, 0x04, 0xaf, 0x24, 0x45, 0x87, 0xf4, 0x96, 0x55, 0xd1, 0x7d, 0xc6, 0x0d, 0x79, 0x12, 0xa9]) +PTL_INTEL_DEBUG_KEY = bytes([ + 0x65, 0x24, 0xe8, 0x0a, 0x41, 0xc8, 0xed, 0xa2, + 0x92, 0x59, 0x20, 0x13, 0x3f, 0xcd, 0x11, 0x8b, + 0x7e, 0xdb, 0x8d, 0xf5, 0x69, 0xd9, 0x36, 0x2c, + 0x6c, 0x34, 0xba, 0xec, 0xce, 0x3e, 0xcb, 0xaa, + 0x52, 0x58, 0xef, 0x6b, 0x92, 0xe7, 0x8f, 0x8b, + 0x36, 0x8b, 0xa0, 0xc4, 0x61, 0x62, 0x13, 0x8c, + 0xcc, 0x2a, 0x75, 0xab, 0x59, 0xab, 0xf0, 0xf1, + 0x28, 0xd7, 0xdc, 0x42, 0xa8, 0xb1, 0xa0, 0x1f, + 0x95, 0x02, 0xaa, 0x30, 0x41, 0xe3, 0x9d, 0xf5, + 0x0c, 0x74, 0x3b, 0x72, 0x22, 0x98, 0x45, 0x50, + 0xec, 0x09, 0x04, 0x45, 0x22, 0x62, 0xc1, 0xce, + 0xb6, 0x4d, 0x1b, 0xac, 0xe2, 0xa2, 0xf1, 0x62, + 0x25, 0x60, 0xc0, 0x12, 0x08, 0x7a, 0x4e, 0x11, + 0x18, 0x81, 0xc8, 0xf6, 0xfa, 0xb0, 0x76, 0x7e, + 0xeb, 0x1c, 0xc3, 0x00, 0xf3, 0x1d, 0x5e, 0xc3, + 0x9c, 0x89, 0x74, 0xad, 0x17, 0xa8, 0x0a, 0x7e, + 0x33, 0xa4, 0x46, 0x1d, 0xcd, 0xac, 0xe2, 0xb2, + 0x34, 0xc2, 0x53, 0x03, 0x72, 0x18, 0x49, 0x22, + 0x9f, 0x51, 0xac, 0x65, 0x79, 0xf7, 0x02, 0x0f, + 0xea, 0xfd, 0x33, 0x5f, 0x3c, 0x7a, 0x0e, 0xd0, + 0x71, 0x85, 0x76, 0xcd, 0x7e, 0x3e, 0x85, 0xa4, + 0xc9, 0x88, 0x7d, 0xb8, 0x68, 0x00, 0xe1, 0x49, + 0xc4, 0x4f, 0xe7, 0xf4, 0x19, 0x1a, 0x88, 0xa2, + 0x89, 0xaa, 0xcc, 0xd6, 0xdd, 0x99, 0xfb, 0x54, + 0x89, 0x14, 0xe7, 0xc5, 0x4b, 0x43, 0x35, 0x50, + 0x77, 0xc8, 0xd6, 0x45, 0xd6, 0x09, 0xae, 0x31, + 0xa7, 0x30, 0x0b, 0xfa, 0xa5, 0x5d, 0xc0, 0x88, + 0x80, 0x50, 0xa5, 0x7f, 0x7c, 0xd7, 0xf6, 0x19, + 0x11, 0x49, 0xb1, 0x31, 0x6b, 0x23, 0x03, 0x82, + 0x6b, 0x42, 0x3a, 0x91, 0xd7, 0x86, 0x13, 0xa1, + 0xf0, 0x09, 0x95, 0xa4, 0xd1, 0xac, 0xd6, 0x3e, + 0xb3, 0x48, 0xe0, 0xc8, 0xdb, 0x4e, 0x91, 0xcb, + 0x1f, 0xd0, 0x5d, 0xec, 0x09, 0xb8, 0x5e, 0x8b, + 0xeb, 0x74, 0xf0, 0x2e, 0xa0, 0x98, 0x2c, 0x06, + 0x35, 0x85, 0xec, 0x6f, 0x8f, 0xfa, 0xb8, 0x0c, + 0x2a, 0x47, 0xc5, 0x4d, 0x15, 0xea, 0x7c, 0x04, + 0x96, 0x21, 0x41, 0x38, 0x1e, 0x3f, 0x7c, 0x96, + 0x61, 0x12, 0x5d, 0x50, 0x90, 0x18, 0x5e, 0xe6, + 0xd2, 0x30, 0x53, 0xdb, 0xc3, 0x0f, 0xef, 0x28, + 0xf6, 0x6f, 0xaf, 0x03, 0xc0, 0xca, 0x6b, 0x3b, + 0x4f, 0xa8, 0x82, 0xae, 0x4e, 0x0f, 0x9b, 0x08, + 0x8d, 0x8f, 0x43, 0xed, 0x48, 0x8e, 0xe6, 0xa1, + 0x7e, 0xb3, 0x2e, 0x37, 0x2e, 0x48, 0x95, 0xd4, + 0x1d, 0xa6, 0xfe, 0x22, 0x9f, 0x9a, 0x02, 0xa9, + 0xd9, 0xfc, 0x23, 0x71, 0x02, 0x48, 0x24, 0x6b, + 0xe7, 0xc1, 0x6c, 0x20, 0x9f, 0xdf, 0x8d, 0xc1, + 0x65, 0xe4, 0x34, 0xc3, 0x02, 0x33, 0x29, 0xe9, + 0x30, 0x32, 0xd1, 0x2f, 0xc4, 0xfd, 0x61, 0xca]) + KNOWN_KEYS = {APL_INTEL_PROD_KEY : 'APL Intel prod key', CNL_INTEL_PROD_KEY : 'CNL Intel prod key', ICL_INTEL_PROD_KEY : 'ICL Intel prod key', @@ -750,6 +800,7 @@ LNL_INTEL_PROD_KEY : 'LNL Intel prod key', ARL_S_INTEL_PROD_KEY : 'ARL-S Intel prod key', PTL_INTEL_PROD_KEY : 'PTL Intel prod key', + PTL_INTEL_DEBUG_KEY : 'PTL Intel debug key', NVL_INTEL_PROD_KEY : 'NVL Intel prod key', NVL_S_INTEL_PROD_KEY : 'NVL-S Intel prod key', COMMUNITY_KEY : 'Community key',