From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com,
yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.intel.com,
ranjani.sridharan@linux.intel.com, rander.wang@intel.com,
daniel.baluta@nxp.com
Subject: [PATCH 2/3] ASoC: SOF: ipc: Drop header parameter from sof_ipc_tx_message_unlocked()
Date: Fri, 28 Jan 2022 15:36:19 +0200 [thread overview]
Message-ID: <20220128133620.9411-3-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20220128133620.9411-1-peter.ujfalusi@linux.intel.com>
The snd_sof_ipc_msg.header is not used by platform code, there is no need
to update it and the 'header' parameter for sof_ipc_tx_message_unlocked()
can be dropped at the same time.
Instead of using the header parameter passed by the caller (which does by
setting it to the hdr->cmd) use the hdr->cmd directly when logging.
At the same time make sure that there is a message passed to the tx_message
function.
All instances of the tx_message passes an IPC message, this check is placed
to make sure the future users can not introduce bugs.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
sound/soc/sof/ipc.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index 5bcf906d90af..ec51daed8b31 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -294,14 +294,20 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,
}
/* send IPC message from host to DSP */
-static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header,
+static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc,
void *msg_data, size_t msg_bytes,
void *reply_data, size_t reply_bytes)
{
+ struct sof_ipc_cmd_hdr *hdr = msg_data;
struct snd_sof_dev *sdev = ipc->sdev;
struct snd_sof_ipc_msg *msg;
int ret;
+ if (!msg_data || msg_bytes < sizeof(*hdr)) {
+ dev_err_ratelimited(sdev->dev, "No IPC message to send\n");
+ return -EINVAL;
+ }
+
if (ipc->disable_ipc_tx || sdev->fw_state != SOF_FW_BOOT_COMPLETE)
return -ENODEV;
@@ -314,15 +320,13 @@ static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header,
/* initialise the message */
msg = &ipc->msg;
- msg->header = header;
+ /* attach message data */
+ memcpy(msg->msg_data, msg_data, msg_bytes);
msg->msg_size = msg_bytes;
+
msg->reply_size = reply_bytes;
msg->reply_error = 0;
- /* attach any data */
- if (msg_bytes)
- memcpy(msg->msg_data, msg_data, msg_bytes);
-
sdev->msg = msg;
ret = snd_sof_dsp_send_msg(sdev, msg);
@@ -339,7 +343,7 @@ static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header,
return ret;
}
- ipc_log_header(sdev->dev, "ipc tx", msg->header);
+ ipc_log_header(sdev->dev, "ipc tx", hdr->cmd);
/* now wait for completion */
return tx_wait_done(ipc, msg, reply_data);
@@ -385,7 +389,7 @@ int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, u32 header,
/* Serialise IPC TX */
mutex_lock(&ipc->tx_mutex);
- ret = sof_ipc_tx_message_unlocked(ipc, header, msg_data, msg_bytes,
+ ret = sof_ipc_tx_message_unlocked(ipc, msg_data, msg_bytes,
reply_data, reply_bytes);
mutex_unlock(&ipc->tx_mutex);
@@ -789,7 +793,6 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
memcpy(sparams->dst, sparams->src + offset, send_bytes);
err = sof_ipc_tx_message_unlocked(sdev->ipc,
- partdata->rhdr.hdr.cmd,
partdata,
partdata->rhdr.hdr.size,
partdata,
--
2.35.0
next prev parent reply other threads:[~2022-01-28 13:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 13:36 [PATCH 0/3] SoC: SOF: ipc: Optimizations for tx message Peter Ujfalusi
2022-01-28 13:36 ` [PATCH 1/3] ASoC: SOF: Intel: cnl: Use pm_gate->hdr.cmd in cnl_compact_ipc_compress() Peter Ujfalusi
2022-01-28 13:36 ` Peter Ujfalusi [this message]
2022-01-28 13:36 ` [PATCH 3/3] ASoC: SOF: ipc: Do not allocate buffer for msg_data Peter Ujfalusi
2022-01-28 23:47 ` [PATCH 0/3] SoC: SOF: ipc: Optimizations for tx message Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220128133620.9411-3-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rander.wang@intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.