Skip to content

Commit 09e7a8f

Browse files
committed
llext: fix failures with short-lived pipelines
When speaker-test stops, it once again creates and immediately destroys pipelines. This leads to failures with LLEXT. Add a minimum pipeline life time for such cases. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 4972c32 commit 09e7a8f

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ CONFIG_DMA_DW_LLI_POOL_SIZE=50
4141
CONFIG_INTEL_MODULES=y
4242
CONFIG_LIBRARY_MANAGER=y
4343
CONFIG_LIBRARY_AUTH_SUPPORT=y
44+
CONFIG_LIBRARY_PIPELINE_FORCE_MIN_LIFETIME=100
4445
CONFIG_INTEL_ADSP_TIMER=y
4546
CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
4647
CONFIG_AMS=y

src/audio/pipeline/pipeline-graph.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <rtos/interrupt.h>
1313
#include <sof/lib/mm_heap.h>
1414
#include <sof/lib/uuid.h>
15+
#include <sof/llext_manager.h>
1516
#include <sof/compiler_attributes.h>
1617
#include <sof/list.h>
1718
#include <rtos/spinlock.h>
@@ -260,6 +261,11 @@ static int pipeline_comp_complete(struct comp_dev *current,
260261

261262
/* complete component init */
262263
current->pipeline = ppl_data->p;
264+
265+
if (comp_is_llext(current))
266+
/* pipelines are allocated using rzalloc(), so initially .init_time = 0 */
267+
current->pipeline->init_time = sof_cycle_get_64();
268+
263269
/* LL module has its period always eq period of the pipeline
264270
* DP period is set to 0 as sink format may not yet been set
265271
* It will be calculated during module prepare operation

src/include/sof/audio/pipeline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct pipeline {
9494
bool aborted; /* STOP or PAUSE failed, stay active */
9595
bool pending; /* trigger scheduled but not executed yet */
9696
} trigger;
97+
uint64_t init_time;
9798
};
9899

99100
struct pipeline_walk_context {

src/ipc/ipc4/helper.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ static int ipc_pipeline_module_free(uint32_t pipeline_id)
331331
int ipc_pipeline_free(struct ipc *ipc, uint32_t comp_id)
332332
{
333333
struct ipc_comp_dev *ipc_pipe;
334+
uint64_t life_time;
334335
int ret;
335336

336337
/* check whether pipeline exists */
@@ -342,6 +343,17 @@ int ipc_pipeline_free(struct ipc *ipc, uint32_t comp_id)
342343
if (!cpu_is_me(ipc_pipe->core))
343344
return ipc4_process_on_core(ipc_pipe->core, false);
344345

346+
if (ipc_pipe->pipeline->init_time) {
347+
/*
348+
* This pipeline must not be destroyed before a minimum time
349+
* since its creation has passed
350+
*/
351+
life_time = k_cyc_to_ms_near64(sof_cycle_get_64() - ipc_pipe->pipeline->init_time);
352+
pipe_dbg(ipc_pipe->pipeline, "Extend pipeline life beyond %llu", life_time);
353+
if (life_time < CONFIG_LIBRARY_PIPELINE_FORCE_MIN_LIFETIME)
354+
k_msleep(CONFIG_LIBRARY_PIPELINE_FORCE_MIN_LIFETIME - life_time);
355+
}
356+
345357
ret = ipc_pipeline_module_free(ipc_pipe->pipeline->pipeline_id);
346358
if (ret != IPC4_SUCCESS) {
347359
tr_err(&ipc_tr, "ipc_pipeline_free(): module free () failed");

src/library_manager/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,15 @@ config LIBRARY_AUTH_SUPPORT
3333
could be used if enabled.
3434
If unsure say N.
3535

36+
config LIBRARY_PIPELINE_FORCE_MIN_LIFETIME
37+
int "Minimum pipeline life-time in ms"
38+
default 0
39+
range 0 500
40+
help
41+
Typically pipelines are created for streaming, which lasts for
42+
considerable time, at least seconds. But in some test-cases pipelines
43+
are created and quickly destroyed again with no streaming at all. In
44+
some configurations this leads to failures. This option allows setting
45+
a minimum pipeline life-time, which fixes those scenarios.
46+
3647
endmenu

0 commit comments

Comments
 (0)