Skip to content

Commit

Permalink
ipc: Add remote component search by pipeline idc
Browse files Browse the repository at this point in the history
By default ipc_get_comp_by_ppl_id() routine omits component
from core different that the one where pipeline is working.
However with introduction of DP modules such situation can happen.
In some flows we need to find modules that belongs to given pipeline
but are scheduled on different core. This modifications will allow to
select when include such modules in the search.

Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
  • Loading branch information
jxstelter committed Oct 30, 2023
1 parent 1c729f4 commit d63a67e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int copier_init(struct processing_module *mod)
for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++)
cd->out_fmt[i] = cd->config.out_fmt;

ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id);
ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id, true);
if (!ipc_pipe) {
comp_err(dev, "pipeline %d is not existed", config->pipeline_id);
ret = -EPIPE;
Expand Down
2 changes: 1 addition & 1 deletion src/idc/idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static int idc_ppl_state(uint32_t ppl_id, uint32_t phase)
struct ipc_comp_dev *ppl_icd;
uint32_t cmd = *(uint32_t *)payload;

ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id);
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id, true);
if (!ppl_icd) {
tr_err(&idc_tr, "idc: comp %d not found", ppl_id);
return IPC4_INVALID_RESOURCE_ID;
Expand Down
3 changes: 2 additions & 1 deletion src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t i
* @param ipc The global IPC context.
* @param type The component type.
* @param ppl_id The pipeline ID.
* @param skip_remote Omit component from different core
* @return component device or NULL.
*/
struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id);
uint32_t ppl_id, bool skip_remote);
/**
* \brief Get buffer device from pipeline ID.
* @param ipc The global IPC context.
Expand Down
6 changes: 4 additions & 2 deletions src/ipc/ipc3/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
return 0;
}

struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type, uint32_t ppl_id)
struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc,
uint16_t type, uint32_t ppl_id,
bool skip_remote)
{
struct ipc_comp_dev *icd;
struct list_item *clist;
Expand All @@ -301,7 +303,7 @@ struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type, uint
icd = container_of(clist, struct ipc_comp_dev, list);
if (icd->type != type)
continue;
if (!cpu_is_me(icd->core))
if ((!cpu_is_me(icd->core)) && skip_remote)
continue;
if (ipc_comp_pipe_id(icd) == ppl_id)
return icd;
Expand Down
6 changes: 3 additions & 3 deletions src/ipc/ipc4/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4)
}

for (i = 0; i < ppl_count; i++) {
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i]);
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i], true);
if (!ppl_icd) {
tr_err(&ipc_tr, "ipc: comp %d not found", ppl_id[i]);
return IPC4_INVALID_RESOURCE_ID;
Expand All @@ -568,7 +568,7 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4)

/* Run the prepare phase on the pipelines */
for (i = 0; i < ppl_count; i++) {
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i]);
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i], true);
if (!ppl_icd) {
ipc_cmd_err(&ipc_tr, "ipc: comp %d not found", ppl_id[i]);
return IPC4_INVALID_RESOURCE_ID;
Expand Down Expand Up @@ -601,7 +601,7 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4)
for (i = 0; i < ppl_count; i++) {
bool delayed = false;

ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i]);
ppl_icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i], true);
if (!ppl_icd) {
ipc_cmd_err(&ipc_tr, "ipc: comp %d not found", ppl_id[i]);
return IPC4_INVALID_RESOURCE_ID;
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 @@ -158,7 +158,9 @@ struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_init)
return dev;
}

struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type, uint32_t ppl_id)
struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id,
bool skip_remote)
{
struct ipc_comp_dev *icd;
struct list_item *clist;
Expand All @@ -175,7 +177,7 @@ struct ipc_comp_dev *ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type, uint
if (icd->id == ppl_id)
return icd;
} else {
if (!cpu_is_me(icd->core))
if ((!cpu_is_me(icd->core)) && skip_remote)
continue;
if (ipc_comp_pipe_id(icd) == ppl_id)
return icd;
Expand Down Expand Up @@ -252,7 +254,7 @@ static int ipc_pipeline_module_free(uint32_t pipeline_id)
struct ipc_comp_dev *icd;
int ret;

icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_COMPONENT, pipeline_id);
icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_COMPONENT, pipeline_id, false);
while (icd) {
struct list_item *list, *_list;
struct comp_buffer *buffer;
Expand Down Expand Up @@ -287,7 +289,7 @@ static int ipc_pipeline_module_free(uint32_t pipeline_id)
if (ret)
return IPC4_INVALID_RESOURCE_STATE;

icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_COMPONENT, pipeline_id);
icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_COMPONENT, pipeline_id, false);
}

return IPC4_SUCCESS;
Expand Down
3 changes: 2 additions & 1 deletion test/cmocka/src/common_mocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,12 @@ struct ipc_comp_dev *WEAK ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint3
}

struct ipc_comp_dev *WEAK ipc_get_comp_by_ppl_id(struct ipc *ipc, uint16_t type,
uint32_t ppl_id)
uint32_t ppl_id, bool skip_remote)
{
(void)ipc;
(void)type;
(void)ppl_id;
(void)skip_remote;

return NULL;
}
Expand Down

0 comments on commit d63a67e

Please sign in to comment.