diff --git a/src/arch/xtensa/lib/cpu.c b/src/arch/xtensa/lib/cpu.c index 5fc918cfb8f9..9a3b4bf9b191 100644 --- a/src/arch/xtensa/lib/cpu.c +++ b/src/arch/xtensa/lib/cpu.c @@ -180,6 +180,8 @@ void cpu_power_down_core(void) pm_runtime_put(PM_RUNTIME_DSP, PWRD_BY_TPLG | cpu_get_id()); + trace_point(0); + /* arch_wait_for_interrupt() not used, because it will cause panic. * This code is executed on irq lvl > 0, which is expected. * Core will be put into reset by host anyway. diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 167163dcce1b..b467ecd34743 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -38,7 +38,7 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t align) } /* allocate new buffer */ - buffer = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, + buffer = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*buffer)); if (!buffer) { tr_err(&buffer_tr, "buffer_alloc(): could not alloc structure"); diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index a5a7e30d8a86..add513cb1201 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -113,7 +113,7 @@ struct pipeline *pipeline_new(uint32_t pipeline_id, uint32_t priority, uint32_t pipeline_id, priority); /* allocate new pipeline */ - p = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*p)); + p = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*p)); if (!p) { pipe_cl_err("pipeline_new(): Out of Memory"); return NULL; @@ -184,60 +184,15 @@ void pipeline_disconnect(struct comp_dev *comp, struct comp_buffer *buffer, int irq_local_enable(flags); } -static int pipeline_comp_free(struct comp_dev *current, - struct comp_buffer *calling_buf, - struct pipeline_walk_context *ctx, int dir) -{ - struct pipeline_data *ppl_data = ctx->comp_data; - uint32_t flags; - - pipe_dbg(current->pipeline, "pipeline_comp_free(), current->comp.id = %u, dir = %u", - dev_comp_id(current), dir); - - if (!comp_is_single_pipeline(current, ppl_data->start)) { - pipe_dbg(current->pipeline, "pipeline_comp_free(), current is from another pipeline"); - return 0; - } - - /* complete component free */ - current->pipeline = NULL; - - pipeline_for_each_comp(current, ctx, dir); - - /* disconnect source from buffer */ - irq_local_disable(flags); - list_item_del(comp_buffer_list(current, dir)); - irq_local_enable(flags); - - return 0; -} - /* pipelines must be inactive */ int pipeline_free(struct pipeline *p) { - struct pipeline_data data; - struct pipeline_walk_context walk_ctx = { - .comp_func = pipeline_comp_free, - .comp_data = &data, - }; - pipe_info(p, "pipeline_free()"); - /* make sure we are not in use */ - if (p->source_comp) { - if (p->source_comp->state > COMP_STATE_READY) { - pipe_err(p, "pipeline_free(): Pipeline in use, %u, %u", - dev_comp_id(p->source_comp), - p->source_comp->state); - return -EBUSY; - } - - data.start = p->source_comp; - - /* disconnect components */ - walk_ctx.comp_func(p->source_comp, NULL, &walk_ctx, - PPL_DIR_DOWNSTREAM); - } + /* + * pipeline_free should always be called only after all the widgets in the pipeline have + * been freed. + */ /* remove from any scheduling */ if (p->pipe_task) { diff --git a/src/ipc/ipc3/dai.c b/src/ipc/ipc3/dai.c index c4403c465760..f567737c3c33 100644 --- a/src/ipc/ipc3/dai.c +++ b/src/ipc/ipc3/dai.c @@ -165,7 +165,7 @@ int ipc_comp_dai_config(struct ipc *ipc, struct ipc_config_dai *common_config, if (icd->type != COMP_TYPE_COMPONENT) continue; - if (!cpu_is_me(icd->core)) { + if (!cpu_is_me(icd->core) && cpu_is_core_enabled(icd->core)) { comp_on_core[icd->core] = true; ret = 0; continue; diff --git a/src/ipc/ipc3/handler.c b/src/ipc/ipc3/handler.c index ee84e05ac9a8..51ca48e6940a 100644 --- a/src/ipc/ipc3/handler.c +++ b/src/ipc/ipc3/handler.c @@ -644,7 +644,7 @@ static int ipc_pm_context_restore(uint32_t header) static int ipc_pm_core_enable(uint32_t header) { struct sof_ipc_pm_core_config pm_core_config; - int ret = 0; + int ret; int i = 0; /* copy message with ABI safe method */ @@ -662,14 +662,19 @@ static int ipc_pm_core_enable(uint32_t header) for (i = 0; i < CONFIG_CORE_COUNT; i++) { if (i != PLATFORM_PRIMARY_CORE_ID) { - if (pm_core_config.enable_mask & (1 << i)) + if (pm_core_config.enable_mask & (1 << i)) { ret = cpu_enable_core(i); - else + if (ret < 0) { + tr_err(&ipc_tr, "Failed to enable core %d", i); + return ret; + } + } else { cpu_disable_core(i); + } } } - return ret; + return 0; } static int ipc_pm_gate(uint32_t header) diff --git a/src/schedule/edf_schedule.c b/src/schedule/edf_schedule.c index 26dcf6f8d9c2..a0a3b46ebedf 100644 --- a/src/schedule/edf_schedule.c +++ b/src/schedule/edf_schedule.c @@ -295,8 +295,6 @@ static void scheduler_free_edf(void *data) /* free main task context */ task_main_free(); - list_item_del(&edf_sch->list); - irq_local_enable(flags); } diff --git a/src/schedule/ll_schedule.c b/src/schedule/ll_schedule.c index dbcb42d32cb2..ce99298c36c2 100644 --- a/src/schedule/ll_schedule.c +++ b/src/schedule/ll_schedule.c @@ -582,8 +582,6 @@ static void scheduler_free_ll(void *data) notifier_unregister(sch, NULL, NOTIFIER_CLK_CHANGE_ID(sch->domain->clk)); - list_init(&sch->tasks); - irq_local_enable(flags); } diff --git a/test/cmocka/src/audio/pipeline/pipeline_free.c b/test/cmocka/src/audio/pipeline/pipeline_free.c index c215a1901a9a..7aecbec62689 100644 --- a/test/cmocka/src/audio/pipeline/pipeline_free.c +++ b/test/cmocka/src/audio/pipeline/pipeline_free.c @@ -35,22 +35,6 @@ static int teardown(void **state) return 0; } -static void test_audio_pipeline_free_comp_busy(void **state) -{ - struct pipeline_connect_data *test_data = *state; - struct pipeline result = test_data->p; - - cleanup_test_data(test_data); - - result.source_comp = test_data->first; - result.sched_comp->state = 3; - - /*Testing component*/ - int err = pipeline_free(&result); - - assert_int_equal(err, -EBUSY); -} - static void test_audio_pipeline_free_return_value(void **state) { struct pipeline_connect_data *test_data = *state; @@ -58,9 +42,6 @@ static void test_audio_pipeline_free_return_value(void **state) cleanup_test_data(test_data); - result.source_comp = test_data->first; - result.sched_comp->state = COMP_STATE_READY; - /*Testing component*/ int err = pipeline_free(&result); @@ -74,8 +55,6 @@ static void test_audio_pipeline_free_sheduler_task_free(void **state) cleanup_test_data(test_data); - result.source_comp = test_data->first; - /*Testing component*/ pipeline_free(&result); @@ -84,74 +63,15 @@ static void test_audio_pipeline_free_sheduler_task_free(void **state) assert_ptr_equal(NULL, result.pipe_task->ops.run); } -static void test_audio_pipeline_free_disconnect_full(void **state) -{ - struct pipeline_connect_data *test_data = *state; - struct pipeline result = test_data->p; - struct comp_ipc_config *first_comp; - struct comp_ipc_config *second_comp; - - cleanup_test_data(test_data); - - /*Set pipeline to check that is null later*/ - result.source_comp = test_data->first; - test_data->first->pipeline = &result; - test_data->second->pipeline = &result; - first_comp = &test_data->first->ipc_config; - second_comp = &test_data->second->ipc_config; - second_comp->pipeline_id = PIPELINE_ID_SAME; - first_comp->pipeline_id = PIPELINE_ID_SAME; - test_data->b1->source = test_data->first; - list_item_append(&result.sched_comp->bsink_list, - &test_data->b1->source_list); - test_data->b1->sink = test_data->second; - - /*Testing component*/ - pipeline_free(&result); - - assert_ptr_equal(NULL, test_data->second->pipeline); - assert_ptr_equal(NULL, test_data->first->pipeline); -} - -static void test_audio_pipeline_free_disconnect_list_del -(void **state) -{ - struct pipeline_connect_data *test_data = *state; - struct pipeline result = test_data->p; - - cleanup_test_data(test_data); - - result.source_comp = test_data->first; - test_data->b1->source = test_data->first; - list_item_append(&result.sched_comp->bsink_list, - &test_data->b1->source_list); - test_data->b1->sink = test_data->second; - - /*Testing component*/ - pipeline_free(&result); - - assert_true(list_is_empty(&test_data->second->bsink_list)); - assert_true(list_is_empty(&test_data->first->bsink_list)); -} - int main(void) { const struct CMUnitTest tests[] = { - cmocka_unit_test( - test_audio_pipeline_free_comp_busy - ), cmocka_unit_test( test_audio_pipeline_free_return_value ), cmocka_unit_test( test_audio_pipeline_free_sheduler_task_free ), - cmocka_unit_test( - test_audio_pipeline_free_disconnect_full - ), - cmocka_unit_test( - test_audio_pipeline_free_disconnect_list_del - ), }; cmocka_set_message_output(CM_OUTPUT_TAP);