From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> To: kvm@vger.kernel.org Cc: linux-remoteproc@vger.kernel.org, virtualization@lists.linux-foundation.org, sound-open-firmware@alsa-project.org, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, Liam Girdwood <liam.r.girdwood@linux.intel.com>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, Ohad Ben-Cohen <ohad@wizery.com>, Bjorn Andersson <bjorn.andersson@linaro.org>, Mathieu Poirier <mathieu.poirier@linaro.org> Subject: [RFC 03/12] ASoC: SOF: support IPC with immediate response Date: Fri, 29 May 2020 09:37:13 +0200 [thread overview] Message-ID: <20200529073722.8184-4-guennadi.liakhovetski@linux.intel.com> (raw) In-Reply-To: <20200529073722.8184-1-guennadi.liakhovetski@linux.intel.com> Usually when an IPC message is sent, we have to wait for a reply from the DSP or from the host in the VirtIO case. However, sometimes in the VirtIO case a response is available immediately. Skip sleeping in such cases. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> --- sound/soc/sof/ipc.c | 11 +++++++---- sound/soc/sof/ops.h | 10 +++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index f7a0353..b3e1587 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -262,6 +262,12 @@ static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header, sdev->msg = msg; + /* + * If snd_sof_dsp_send_msg() returns a positive number it means, that a + * response is already available, no need to sleep waiting for it. In + * such a case msg->ipc_complete will stay true and tx_wait_done() will + * return immediately. + */ ret = snd_sof_dsp_send_msg(sdev, msg); /* Next reply that we receive will be related to this message */ if (!ret) @@ -279,10 +285,7 @@ static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header, ipc_log_header(sdev->dev, "ipc tx", msg->header); /* now wait for completion */ - if (!ret) - ret = tx_wait_done(ipc, msg, reply_data); - - return ret; + return tx_wait_done(ipc, msg, reply_data); } /* send IPC message from host to DSP */ diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index b21632f..bf91467 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -274,7 +274,15 @@ static inline void snd_sof_dsp_block_write(struct snd_sof_dev *sdev, u32 bar, sof_ops(sdev)->block_write(sdev, bar, offset, src, bytes); } -/* ipc */ +/** + * snd_sof_dsp_send_msg - call sdev ops to send a message + * @sdev: sdev context + * @msg: message to send + * + * Returns < 0 - an error code + * 0 - the message has been sent, wait for a reply + * > 0 - the message has been sent, a reply is already available + */ static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) { -- 1.9.3
WARNING: multiple messages have this Message-ID (diff)
From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> To: kvm@vger.kernel.org Cc: Ohad Ben-Cohen <ohad@wizery.com>, Mathieu Poirier <mathieu.poirier@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, linux-remoteproc@vger.kernel.org, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, virtualization@lists.linux-foundation.org, Liam Girdwood <liam.r.girdwood@linux.intel.com>, Bjorn Andersson <bjorn.andersson@linaro.org>, sound-open-firmware@alsa-project.org Subject: [RFC 03/12] ASoC: SOF: support IPC with immediate response Date: Fri, 29 May 2020 09:37:13 +0200 [thread overview] Message-ID: <20200529073722.8184-4-guennadi.liakhovetski@linux.intel.com> (raw) In-Reply-To: <20200529073722.8184-1-guennadi.liakhovetski@linux.intel.com> Usually when an IPC message is sent, we have to wait for a reply from the DSP or from the host in the VirtIO case. However, sometimes in the VirtIO case a response is available immediately. Skip sleeping in such cases. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> --- sound/soc/sof/ipc.c | 11 +++++++---- sound/soc/sof/ops.h | 10 +++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index f7a0353..b3e1587 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -262,6 +262,12 @@ static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header, sdev->msg = msg; + /* + * If snd_sof_dsp_send_msg() returns a positive number it means, that a + * response is already available, no need to sleep waiting for it. In + * such a case msg->ipc_complete will stay true and tx_wait_done() will + * return immediately. + */ ret = snd_sof_dsp_send_msg(sdev, msg); /* Next reply that we receive will be related to this message */ if (!ret) @@ -279,10 +285,7 @@ static int sof_ipc_tx_message_unlocked(struct snd_sof_ipc *ipc, u32 header, ipc_log_header(sdev->dev, "ipc tx", msg->header); /* now wait for completion */ - if (!ret) - ret = tx_wait_done(ipc, msg, reply_data); - - return ret; + return tx_wait_done(ipc, msg, reply_data); } /* send IPC message from host to DSP */ diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index b21632f..bf91467 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -274,7 +274,15 @@ static inline void snd_sof_dsp_block_write(struct snd_sof_dev *sdev, u32 bar, sof_ops(sdev)->block_write(sdev, bar, offset, src, bytes); } -/* ipc */ +/** + * snd_sof_dsp_send_msg - call sdev ops to send a message + * @sdev: sdev context + * @msg: message to send + * + * Returns < 0 - an error code + * 0 - the message has been sent, wait for a reply + * > 0 - the message has been sent, a reply is already available + */ static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) { -- 1.9.3
next prev parent reply other threads:[~2020-05-29 7:38 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-29 7:37 [RFC 00/12] Audio DSP VirtIO and vhost drivers Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 01/12] ASoC: add function parameters to enable forced path pruning Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 02/12] ASoC: SOF: extract firmware-related operation into a function Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski [this message] 2020-05-29 7:37 ` [RFC 03/12] ASoC: SOF: support IPC with immediate response Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 04/12] ASoC: SOF: add a power status IPC Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 05/12] ASoC: SOF: add two helper lookup functions Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 06/12] ASoC: SOF: add an RPMsg VirtIO DSP driver Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 07/12] ASoC: SOF: use a macro instead of a hard-coded value Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 08/12] ASoC: SOF: add a vhost driver: sound part Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 09/12] ASoC: SOF: VirtIO: free guest pipelines upon termination Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 10/12] vhost: add an SOF Audio DSP driver Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 11/12] rpmsg: increase buffer size and reduce buffer number Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-06-04 19:58 ` Mathieu Poirier 2020-06-05 6:37 ` Guennadi Liakhovetski 2020-05-29 7:37 ` [RFC 12/12] rpmsg: add a device ID to also bind to the ADSP device Guennadi Liakhovetski 2020-05-29 7:37 ` Guennadi Liakhovetski 2020-06-04 20:01 ` Mathieu Poirier 2020-06-05 6:46 ` Guennadi Liakhovetski 2020-06-08 16:17 ` Mathieu Poirier 2020-06-08 17:02 ` Guennadi Liakhovetski 2020-06-08 17:02 ` Guennadi Liakhovetski 2020-06-09 16:26 ` Mathieu Poirier
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=20200529073722.8184-4-guennadi.liakhovetski@linux.intel.com \ --to=guennadi.liakhovetski@linux.intel.com \ --cc=bjorn.andersson@linaro.org \ --cc=jasowang@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=liam.r.girdwood@linux.intel.com \ --cc=linux-remoteproc@vger.kernel.org \ --cc=mathieu.poirier@linaro.org \ --cc=mst@redhat.com \ --cc=ohad@wizery.com \ --cc=pierre-louis.bossart@linux.intel.com \ --cc=sound-open-firmware@alsa-project.org \ --cc=virtualization@lists.linux-foundation.org \ /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: linkBe 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.