ASoC: SOF: prepare code to allocate IPC messages in fw_ready
authorRander Wang <rander.wang@intel.com>
Fri, 8 Oct 2021 09:38:36 +0000 (12:38 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 8 Oct 2021 12:51:16 +0000 (13:51 +0100)
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>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Message-Id: <20211008093836.28210-1-peter.ujfalusi@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc.c
sound/soc/sof/loader.c
sound/soc/sof/sof-priv.h

index b2e556b64994f547c84ad7503f386d07b21413c7..e6c53c6c470e4fc7486617272ea4b171c2d787e2 100644 (file)
@@ -919,6 +919,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;
@@ -935,17 +951,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;
index c0aa9a5d1494a0c36780b79c0337b960bae1f841..12a1f3c14c5bfddcd3854620c31e192a349d5131 100644 (file)
@@ -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,
@@ -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);
 
index efaec2989a27bb7b7f8b5f5629c30ac1c6610cda..ba341b1bda0cb842cd9b3243ad16d6f10280bdcf 100644 (file)
@@ -526,6 +526,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