All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, robh+dt@kernel.org, plai@codeaurora.org,
	bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Subject: [PATCH 4/8] ASoC: q6dsp: q6afe: add global q6afe waitqueue
Date: Thu, 10 Sep 2020 11:17:28 +0100	[thread overview]
Message-ID: <20200910101732.23484-5-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20200910101732.23484-1-srinivas.kandagatla@linaro.org>

In some cases like clocks q6afe would have to process commands
without an associated q6afe port, in such cases waitqueue is
required at global level to wait for the command to finish.
This patch also adds the command result to go with this waitqueue.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/qcom/qdsp6/q6afe.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index f934c69f0a14..2a8e3c3acb10 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -362,6 +362,8 @@ struct q6afe {
 	struct device *dev;
 	struct q6core_svc_api_info ainfo;
 	struct mutex lock;
+	struct aprv2_ibasic_rsp_result_t result;
+	wait_queue_head_t wait;
 	struct list_head port_list;
 	spinlock_t port_list_lock;
 };
@@ -905,11 +907,20 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
 			    struct q6afe_port *port, uint32_t rsp_opcode)
 {
 	wait_queue_head_t *wait = &port->wait;
+	struct aprv2_ibasic_rsp_result_t *result;
 	int ret;
 
 	mutex_lock(&afe->lock);
-	port->result.opcode = 0;
-	port->result.status = 0;
+	if (port) {
+		wait = &port->wait;
+		result = &port->result;
+	} else {
+		result = &afe->result;
+		wait = &afe->wait;
+	}
+
+	result->opcode = 0;
+	result->status = 0;
 
 	ret = apr_send_pkt(afe->apr, pkt);
 	if (ret < 0) {
@@ -918,13 +929,13 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
 		goto err;
 	}
 
-	ret = wait_event_timeout(*wait, (port->result.opcode == rsp_opcode),
+	ret = wait_event_timeout(*wait, (result->opcode == rsp_opcode),
 				 msecs_to_jiffies(TIMEOUT_MS));
 	if (!ret) {
 		ret = -ETIMEDOUT;
-	} else if (port->result.status > 0) {
+	} else if (result->status > 0) {
 		dev_err(afe->dev, "DSP returned error[%x]\n",
-			port->result.status);
+			result->status);
 		ret = -EINVAL;
 	} else {
 		ret = 0;
@@ -1594,6 +1605,7 @@ static int q6afe_probe(struct apr_device *adev)
 	q6core_get_svc_api_info(adev->svc_id, &afe->ainfo);
 	afe->apr = adev;
 	mutex_init(&afe->lock);
+	init_waitqueue_head(&afe->wait);
 	afe->dev = dev;
 	INIT_LIST_HEAD(&afe->port_list);
 	spin_lock_init(&afe->port_list_lock);
-- 
2.21.0


WARNING: multiple messages have this Message-ID (diff)
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: broonie@kernel.org
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	bgoswami@codeaurora.org, linux-kernel@vger.kernel.org,
	plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com,
	robh+dt@kernel.org,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Subject: [PATCH 4/8] ASoC: q6dsp: q6afe: add global q6afe waitqueue
Date: Thu, 10 Sep 2020 11:17:28 +0100	[thread overview]
Message-ID: <20200910101732.23484-5-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20200910101732.23484-1-srinivas.kandagatla@linaro.org>

In some cases like clocks q6afe would have to process commands
without an associated q6afe port, in such cases waitqueue is
required at global level to wait for the command to finish.
This patch also adds the command result to go with this waitqueue.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/qcom/qdsp6/q6afe.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index f934c69f0a14..2a8e3c3acb10 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -362,6 +362,8 @@ struct q6afe {
 	struct device *dev;
 	struct q6core_svc_api_info ainfo;
 	struct mutex lock;
+	struct aprv2_ibasic_rsp_result_t result;
+	wait_queue_head_t wait;
 	struct list_head port_list;
 	spinlock_t port_list_lock;
 };
@@ -905,11 +907,20 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
 			    struct q6afe_port *port, uint32_t rsp_opcode)
 {
 	wait_queue_head_t *wait = &port->wait;
+	struct aprv2_ibasic_rsp_result_t *result;
 	int ret;
 
 	mutex_lock(&afe->lock);
-	port->result.opcode = 0;
-	port->result.status = 0;
+	if (port) {
+		wait = &port->wait;
+		result = &port->result;
+	} else {
+		result = &afe->result;
+		wait = &afe->wait;
+	}
+
+	result->opcode = 0;
+	result->status = 0;
 
 	ret = apr_send_pkt(afe->apr, pkt);
 	if (ret < 0) {
@@ -918,13 +929,13 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
 		goto err;
 	}
 
-	ret = wait_event_timeout(*wait, (port->result.opcode == rsp_opcode),
+	ret = wait_event_timeout(*wait, (result->opcode == rsp_opcode),
 				 msecs_to_jiffies(TIMEOUT_MS));
 	if (!ret) {
 		ret = -ETIMEDOUT;
-	} else if (port->result.status > 0) {
+	} else if (result->status > 0) {
 		dev_err(afe->dev, "DSP returned error[%x]\n",
-			port->result.status);
+			result->status);
 		ret = -EINVAL;
 	} else {
 		ret = 0;
@@ -1594,6 +1605,7 @@ static int q6afe_probe(struct apr_device *adev)
 	q6core_get_svc_api_info(adev->svc_id, &afe->ainfo);
 	afe->apr = adev;
 	mutex_init(&afe->lock);
+	init_waitqueue_head(&afe->wait);
 	afe->dev = dev;
 	INIT_LIST_HEAD(&afe->port_list);
 	spin_lock_init(&afe->port_list_lock);
-- 
2.21.0


  parent reply	other threads:[~2020-09-10 10:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 10:17 [PATCH 0/8] ASoC: q6dsp: Add support to Codec Ports Srinivas Kandagatla
2020-09-10 10:17 ` Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 1/8] ASoC: q6dsp: q6afe: add support to Codec DMA ports Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 2/8] ASoC: q6dsp: q6routing: " Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 3/8] ASoC: q6dsp: q6afe: prepare afe_apr_send_pkt to take response opcode Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 10:17 ` Srinivas Kandagatla [this message]
2020-09-10 10:17   ` [PATCH 4/8] ASoC: q6dsp: q6afe: add global q6afe waitqueue Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 5/8] ASoC: q6dsp: q6afe: add lpass hw voting support Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 6/8] ASoC: q6dsp: q6afe: update q6afe_set_param to support global clocks Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 7/8] ASoC: q6dsp: q6afe: add codec lpass clocks Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 10:17 ` [PATCH 8/8] ASoC: q6dsp: q6afe-dai: add support to Codec DMA ports Srinivas Kandagatla
2020-09-10 10:17   ` Srinivas Kandagatla
2020-09-10 12:51 ` [PATCH 0/8] ASoC: q6dsp: Add support to Codec Ports Mark Brown
2020-09-10 12:51   ` 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=20200910101732.23484-5-srinivas.kandagatla@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=plai@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.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.