Skip to content

Commit 2cb61a8

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 d638cc3 commit 2cb61a8

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/audio/pipeline/pipeline-stream.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,24 @@ 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-
ppl_data->kcps[comp_core] = CLK_MAX_CPU_HZ / 1000;
347+
uint32_t core_kcps = core_kcps_get(comp_core);
348+
349+
if (!current->kcps_inc[comp_core]) {
350+
current->kcps_inc[comp_core] = core_kcps;
351+
ppl_data->kcps[comp_core] = CLK_MAX_CPU_HZ / 1000 - core_kcps;
352+
} else {
353+
ppl_data->kcps[comp_core] = core_kcps - current->kcps_inc[comp_core];
354+
current->kcps_inc[comp_core] = 0;
355+
}
348356
tr_warn(pipe,
349357
"0 CPS requested for module: %#x, core: %d using safe max KCPS: %u",
350358
current->ipc_config.id, comp_core, ppl_data->kcps[comp_core]);
351359

360+
/*
361+
* This return code indicates to the caller, that the kcps calue
362+
* shouldn't be used for slowing down the clock when terminating
363+
* the pipeline
364+
*/
352365
return PPL_STATUS_PATH_STOP;
353366
} else {
354367
kcps = cd->cpc * 1000 / current->period;

src/include/sof/audio/component.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ struct comp_dev {
604604
#if CONFIG_PERFORMANCE_COUNTERS
605605
struct perf_cnt_data pcd;
606606
#endif
607+
608+
#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
609+
int32_t kcps_inc[CONFIG_CORE_COUNT];
610+
#endif
607611
};
608612

609613
/** @}*/

src/include/sof/audio/pipeline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct pipeline_data {
123123
int cmd;
124124
uint32_t delay_ms; /* between PRE_{START,RELEASE} and {START,RELEASE} */
125125
#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
126-
uint32_t kcps[CONFIG_CORE_COUNT]; /**< the max count of KCPS */
126+
int32_t kcps[CONFIG_CORE_COUNT]; /**< the max count of KCPS */
127127
#endif
128128
};
129129

0 commit comments

Comments
 (0)