Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/ipc/ipc-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ __cold struct comp_buffer *buffer_new(struct mod_alloc_ctx *alloc,
#endif

/* allocate buffer */
buffer = buffer_alloc(alloc, desc->size, flags, PLATFORM_DCACHE_ALIGN,
is_shared);
buffer = buffer_alloc(alloc, desc->size, flags, PLATFORM_DCACHE_ALIGN, is_shared);
if (buffer) {
buffer->stream.runtime_stream_params.id = desc->comp.id;
buffer->stream.runtime_stream_params.pipeline_id = desc->comp.pipeline_id;
Expand Down Expand Up @@ -188,14 +187,12 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag,
if (dir == PPL_DIR_DOWNSTREAM) {
comp_dev_for_each_consumer(dev, buf) {
comp_update_params(flag, params, buf);
buffer_set_params(buf, params,
BUFFER_UPDATE_FORCE);
buffer_set_params(buf, params, BUFFER_UPDATE_FORCE);
}
} else {
comp_dev_for_each_producer(dev, buf) {
comp_update_params(flag, params, buf);
buffer_set_params(buf, params,
BUFFER_UPDATE_FORCE);
buffer_set_params(buf, params, BUFFER_UPDATE_FORCE);
}
}

Expand Down Expand Up @@ -284,11 +281,9 @@ int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)

pipeline_id = ipc_pipe->pipeline->pipeline_id;

tr_dbg(&ipc_tr, "ipc: pipe %d -> complete on comp 0x%x", pipeline_id,
comp_id);
tr_dbg(&ipc_tr, "ipc: pipe %d -> complete on comp 0x%x", pipeline_id, comp_id);

return pipeline_complete(ipc_pipe->pipeline, ipc_ppl_source->cd,
ipc_ppl_sink->cd);
return pipeline_complete(ipc_pipe->pipeline, ipc_ppl_source->cd, ipc_ppl_sink->cd);
}

__cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
Expand All @@ -306,8 +301,7 @@ __cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
/* check whether component exists */
icd = ipc_get_comp_by_id(ipc, comp_id);
if (!icd) {
tr_err(&ipc_tr, "comp id: 0x%x is not found",
comp_id);
tr_err(&ipc_tr, "comp id: 0x%x is not found", comp_id);
return -ENODEV;
}

Expand Down Expand Up @@ -336,8 +330,7 @@ __cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
* leak on error. Bug-free host drivers won't do
* this, this was found via fuzzing.
*/
tr_err(&ipc_tr, "uninitialized buffer lists on comp 0x%x\n",
icd->id);
tr_err(&ipc_tr, "uninitialized buffer lists on comp 0x%x\n", icd->id);
return -EINVAL;
}

Expand Down
21 changes: 9 additions & 12 deletions src/ipc/ipc4/handler-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,28 +1513,25 @@ __cold int ipc4_user_process_module_message(struct ipc4_message_request *ipc4,
case SOF_IPC4_MOD_INIT_INSTANCE:
#ifdef CONFIG_SOF_USERSPACE_LL
{
BUILD_ASSERT(sizeof(struct comp_driver) + sizeof(struct tr_ctx) <=
sizeof(((struct ipc_user *)0)->init_drv_data),
"ipc_user.init_drv_data too small for driver copy");

/* User-space init: kernel does driver lookup only (requires
* access to IMR manifest and driver list in kernel memory).
* Component creation (drv->ops.create) runs in user thread
* so untrusted module code does not execute in kernel context.
* Cross-core creation stays fully in kernel.
*/
struct ipc4_module_init_instance mi;

BUILD_ASSERT(sizeof(struct comp_driver) + sizeof(struct tr_ctx) <=
sizeof(((struct ipc_user *)0)->init_drv_data),
"ipc_user.init_drv_data too small for driver copy");

ret = memcpy_s(&mi, sizeof(mi), ipc4, sizeof(*ipc4));
if (ret < 0)
break;
const struct ipc4_module_init_instance *mi =
(const struct ipc4_module_init_instance *)ipc4;

if (!cpu_is_me(mi.extension.r.core_id)) {
if (!cpu_is_me(mi->extension.r.core_id)) {
ret = ipc4_init_module_instance(ipc4);
} else {
struct ipc *ipc = ipc_get();
uint32_t comp_id = IPC4_COMP_ID(mi.primary.r.module_id,
mi.primary.r.instance_id);
uint32_t comp_id = IPC4_COMP_ID(mi->primary.r.module_id,
mi->primary.r.instance_id);
const struct comp_driver *drv = ipc4_get_comp_drv(
IPC4_MOD_ID(comp_id));
struct ipc_user *pdata = ipc->ipc_user_pdata;
Expand Down
43 changes: 14 additions & 29 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ __cold struct comp_dev *comp_new_ipc4_user(struct ipc4_message_request *ipc4,
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
#else
if (module_init.extension.r.proc_domain) {
tr_err(&ipc_tr,
"ipc: DP scheduling is disabled, cannot create comp 0x%x",
comp_id);
tr_err(&ipc_tr, "ipc: DP scheduling is disabled, cannot create comp 0x%x", comp_id);
return NULL;
}
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
Expand Down Expand Up @@ -1166,8 +1164,7 @@ __cold int ipc4_chain_manager_create(const struct ipc4_chain_dma *cdma)
const uint32_t comp_id = IPC4_COMP_ID(cdma->primary.r.host_dma_id
+ IPC4_MAX_MODULE_COUNT, 0);
dev->ipc_config.id = comp_id;
dev->ipc_config.pipeline_id = cdma->primary.r.host_dma_id
+ IPC4_MAX_MODULE_COUNT;
dev->ipc_config.pipeline_id = cdma->primary.r.host_dma_id + IPC4_MAX_MODULE_COUNT;

return ipc4_add_comp_dev(dev);
}
Expand Down Expand Up @@ -1309,13 +1306,10 @@ __cold static const struct comp_driver *ipc4_search_for_drv(const void *uuid)

/* search driver list with UUID */
list_for_item(clist, &drivers->list) {
info = container_of(clist, struct comp_driver_info,
list);
info = container_of(clist, struct comp_driver_info, list);
if (!memcmp(info->drv->uid, uuid, UUID_SIZE)) {
tr_dbg(&comp_tr,
"found type %d, uuid %pU",
info->drv->type,
info->drv->tctx->uuid_p);
tr_dbg(&comp_tr, "found type %d, uuid %pU",
info->drv->type, info->drv->tctx->uuid_p);
drv = info->drv;
break;
}
Expand Down Expand Up @@ -1397,8 +1391,7 @@ static const struct comp_driver *ipc4_get_fuzzer_drv(uint32_t module_id)
return inf->drv;
}

tr_err(&comp_tr,
"no instantiable driver at module_id %u (%u available)",
tr_err(&comp_tr, "no instantiable driver at module_id %u (%u available)",
module_id, idx);
return NULL;
}
Expand Down Expand Up @@ -1642,10 +1635,8 @@ void ipc4_audio_format_to_stream_params(const struct ipc4_audio_format *audio_fm
params->sample_valid_bytes = audio_fmt->valid_bit_depth / 8;
params->buffer_fmt = audio_fmt->interleaving_style;

audio_stream_fmt_conversion(audio_fmt->depth,
audio_fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
audio_fmt->s_type);
audio_stream_fmt_conversion(audio_fmt->depth, audio_fmt->valid_bit_depth,
&frame_fmt, &valid_fmt, audio_fmt->s_type);
params->frame_fmt = frame_fmt;

for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++)
Expand All @@ -1670,10 +1661,8 @@ void ipc4_update_buffer_format(struct comp_buffer *buf_c,

audio_stream_set_channels(&buf_c->stream, fmt->channels_count);
audio_stream_set_rate(&buf_c->stream, fmt->sampling_frequency);
audio_stream_fmt_conversion(fmt->depth,
fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
fmt->s_type);
audio_stream_fmt_conversion(fmt->depth, fmt->valid_bit_depth,
&frame_fmt, &valid_fmt, fmt->s_type);

audio_stream_set_frm_fmt(&buf_c->stream, frame_fmt);
audio_stream_set_valid_fmt(&buf_c->stream, valid_fmt);
Expand All @@ -1692,10 +1681,8 @@ void ipc4_update_source_format(struct sof_source *source,

source_set_channels(source, fmt->channels_count);
source_set_rate(source, fmt->sampling_frequency);
audio_stream_fmt_conversion(fmt->depth,
fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
fmt->s_type);
audio_stream_fmt_conversion(fmt->depth, fmt->valid_bit_depth,
&frame_fmt, &valid_fmt, fmt->s_type);

source_set_frm_fmt(source, frame_fmt);
source_set_valid_fmt(source, valid_fmt);
Expand All @@ -1710,10 +1697,8 @@ void ipc4_update_sink_format(struct sof_sink *sink,

sink_set_channels(sink, fmt->channels_count);
sink_set_rate(sink, fmt->sampling_frequency);
audio_stream_fmt_conversion(fmt->depth,
fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
fmt->s_type);
audio_stream_fmt_conversion(fmt->depth, fmt->valid_bit_depth,
&frame_fmt, &valid_fmt, fmt->s_type);

sink_set_frm_fmt(sink, frame_fmt);
sink_set_valid_fmt(sink, valid_fmt);
Expand Down
Loading