From f76d4f4f1fbd8ba83af57d601d9edc732d1e5a68 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 10 Jan 2024 14:39:53 +0800 Subject: [PATCH] Add some trace Signed-off-by: Bard Liao --- src/audio/copier/copier_dai.c | 32 +++++++++++++++++++++++++++----- src/audio/dai-zephyr.c | 2 +- src/include/sof/ipc/topology.h | 2 +- src/ipc/ipc4/helper.c | 24 +++++++++++++++++------- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/audio/copier/copier_dai.c b/src/audio/copier/copier_dai.c index f42b5b62c99f..d7f9f07ee5e1 100644 --- a/src/audio/copier/copier_dai.c +++ b/src/audio/copier/copier_dai.c @@ -94,35 +94,57 @@ static int copier_alh_assign_dai_index(struct comp_dev *dev, * in other words do we need to create multiple dai or not */ if (!is_multi_gateway(node_id)) { + comp_err(mod->dev, "bard: !is_multi_gateway"); /* Find DMA config in blob and retrieve stream_id */ ret = ipc4_find_dma_config_multiple(dai, dma_config, dma_config_length, - alh_blob->alh_cfg.mapping[0].alh_id); + alh_blob->alh_cfg.mapping[0].alh_id, + 0); if (ret != 0) { - comp_err(mod->dev, "No sndw dma_config found in blob!"); + comp_err(mod->dev, "No sndw dma_config found in blob! alh_id 0x%x", + alh_blob->alh_cfg.mapping[0].alh_id); return -EINVAL; } dai_index[0] = dai->host_dma_config[0]->stream_id; return 0; } + comp_err(mod->dev, "bard: copier_alh_assign_dai_index 1"); dai_num = alh_blob->alh_cfg.count; if (dai_num > IPC4_ALH_MAX_NUMBER_OF_GTW || dai_num < 0) { comp_err(mod->dev, "Invalid dai_count: %d", dai_num); return -EINVAL; } + comp_err(mod->dev, "bard: copier_alh_assign_dai_index 2 dai_num %d", dai_num); for (i = 0; i < dai_num; i++) { + comp_err(mod->dev, "bard: i %d", i); ret = ipc4_find_dma_config_multiple(dai, dma_config, dma_config_length, - alh_blob->alh_cfg.mapping[i].alh_id); + alh_blob->alh_cfg.mapping[i].alh_id, + i); + comp_err(mod->dev, "bard: copier_alh_assign_dai_index after ipc4_find_dma_config_multiple"); if (ret != 0) { - comp_err(mod->dev, "No sndw dma_config found in blob!"); + comp_err(mod->dev, "No sndw dma_config found in blob! mapping[%d].alh_id 0x%x", + i, alh_blob->alh_cfg.mapping[i].alh_id); return -EINVAL; } - dai_index[i] = dai->host_dma_config[i]->stream_id; + if (dai->host_dma_config[i]) { + comp_err(mod->dev, "bard: copier_alh_assign_dai_index 3 stream_id 0x%x", dai->host_dma_config[i]->stream_id); + } else { + comp_err(mod->dev, "bard: dai->host_dma_config[%d] is null", i); + return -EINVAL; + } + if (dai_index[i]) + dai_index[i] = dai->host_dma_config[i]->stream_id; + else { + comp_err(mod->dev, "bard: dai_index[%d] is null", i); + return -EINVAL; + } + comp_err(mod->dev, "bard: copier_alh_assign_dai_index 4"); } *dai_count = dai_num; + comp_err(mod->dev, "bard: copier_alh_assign_dai_index 5 *dai_count %d", *dai_count); break; case SOF_DAI_INTEL_ALH: /* Use DAI_INTEL_ALH for ACE 1.0 and older */ diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 95812a25a377..f6b5b0bd58f8 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -914,7 +914,7 @@ int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev) } channel = dai_config_dma_channel(dd, dev, dd->dai_spec_config); - comp_dbg(dev, "dai_common_config_prepare(), channel = %d", channel); + comp_info(dev, "dai_common_config_prepare(), channel = %d", channel); /* do nothing for asking for channel free, for compatibility. */ if (channel == DMA_CHAN_INVALID) { diff --git a/src/include/sof/ipc/topology.h b/src/include/sof/ipc/topology.h index a41e2e3e6128..573737a3229b 100644 --- a/src/include/sof/ipc/topology.h +++ b/src/include/sof/ipc/topology.h @@ -61,7 +61,7 @@ int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint3 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); int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buffer, - uint32_t size, uint32_t device_id); + uint32_t size, uint32_t device_id, int dma_cfg_index); #else #error "No or invalid IPC MAJOR version selected." #endif diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 3547b6d9b9b5..dc42552fb99b 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -1026,9 +1026,11 @@ int ipc4_add_comp_dev(struct comp_dev *dev) int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size) { + tr_err(&comp_tr, "bard: ipc4_find_dma_config"); #if defined(CONFIG_ACE_VERSION_2_0) uint32_t *dma_config_id = GET_IPC_DMA_CONFIG_ID(data_buffer, size); + tr_err(&comp_tr, "bard: dma_config_id 0x%x", *dma_config_id); if (*dma_config_id != GTW_DMA_CONFIG_ID) return IPC4_INVALID_REQUEST; @@ -1038,33 +1040,41 @@ int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint3 } int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buffer, - uint32_t size, uint32_t device_id) + uint32_t size, uint32_t device_id, int dma_cfg_index) { uint32_t end_addr = (uint32_t)data_buffer + size; struct ipc_dma_config *dma_cfg; struct sof_tlv *tlvs; - int dma_cfg_count = 0; + tr_err(&ipc_tr, "bard: ipc4_find_dma_config_multiple device_id 0x%x", device_id); for (tlvs = (struct sof_tlv *)data_buffer; (uint32_t)tlvs < end_addr; tlvs = tlv_next(tlvs)) { + if ((uintptr_t)tlvs % sizeof(uint32_t) != 0) + tr_err(&comp_tr, "bard: tlv size in incorrect"); + else + tr_err(&comp_tr, "bard: tlv->type 0x%x", tlvs->type); dma_cfg = tlv_value_ptr_get(tlvs, GTW_DMA_CONFIG_ID); - if (!dma_cfg) + if (!dma_cfg) { + tr_err(&ipc_tr, "bard: !dma_cfg"); continue; + } + tr_err(&ipc_tr, "bard: device_count %d dma_cfg_index %d", dma_cfg->channel_map.device_count, dma_cfg_index); if (dma_cfg->channel_map.device_count == 0) { - dai->host_dma_config[dma_cfg_count] = dma_cfg; + dai->host_dma_config[dma_cfg_index] = dma_cfg; return IPC4_SUCCESS; } for (uint32_t i = 0; i < dma_cfg->channel_map.device_count; i++) { + tr_err(&ipc_tr, "bard: map[%d].device_address = 0x%x device_id 0x%x", + i, dma_cfg->channel_map.map[i].device_address, device_id); if (dma_cfg->channel_map.map[i].device_address == device_id) { - dai->host_dma_config[dma_cfg_count] = dma_cfg; + dai->host_dma_config[dma_cfg_index] = dma_cfg; + tr_err(&ipc_tr, "bard: set ai->host_dma_config[%d] return success", dma_cfg_index); return IPC4_SUCCESS; } } - - dma_cfg_count++; } return IPC4_INVALID_REQUEST;