diff --git a/src/audio/pipeline/pipeline-stream.c b/src/audio/pipeline/pipeline-stream.c index 7077f5e30251..9f3dc6eb8a05 100644 --- a/src/audio/pipeline/pipeline-stream.c +++ b/src/audio/pipeline/pipeline-stream.c @@ -344,11 +344,24 @@ static int pipeline_calc_cps_consumption(struct comp_dev *current, if (cd->cpc == 0) { /* Use maximum clock budget, assume 1ms chunk size */ - ppl_data->kcps[comp_core] = CLK_MAX_CPU_HZ / 1000; + uint32_t core_kcps = core_kcps_get(comp_core); + + if (!current->kcps_inc[comp_core]) { + current->kcps_inc[comp_core] = core_kcps; + ppl_data->kcps[comp_core] = CLK_MAX_CPU_HZ / 1000 - core_kcps; + } else { + ppl_data->kcps[comp_core] = core_kcps - current->kcps_inc[comp_core]; + current->kcps_inc[comp_core] = 0; + } tr_warn(pipe, "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; diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 4dfa2e66a26a..e8171084087b 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -604,6 +604,10 @@ struct comp_dev { #if CONFIG_PERFORMANCE_COUNTERS struct perf_cnt_data pcd; #endif + +#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL + int32_t kcps_inc[CONFIG_CORE_COUNT]; +#endif }; /** @}*/ diff --git a/src/include/sof/audio/pipeline.h b/src/include/sof/audio/pipeline.h index 0edb3305680c..2410f774f00d 100644 --- a/src/include/sof/audio/pipeline.h +++ b/src/include/sof/audio/pipeline.h @@ -123,7 +123,7 @@ struct pipeline_data { int cmd; uint32_t delay_ms; /* between PRE_{START,RELEASE} and {START,RELEASE} */ #if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL - uint32_t kcps[CONFIG_CORE_COUNT]; /**< the max count of KCPS */ + int32_t kcps[CONFIG_CORE_COUNT]; /**< the max count of KCPS */ #endif };