Skip to content

Commit c4bbda2

Browse files
RanderWangplbossart
authored andcommitted
ASoC: SOF: prepare code to allocate IPC messages in fw_ready
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 <rander.wang@intel.com>
1 parent eb55816 commit c4bbda2

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

sound/soc/sof/ipc.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,22 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev)
913913
}
914914
EXPORT_SYMBOL(snd_sof_ipc_valid);
915915

916+
int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev)
917+
{
918+
struct snd_sof_ipc_msg *msg;
919+
920+
msg = &sdev->ipc->msg;
921+
msg->msg_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE, GFP_KERNEL);
922+
if (!msg->msg_data)
923+
return -ENOMEM;
924+
925+
msg->reply_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE, GFP_KERNEL);
926+
if (!msg->reply_data)
927+
return -ENOMEM;
928+
929+
return 0;
930+
}
931+
916932
struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
917933
{
918934
struct snd_sof_ipc *ipc;
@@ -929,17 +945,6 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
929945
/* indicate that we aren't sending a message ATM */
930946
msg->ipc_complete = true;
931947

932-
/* pre-allocate message data */
933-
msg->msg_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE,
934-
GFP_KERNEL);
935-
if (!msg->msg_data)
936-
return NULL;
937-
938-
msg->reply_data = devm_kzalloc(sdev->dev, SOF_IPC_MSG_MAX_SIZE,
939-
GFP_KERNEL);
940-
if (!msg->reply_data)
941-
return NULL;
942-
943948
init_waitqueue_head(&msg->waitq);
944949

945950
return ipc;

sound/soc/sof/loader.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/firmware.h>
1414
#include <sound/sof.h>
1515
#include <sound/sof/ext_manifest.h>
16+
#include "sof-priv.h"
1617
#include "ops.h"
1718

1819
static int get_ext_windows(struct snd_sof_dev *sdev,
@@ -517,7 +518,7 @@ int sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)
517518

518519
sof_get_windows(sdev);
519520

520-
return 0;
521+
return sof_ipc_init_msg_memory(sdev);
521522
}
522523
EXPORT_SYMBOL(sof_fw_ready);
523524

sound/soc/sof/sof-priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header,
542542
int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, u32 header,
543543
void *msg_data, size_t msg_bytes,
544544
void *reply_data, size_t reply_bytes);
545+
int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev);
545546

546547
/*
547548
* Trace/debug

0 commit comments

Comments
 (0)