Skip to content

Commit

Permalink
ASoC: SOF: prepare code to allocate IPC messages in fw_ready
Browse files Browse the repository at this point in the history
The fixed maximum size of IPC message does not allow for large
transfers, e.g. for filter data. Currently such messages will
be divided into smaller pieces and sent to firmware in multiple
chunks. For future IPC, this strategy is not suitable.

The maximum IPC message size is limited by host box size which
can be known when firmware is ready, so the fw_ready callback
can allocate IPC messages with platform-specific sizes instead
of the current fixed-size.

To be compatible with released firmware, current platforms will
still use SOF_IPC_MSG_MAX_SIZE. For future platforms, there will
be a new fw_ready function and the platform-specific allocation
will take place there.

Signed-off-by: Rander Wang <[email protected]>
  • Loading branch information
RanderWang authored and plbossart committed Aug 26, 2021
1 parent eb55816 commit c4bbda2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
27 changes: 16 additions & 11 deletions sound/soc/sof/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,22 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev)
}
EXPORT_SYMBOL(snd_sof_ipc_valid);

int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev)
{
struct snd_sof_ipc_msg *msg;

msg = &sdev->ipc->msg;
msg->msg_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE, GFP_KERNEL);
if (!msg->msg_data)
return -ENOMEM;

msg->reply_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE, GFP_KERNEL);
if (!msg->reply_data)
return -ENOMEM;

return 0;
}

struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
{
struct snd_sof_ipc *ipc;
Expand All @@ -929,17 +945,6 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
/* indicate that we aren't sending a message ATM */
msg->ipc_complete = true;

/* pre-allocate message data */
msg->msg_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE,
GFP_KERNEL);
if (!msg->msg_data)
return NULL;

msg->reply_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE,
GFP_KERNEL);
if (!msg->reply_data)
return NULL;

init_waitqueue_head(&msg->waitq);

return ipc;
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/sof/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/firmware.h>
#include <sound/sof.h>
#include <sound/sof/ext_manifest.h>
#include "sof-priv.h"
#include "ops.h"

static int get_ext_windows(struct snd_sof_dev *sdev,
Expand Down Expand Up @@ -517,7 +518,7 @@ int sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)

sof_get_windows(sdev);

return 0;
return sof_ipc_init_msg_memory(sdev);
}
EXPORT_SYMBOL(sof_fw_ready);

Expand Down
1 change: 1 addition & 0 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header,
int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, u32 header,
void *msg_data, size_t msg_bytes,
void *reply_data, size_t reply_bytes);
int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev);

/*
* Trace/debug
Expand Down

0 comments on commit c4bbda2

Please sign in to comment.