From ebf940e31e28d474e7db394af368799336f9d9ae Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Fri, 4 Mar 2022 21:13:30 +0800 Subject: [PATCH] ipc4: don't get dai position when dai is not ready Fix fw panic in ipc4 linux driver test. When dai and host are in different pipelines, dai pipeline may be prepared after host pipeline, in this case we can't get dai position. The pipeline of copier component is set when pipeline is prepared, now set it in initialization function to avoid above case. Signed-off-by: Rander Wang --- src/audio/copier.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/audio/copier.c b/src/audio/copier.c index 679d95f9e..3fa846e6b 100644 --- a/src/audio/copier.c +++ b/src/audio/copier.c @@ -324,6 +324,7 @@ static struct comp_dev *copier_new(const struct comp_driver *drv, { struct ipc4_copier_module_cfg *copier = spec; union ipc4_connector_node_id node_id; + struct ipc_comp_dev *ipc_pipe; struct ipc *ipc = ipc_get(); struct copier_data *cd; struct comp_dev *dev; @@ -353,20 +354,19 @@ static struct comp_dev *copier_new(const struct comp_driver *drv, list_init(&dev->bsource_list); list_init(&dev->bsink_list); + ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id); + if (!ipc_pipe) { + comp_cl_err(&comp_copier, "pipeline %d is not existed", config->pipeline_id); + goto error_cd; + } + + dev->pipeline = ipc_pipe->pipeline; + /* copier is linked to gateway */ if (copier->gtw_cfg.node_id != IPC4_INVALID_NODE_ID) { - struct ipc_comp_dev *ipc_pipe; - node_id.dw = copier->gtw_cfg.node_id; cd->direction = node_id.f.dma_type % 2; - /* check whether pipeline id is already taken or in use */ - ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id); - if (!ipc_pipe) { - tr_err(&ipc_tr, "pipeline %d is not existed", config->pipeline_id); - goto error_cd; - } - switch (node_id.f.dma_type) { case ipc4_hda_host_output_class: case ipc4_hda_host_input_class: @@ -568,7 +568,21 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd) comp_err(dev, "failed to find dai comp"); return ret; } + dai_cd = comp_get_drvdata(dai_copier); + /* dai is in another pipeline and it is not prepared or active */ + if (dai_copier->state <= COMP_STATE_READY || dai_cd->endpoint->state <= COMP_STATE_READY) { + struct ipc4_pipeline_registers pipe_reg; + + comp_warn(dev, "dai is not ready"); + + pipe_reg.stream_start_offset = 0; + pipe_reg.stream_end_offset = 0; + mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg, sizeof(pipe_reg)); + + return 0; + } + comp_position(dai_cd->endpoint, &posn); /* update stream start and end offset for running message in host copier