From 3b31adc259d760ded0be24937c4cf31bbb25010f Mon Sep 17 00:00:00 2001 From: "Kwasowiec, Fabiola" Date: Thu, 14 Sep 2023 08:48:06 +0200 Subject: [PATCH] helper: add a condition before updating the component direction At the pipeline reset stage, the direction of the components is not always known, resulting in a call to a field that is null and consequently a crash/timeout. Signed-off-by: Kwasowiec, Fabiola --- src/include/sof/ipc/topology.h | 2 +- src/ipc/ipc4/handler.c | 4 ++-- src/ipc/ipc4/helper.c | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/include/sof/ipc/topology.h b/src/include/sof/ipc/topology.h index 810df643fc13..34748379dbc2 100644 --- a/src/include/sof/ipc/topology.h +++ b/src/include/sof/ipc/topology.h @@ -56,7 +56,7 @@ int ipc4_chain_dma_state(struct comp_dev *dev, struct ipc4_chain_dma *cdma); int ipc4_create_chain_dma(struct ipc *ipc, struct ipc4_chain_dma *cdma); int ipc4_trigger_chain_dma(struct ipc *ipc, struct ipc4_chain_dma *cdma, bool *delay); int ipc4_process_on_core(uint32_t core, bool blocking); -int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id); +int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id, uint32_t cmd); int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size); int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd); int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *delayed); diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index bb5ad023d06a..bc91c6a3727f 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -274,7 +274,7 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) switch (status) { case COMP_STATE_INIT: tr_dbg(&ipc_tr, "pipeline %d: reset from init", ppl_icd->id); - ret = ipc4_pipeline_complete(ipc, ppl_icd->id); + ret = ipc4_pipeline_complete(ipc, ppl_icd->id, cmd); if (ret < 0) ret = IPC4_INVALID_REQUEST; @@ -296,7 +296,7 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) switch (status) { case COMP_STATE_INIT: tr_dbg(&ipc_tr, "pipeline %d: pause from init", ppl_icd->id); - ret = ipc4_pipeline_complete(ipc, ppl_icd->id); + ret = ipc4_pipeline_complete(ipc, ppl_icd->id, cmd); if (ret < 0) ret = IPC4_INVALID_REQUEST; diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 206773d23c0c..1f1bcc46e8c4 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -630,7 +630,7 @@ static int ipc4_update_comps_direction(struct ipc *ipc, uint32_t ppl_id) return 0; } -int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id) +int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id, uint32_t cmd) { struct ipc_comp_dev *ipc_pipe; int ret; @@ -649,9 +649,11 @@ int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id) * pipeline w/o connection to gateway, so direction is not configured in binding phase. * Need to update direction for such modules when pipeline is completed. */ - ret = ipc4_update_comps_direction(ipc, comp_id); - if (ret < 0) - return ret; + if (cmd != SOF_IPC4_PIPELINE_STATE_RESET) { + ret = ipc4_update_comps_direction(ipc, comp_id); + if (ret < 0) + return ret; + } return ipc_pipeline_complete(ipc, comp_id); }