From 4b54a3879bf0f02c658bce3baa909845017d21eb Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 26 Jun 2024 10:18:43 +0200 Subject: [PATCH] kcps: fix 0 module CPC case If a module contains 0 as its CPC value, the consumption calculation routine will assign a "safe" maximum value to keep the DSP running at the maximum clock rate. This works when constructing a pipeline, but when a pipeline is torn down, returning the maximum clock rate leads to the clock being to 0 Hz. Fix this by detecting such cases in pipeline termination code. Signed-off-by: Guennadi Liakhovetski --- src/audio/pipeline/pipeline-stream.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/audio/pipeline/pipeline-stream.c b/src/audio/pipeline/pipeline-stream.c index 7077f5e30251..393949d647bb 100644 --- a/src/audio/pipeline/pipeline-stream.c +++ b/src/audio/pipeline/pipeline-stream.c @@ -349,6 +349,11 @@ static int pipeline_calc_cps_consumption(struct comp_dev *current, "0 CPS requested for module: %#x, core: %d using safe max KCPS: %u", current->ipc_config.id, comp_core, ppl_data->kcps[comp_core]); + /* + * This return code indicates to the caller, that the kcps calue + * shouldn't be used for slowing down the clock when terminating + * the pipeline + */ return PPL_STATUS_PATH_STOP; } else { kcps = cd->cpc * 1000 / current->period; @@ -430,6 +435,10 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd) ret = walk_ctx.comp_func(p->source_comp, NULL, &walk_ctx, PPL_DIR_DOWNSTREAM); for (int i = 0; i < arch_num_cpus(); i++) { + if (ret == PPL_STATUS_PATH_STOP) + /* Some components didn't provide CPC values */ + break; + if (data.kcps[i] > 0) { core_kcps_adjust(i, -data.kcps[i]); tr_info(pipe, "Sum of KCPS consumption: %d, core: %d", core_kcps_get(i), i);