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
2 changes: 1 addition & 1 deletion src/audio/google/google_hotword_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static struct comp_dev *ghd_create(const struct comp_driver *drv,
cd->event.event_type = SOF_CTRL_EVENT_KD;
cd->event.num_elems = 0;

cd->msg = ipc_msg_init(cd->event.rhdr.hdr.cmd, cd->event.rhdr.hdr.size);
cd->msg = ipc_msg_init(NULL, cd->event.rhdr.hdr.cmd, cd->event.rhdr.hdr.size);
if (!cd->msg) {
comp_err(dev, "ipc_msg_init failed");
goto cd_fail;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/host-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ int host_common_new(struct host_data *hd, struct comp_dev *dev,
ipc_build_stream_posn(&hd->posn, SOF_IPC_STREAM_POSITION, config_id);

#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
hd->msg = ipc_msg_init(hd->posn.rhdr.hdr.cmd, hd->posn.rhdr.hdr.size);
hd->msg = ipc_msg_init(NULL, hd->posn.rhdr.hdr.cmd, hd->posn.rhdr.hdr.size);
if (!hd->msg) {
comp_err(dev, "ipc_msg_init failed");
dma_put(hd->dma);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ __cold int host_common_new(struct host_data *hd, struct comp_dev *dev,
ipc_build_stream_posn(&hd->posn, SOF_IPC_STREAM_POSITION, config_id);

#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
hd->msg = ipc_msg_init(hd->posn.rhdr.hdr.cmd, sizeof(hd->posn));
hd->msg = ipc_msg_init(hd->heap, hd->posn.rhdr.hdr.cmd, sizeof(hd->posn));
if (!hd->msg) {
comp_err(dev, "ipc_msg_init failed");
sof_dma_put(hd->dma);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int mfcc_free(struct processing_module *mod)
struct mfcc_comp_data *cd = module_get_private_data(mod);

comp_info(mod->dev, "entry");
ipc_msg_free(cd->msg);
mod_ipc_msg_free(mod, cd->msg);
cd->msg = NULL;
mod_data_blob_handler_free(mod, cd->model_handler);
mfcc_free_buffers(mod);
Expand Down
8 changes: 4 additions & 4 deletions src/audio/mfcc/mfcc_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ int mfcc_ipc_notification_init(struct processing_module *mod)
primary->r.type = SOF_IPC4_GLB_NOTIFICATION;
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
cd->msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan));
cd->msg = mod_ipc_msg_w_ext_init(mod, msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan));
if (!cd->msg) {
comp_err(dev, "Failed to initialize VAD notification");
return -ENOMEM;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/module_adapter/module/cadence_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static struct ipc_msg *cadence_codec_notification_init(struct processing_module
primary.r.type = SOF_IPC4_GLB_NOTIFICATION;
primary.r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
primary.r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
msg = ipc_msg_w_ext_init(primary.dat, 0, sizeof(*msg_module_data));
msg = mod_ipc_msg_w_ext_init(mod, primary.dat, 0, sizeof(*msg_module_data));
if (!msg)
return NULL;

Expand Down Expand Up @@ -366,7 +366,7 @@ static int cadence_codec_init(struct processing_module *mod)
if (setup_cfg)
mod_free(mod, setup_cfg->data);
free_notification:
ipc_msg_free(cd->msg);
mod_ipc_msg_free(mod, cd->msg);
free_cd:
mod_free(mod, cd);

Expand Down Expand Up @@ -568,7 +568,7 @@ static int ipc4_cadence_codec_free(struct processing_module *mod)
{
struct cadence_codec_data *cd = module_get_private_data(mod);

ipc_msg_free(cd->msg);
mod_ipc_msg_free(mod, cd->msg);

return cadence_codec_free(mod);
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio/pipeline/pipeline-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct pipeline *pipeline_new(struct k_heap *heap, uint32_t pipeline_id, uint32_
ipc_build_stream_posn(&posn, SOF_IPC_STREAM_TRIG_XRUN, p->comp_id);

if (posn.rhdr.hdr.size) {
p->msg = ipc_msg_init(posn.rhdr.hdr.cmd, posn.rhdr.hdr.size);
p->msg = ipc_msg_init(heap, posn.rhdr.hdr.cmd, posn.rhdr.hdr.size);
if (!p->msg) {
pipe_err(p, "ipc_msg_init failed");
goto free;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/sound_dose/sound_dose-ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ static struct ipc_msg *sound_dose_notification_init(struct processing_module *mo
primary->r.type = SOF_IPC4_GLB_NOTIFICATION;
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload));
msg = mod_ipc_msg_w_ext_init(mod, msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload));
if (!msg)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion src/audio/sound_dose/sound_dose.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ __cold static int sound_dose_free(struct processing_module *mod)
comp_dbg(mod->dev, "entry");

sound_dose_filters_free(cd);
ipc_msg_free(cd->msg);
mod_ipc_msg_free(mod, cd->msg);
rfree(cd->abi);
rfree(cd);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/tdfb/tdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ static int tdfb_init(struct processing_module *mod)
err:
/* These are null if not used for IPC version */
mod_free(mod, cd->ctrl_data);
ipc_msg_free(cd->msg);
mod_ipc_msg_free(mod, cd->msg);
mod_data_blob_handler_free(mod, cd->model_handler);

err_free_cd:
Expand All @@ -691,7 +691,7 @@ static int tdfb_free(struct processing_module *mod)

comp_dbg(mod->dev, "entry");

ipc_msg_free(cd->msg);
mod_ipc_msg_free(mod, cd->msg);
tdfb_free_delaylines(mod);
mod_data_blob_handler_free(mod, cd->model_handler);
tdfb_direction_free(mod);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/tdfb/tdfb_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int init_get_ctl_ipc(struct processing_module *mod)

cd->ctrl_data->rhdr.hdr.cmd = SOF_IPC_GLB_COMP_MSG | SOF_IPC_COMP_GET_VALUE | comp_id;
cd->ctrl_data->rhdr.hdr.size = TDFB_GET_CTRL_DATA_SIZE;
cd->msg = ipc_msg_init(cd->ctrl_data->rhdr.hdr.cmd, cd->ctrl_data->rhdr.hdr.size);
cd->msg = mod_ipc_msg_init(mod, cd->ctrl_data->rhdr.hdr.cmd, cd->ctrl_data->rhdr.hdr.size);

cd->ctrl_data->comp_id = comp_id;
cd->ctrl_data->type = SOF_CTRL_TYPE_VALUE_CHAN_GET;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/tdfb/tdfb_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ static struct ipc_msg *tdfb_notification_init(struct processing_module *mod,
primary->r.type = SOF_IPC4_GLB_NOTIFICATION;
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
msg = mod_ipc_msg_w_ext_init(mod, msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan));
if (!msg)
Expand Down
17 changes: 17 additions & 0 deletions src/include/ipc4/notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,21 @@ void send_mixer_underrun_notif_msg(uint32_t resource_id, uint32_t eos_flag, uint
uint32_t expected_data_mixed);
void ipc4_update_notification_mask(uint32_t ntfy_mask, uint32_t enabled_mask);

#ifdef CONFIG_SOF_USERSPACE_LL

__syscall bool send_resource_notif(uint32_t resource_id, uint32_t event_type,
uint32_t resource_type, void *data, uint32_t data_size);

bool z_impl_send_resource_notif(uint32_t resource_id, uint32_t event_type,
uint32_t resource_type, void *data, uint32_t data_size);

#include <zephyr/syscalls/notification.h>

#else

bool send_resource_notif(uint32_t resource_id, uint32_t event_type,
uint32_t resource_type, void *data, uint32_t data_size);

#endif /* CONFIG_SOF_USERSPACE_LL */

#endif /* __IPC4_NOTIFICATION_H__ */
60 changes: 60 additions & 0 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <sof/audio/component.h>
#include <sof/audio/sink_api.h>
#include <sof/audio/source_api.h>
#include <sof/ipc/msg.h>
#include "module_interface.h"

#include <sof/compiler_attributes.h>
Expand Down Expand Up @@ -239,6 +240,65 @@ static inline void *mod_zalloc(struct processing_module *mod, size_t size)
return ret;
}

/**
* \brief Initialize a new IPC message using the module allocator.
* @param mod Module to allocate from
* @param header Message header metadata
* @param extension Message header extension metadata
* @param size Message data size in bytes.
* @return New IPC message.
*/
static inline struct ipc_msg *mod_ipc_msg_w_ext_init(struct processing_module *mod,
uint32_t header,
uint32_t extension,
uint32_t size)
{
Comment on lines +251 to +255
struct ipc_msg *msg;

msg = mod_zalloc(mod, sizeof(*msg));
if (!msg)
return NULL;

if (size) {
msg->tx_data = mod_zalloc(mod, size);
if (!msg->tx_data) {
mod_free(mod, msg);
return NULL;
}
}

msg->header = header;
msg->extension = extension;
msg->tx_size = size;
list_init(&msg->list);

return msg;
}

static inline struct ipc_msg *mod_ipc_msg_init(struct processing_module *mod,
uint32_t header, uint32_t size)
{
return mod_ipc_msg_w_ext_init(mod, header, 0, size);
}

/**
* \brief Free an IPC message allocated with mod_ipc_msg_init() or
* mod_ipc_msg_w_ext_init().
* @param mod Module that owns the message.
* @param msg Message to free (may be NULL).
*/
static inline void mod_ipc_msg_free(struct processing_module *mod,
struct ipc_msg *msg)
{
if (!msg)
return;

ipc_msg_list_remove(msg);

mod_free(mod, msg->tx_data);
mod_free(mod, msg);
}

#if CONFIG_COMP_BLOB
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
__syscall struct comp_data_blob_handler *mod_data_blob_handler_new(struct processing_module *mod);
Expand Down
30 changes: 30 additions & 0 deletions src/include/sof/ipc/ipc_msg_list_remove.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2026 Intel Corporation. All rights reserved.
*/

#ifndef __SOF_IPC_IPC_MSG_LIST_REMOVE_H__
#define __SOF_IPC_IPC_MSG_LIST_REMOVE_H__

struct ipc_msg;

/**
* \brief Remove an IPC message from the send queue.
*
* Acquires the IPC lock and removes the message from its list.
* Safe to call from userspace.
*
* @param msg The IPC message to remove from the queue.
*/
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_USERSPACE_LL)
__syscall void ipc_msg_list_remove(struct ipc_msg *msg);
#else
void z_impl_ipc_msg_list_remove(struct ipc_msg *msg);
#define ipc_msg_list_remove z_impl_ipc_msg_list_remove
#endif

#if defined(__ZEPHYR__) && defined(CONFIG_SOF_USERSPACE_LL)
#include <zephyr/syscalls/ipc_msg_list_remove.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this could be part of the first if branch as the condition is the same..

#endif

#endif /* __SOF_IPC_IPC_MSG_LIST_REMOVE_H__ */
32 changes: 32 additions & 0 deletions src/include/sof/ipc/ipc_msg_send.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2026 Intel Corporation. All rights reserved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the all rights reserved.

*/

#ifndef __SOF_IPC_IPC_MSG_SEND_H__
#define __SOF_IPC_IPC_MSG_SEND_H__

#include <stdbool.h>

struct ipc_msg;

/**
* \brief Queues an IPC message for transmission.
* @param msg The IPC message.
* @param data The message data.
* @param high_priority True if a high priority message.
*/
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_USERSPACE_LL)
__syscall void ipc_msg_send(struct ipc_msg *msg, void *data,
bool high_priority);
#else
void z_impl_ipc_msg_send(struct ipc_msg *msg, void *data,
bool high_priority);
#define ipc_msg_send z_impl_ipc_msg_send
#endif

#if defined(__ZEPHYR__) && defined(CONFIG_SOF_USERSPACE_LL)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here

#include <zephyr/syscalls/ipc_msg_send.h>
#endif

#endif /* __SOF_IPC_IPC_MSG_SEND_H__ */
Loading
Loading