Skip to content

Commit

Permalink
helper: add a condition before updating the component direction
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fkwasowi authored and kv2019i committed Sep 18, 2023
1 parent 57cb19e commit 3b31adc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/ipc/ipc4/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 3b31adc

Please sign in to comment.