Skip to content

Commit f93f521

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 6f8edf8 commit f93f521

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/audio/pipeline/pipeline-stream.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,15 @@ 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]);
@@ -431,8 +439,15 @@ int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd)
431439

432440
for (int i = 0; i < arch_num_cpus(); i++) {
433441
if (data.kcps[i] > 0) {
442+
uint32_t core_kcps = core_kcps_get(i);
443+
444+
/* Cannot go below 50000kcps */
445+
if (data.kcps[i] > core_kcps - 50000)
446+
data.kcps[i] = core_kcps - 50000;
447+
434448
core_kcps_adjust(i, -data.kcps[i]);
435-
tr_info(pipe, "Sum of KCPS consumption: %d, core: %d", core_kcps_get(i), i);
449+
tr_info(pipe, "Sum of KCPS consumption: %d, core: %d",
450+
core_kcps, i);
436451
}
437452
}
438453
}

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)