From ba311d8badd6c48b80edd7b080ebc65ec48f1380 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Aug 2023 15:41:25 +0100 Subject: [PATCH 1/3] ipc4: more dbg context for pipeline state changes Give more context for pipeline context changes. Signed-off-by: Liam Girdwood --- src/ipc/ipc4/handler.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index ecb8285c6105..cc1fcd574272 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -223,9 +223,10 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, int status; int ret; - tr_dbg(&ipc_tr, "ipc4 set pipeline %d state %x:", ppl_icd->id, cmd); - status = ppl_icd->pipeline->status; + tr_dbg(&ipc_tr, "ipc4 set pipeline %d cmd state %x: from state %x", ppl_icd->id, + cmd, status); + /* source & sink components are set when pipeline is set to COMP_STATE_INIT */ if (status != COMP_STATE_INIT) { int host_id; @@ -252,6 +253,8 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, case COMP_STATE_READY: cmd = COMP_TRIGGER_PRE_START; + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: params", + ppl_icd->id, cmd); ret = ipc4_pcm_params(host); if (ret < 0) return IPC4_INVALID_REQUEST; @@ -267,6 +270,8 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, case SOF_IPC4_PIPELINE_STATE_RESET: switch (status) { case COMP_STATE_INIT: + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: reset from init", + ppl_icd->id, cmd); ret = ipc4_pipeline_complete(ipc, ppl_icd->id); if (ret < 0) ret = IPC4_INVALID_REQUEST; @@ -277,6 +282,8 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, return 0; case COMP_STATE_ACTIVE: case COMP_STATE_PAUSED: + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: pause from reset", + ppl_icd->id, cmd); ret = pipeline_trigger(host->cd->pipeline, host->cd, COMP_TRIGGER_STOP); if (ret < 0) { ipc_cmd_err(&ipc_tr, "ipc: comp %d trigger 0x%x failed %d", @@ -297,6 +304,8 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, * executing in the pipeline task. */ if (!*delayed) { + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: delayed reset", + ppl_icd->id, cmd); ret = pipeline_reset(host->cd->pipeline, host->cd); if (ret < 0) ret = IPC4_INVALID_REQUEST; @@ -306,6 +315,8 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, case SOF_IPC4_PIPELINE_STATE_PAUSED: switch (status) { case COMP_STATE_INIT: + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: pause from init", + ppl_icd->id, cmd); ret = ipc4_pipeline_complete(ipc, ppl_icd->id); if (ret < 0) ret = IPC4_INVALID_REQUEST; @@ -330,12 +341,17 @@ int set_pipeline_state(struct ipc_comp_dev *ppl_icd, uint32_t cmd, return IPC4_INVALID_REQUEST; } + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: from state %x", ppl_icd->id, + cmd, status); + /* trigger the component */ ret = pipeline_trigger(host->cd->pipeline, host->cd, cmd); if (ret < 0) { ipc_cmd_err(&ipc_tr, "ipc: comp %d trigger 0x%x failed %d", ppl_icd->id, cmd, ret); ret = IPC4_PIPELINE_STATE_NOT_SET; } else if (ret == PPL_STATUS_SCHEDULED) { + tr_dbg(&ipc_tr, "ipc4: set pipeline %d new cmd state %x: trigger delayed", + ppl_icd->id, cmd); *delayed = true; ret = 0; } From 19cfb8df4a26e9d7d0e35cff5b7e5efd6c146732 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Aug 2023 15:43:55 +0100 Subject: [PATCH 2/3] ipc4: relax the IPC timeout checks and be nicer to other threads No need to check every 250uS for ipc completion, relax this to avoid any busy scheduling. Signed-off-by: Liam Girdwood --- src/ipc/ipc4/handler.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index cc1fcd574272..3ecc5d098d02 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -396,15 +396,16 @@ static void ipc_compound_msg_done(uint32_t msg_id, int error) } } +/* wait for IPCs to complete on other cores and be nice to any LL work */ static int ipc_wait_for_compound_msg(void) { - int try_count = 30; + int try_count = 30; /* timeout out is 30 x 10ms so 300ms for IPC */ while (atomic_read(&msg_data.delayed_reply)) { - k_sleep(Z_TIMEOUT_US(250)); + k_sleep(Z_TIMEOUT_MS(10)); if (!try_count--) { - ipc_cmd_err(&ipc_tr, "failed to wait schedule thread"); + ipc_cmd_err(&ipc_tr, "ipc4: failed to wait schedule thread"); return IPC4_FAILURE; } } From 664b94be238f10bfdf42474cac9e0bf72e8d122a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Aug 2023 15:45:15 +0100 Subject: [PATCH 3/3] ipc4: ipc atomic state should be reset after timeout. reset the atomic ipc4 message delay state after any timeout error. Signed-off-by: Liam Girdwood --- src/ipc/ipc4/handler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index 3ecc5d098d02..bddf37d3e2fb 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -405,6 +405,7 @@ static int ipc_wait_for_compound_msg(void) k_sleep(Z_TIMEOUT_MS(10)); if (!try_count--) { + atomic_set(&msg_data.delayed_reply, 0); ipc_cmd_err(&ipc_tr, "ipc4: failed to wait schedule thread"); return IPC4_FAILURE; }