Skip to content

Commit 8ca5ee1

Browse files
committed
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 reduced to a small value. Fix this by detecting such cases in pipeline termination code. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 7fe60a1 commit 8ca5ee1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/audio/pipeline/pipeline-stream.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,18 @@ static int pipeline_calc_cps_consumption(struct comp_dev *current,
344344

345345
if (cd->cpc == 0) {
346346
/* Use maximum clock budget, assume 1ms chunk size */
347+
if (!ppl_data->kcps_acc[comp_core])
348+
ppl_data->kcps_acc[comp_core] = ppl_data->kcps[comp_core];
347349
ppl_data->kcps[comp_core] = CLK_MAX_CPU_HZ / 1000;
348350
tr_warn(pipe,
349351
"0 CPS requested for module: %#x, core: %d using safe max KCPS: %u",
350352
current->ipc_config.id, comp_core, ppl_data->kcps[comp_core]);
351353

354+
/*
355+
* This return code indicates to the caller, that the kcps calue
356+
* shouldn't be used for slowing down the clock when terminating
357+
* the pipeline
358+
*/
352359
return PPL_STATUS_PATH_STOP;
353360
} else {
354361
kcps = cd->cpc * 1000 / current->period;
@@ -430,6 +437,12 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd)
430437
ret = walk_ctx.comp_func(p->source_comp, NULL, &walk_ctx, PPL_DIR_DOWNSTREAM);
431438

432439
for (int i = 0; i < arch_num_cpus(); i++) {
440+
if (ret == PPL_STATUS_PATH_STOP) {
441+
/* Restore the value before maximization */
442+
data.kcps[i] -= data.kcps_acc[i];
443+
data.kcps_acc[i] = 0;
444+
}
445+
433446
if (data.kcps[i] > 0) {
434447
core_kcps_adjust(i, -data.kcps[i]);
435448
tr_info(pipe, "Sum of KCPS consumption: %d, core: %d", core_kcps_get(i), i);

src/include/sof/audio/pipeline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ struct pipeline_data {
124124
uint32_t delay_ms; /* between PRE_{START,RELEASE} and {START,RELEASE} */
125125
#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
126126
uint32_t kcps[CONFIG_CORE_COUNT]; /**< the max count of KCPS */
127+
uint32_t kcps_acc[CONFIG_CORE_COUNT]; /**< accumulated KCPS before maximization */
127128
#endif
128129
};
129130

0 commit comments

Comments
 (0)