All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	bgoswami@codeaurora.org, lgirdwood@gmail.com, tiwai@suse.de,
	plai@codeaurora.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 12/16] ASoC: qcom: audioreach: add q6prm support
Date: Thu, 15 Jul 2021 11:32:33 +0100	[thread overview]
Message-ID: <50357647-7478-3848-74c4-1de50851d5d0@linaro.org> (raw)
In-Reply-To: <65c935b8-fb36-8da7-9a27-1ecd6559c41b@linux.intel.com>



On 14/07/2021 18:09, Pierre-Louis Bossart wrote:
> 
> 
> 
>> +static int q6prm_send_cmd_sync(struct q6prm *prm, struct gpr_pkt *pkt,
>> +			uint32_t rsp_opcode)
>> +{
>> +	gpr_device_t *gdev = prm->gdev;
>> +	struct gpr_hdr *hdr = &pkt->hdr;
>> +	int rc;
>> +
>> +	mutex_lock(&prm->lock);
>> +	prm->result.opcode = 0;
>> +	prm->result.status = 0;
>> +
>> +	rc = gpr_send_pkt(prm->gdev, pkt);
>> +	if (rc < 0)
>> +		goto err;
>> +
>> +	if (rsp_opcode)
>> +		rc = wait_event_timeout(prm->wait,
>> +					(prm->result.opcode == hdr->opcode) ||
>> +					(prm->result.opcode == rsp_opcode),
>> +					5 * HZ);
>> +	else
>> +		rc = wait_event_timeout(prm->wait,
>> +					(prm->result.opcode == hdr->opcode),
>> +					5 * HZ);
>> +
>> +	if (!rc) {
>> +		dev_err(&gdev->dev, "CMD timeout for [%x] opcode\n",
>> +			hdr->opcode);
>> +		rc = -ETIMEDOUT;
>> +	} else if (prm->result.status > 0) {
>> +		dev_err(&gdev->dev, "DSP returned error[%x] %x\n", hdr->opcode,
>> +			prm->result.status);
>> +		rc = -EINVAL;
>> +	} else {
>> +		dev_err(&gdev->dev, "DSP returned [%x]\n",
>> +			prm->result.status);
>> +		rc = 0;
>> +	}
>> +
>> +err:
>> +	mutex_unlock(&prm->lock);
>> +	return rc;
>> +}
> 
> In patch7 you had more or less the same code. can a helper be used?

Its possible, will abstract this out in audioreach.c.


> 
> +int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph,
> +				   struct gpr_pkt *pkt, uint32_t rsp_opcode)
> +{
> +
> +	struct device *dev = graph->dev;
> +	struct gpr_hdr *hdr = &pkt->hdr;
> +	int rc;
> +
> +	mutex_lock(&graph->cmd_lock);
> +	graph->result.opcode = 0;
> +	graph->result.status = 0;
> +
> +	rc = gpr_send_port_pkt(graph->port, pkt);
> +	if (rc < 0)
> +		goto err;
> +
> +	if (rsp_opcode)
> +		rc = wait_event_timeout(graph->cmd_wait,
> +					(graph->result.opcode == hdr->opcode) ||
> +					(graph->result.opcode == rsp_opcode),
> +					5 * HZ);
> +	else
> +		rc = wait_event_timeout(graph->cmd_wait,
> +					(graph->result.opcode == hdr->opcode),
> +					5 * HZ);
> +
> +	if (!rc) {
> +		dev_err(dev, "CMD timeout for [%x] opcode\n", hdr->opcode);
> +		rc = -ETIMEDOUT;
> +	} else if (graph->result.status > 0) {
> +		dev_err(dev, "DSP returned error[%x] %x\n", hdr->opcode,
> +			graph->result.status);
> +		rc = -EINVAL;
> +	} else {
> +		dev_err(dev, "DSP returned [%x]\n", graph->result.status);
> +		rc = 0;
> +	}
> +
> +err:
> +	mutex_unlock(&graph->cmd_lock);
> +	return rc;
> +}
> +EXPORT_SYMBOL_GPL(audioreach_graph_send_cmd_sync);
> 
> 
>> +static int q6prm_set_hw_core_req(struct device *dev, uint32_t hw_block_id,   bool enable)
>> +{
>> +	struct prm_cmd_request_hw_core *req;
>> +	struct apm_module_param_data *param_data;
>> +	struct gpr_pkt *pkt;
>> +	struct q6prm *prm = dev_get_drvdata(dev);
>> +	gpr_device_t *gdev  = prm->gdev;
>> +	void *p;
>> +	int rc = 0;
>> +	uint32_t opcode, rsp_opcode;
>> +
>> +	if (enable) {
>> +		opcode = PRM_CMD_REQUEST_HW_RSC;
>> +		rsp_opcode = PRM_CMD_RSP_REQUEST_HW_RSC;
>> +	} else {
>> +		opcode = PRM_CMD_RELEASE_HW_RSC;
>> +		rsp_opcode = PRM_CMD_RSP_RELEASE_HW_RSC;
>> +	}
>> +
>> +	p = audioreach_alloc_cmd_pkt(sizeof(*req), opcode, 0, gdev->svc.id,
>> +				     GPR_PRM_MODULE_IID);
>> +	if (IS_ERR(p))
>> +		return -ENOMEM;
>> +
>> +	pkt = p;
>> +	req = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
>> +
>> +	param_data = &req->param_data;
>> +
>> +	param_data->module_instance_id = GPR_PRM_MODULE_IID;
>> +	param_data->error_code = 0;
>> +	param_data->param_id = PARAM_ID_RSC_HW_CORE;
>> +	param_data->param_size = sizeof(*req) - APM_MODULE_PARAM_DATA_SIZE;
>> +
>> +	req->hw_clk_id = hw_block_id;
>> +
>> +	q6prm_send_cmd_sync(prm, pkt, rsp_opcode);
>> +
>> +	kfree(pkt);
>> +
>> +	return rc;
> 
> rc is not assigned, should this not trap the result of sending a command?
My bad! will fix such instances.


--srini

WARNING: multiple messages have this Message-ID (diff)
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	bgoswami@codeaurora.org, tiwai@suse.de, plai@codeaurora.org,
	lgirdwood@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 12/16] ASoC: qcom: audioreach: add q6prm support
Date: Thu, 15 Jul 2021 11:32:33 +0100	[thread overview]
Message-ID: <50357647-7478-3848-74c4-1de50851d5d0@linaro.org> (raw)
In-Reply-To: <65c935b8-fb36-8da7-9a27-1ecd6559c41b@linux.intel.com>



On 14/07/2021 18:09, Pierre-Louis Bossart wrote:
> 
> 
> 
>> +static int q6prm_send_cmd_sync(struct q6prm *prm, struct gpr_pkt *pkt,
>> +			uint32_t rsp_opcode)
>> +{
>> +	gpr_device_t *gdev = prm->gdev;
>> +	struct gpr_hdr *hdr = &pkt->hdr;
>> +	int rc;
>> +
>> +	mutex_lock(&prm->lock);
>> +	prm->result.opcode = 0;
>> +	prm->result.status = 0;
>> +
>> +	rc = gpr_send_pkt(prm->gdev, pkt);
>> +	if (rc < 0)
>> +		goto err;
>> +
>> +	if (rsp_opcode)
>> +		rc = wait_event_timeout(prm->wait,
>> +					(prm->result.opcode == hdr->opcode) ||
>> +					(prm->result.opcode == rsp_opcode),
>> +					5 * HZ);
>> +	else
>> +		rc = wait_event_timeout(prm->wait,
>> +					(prm->result.opcode == hdr->opcode),
>> +					5 * HZ);
>> +
>> +	if (!rc) {
>> +		dev_err(&gdev->dev, "CMD timeout for [%x] opcode\n",
>> +			hdr->opcode);
>> +		rc = -ETIMEDOUT;
>> +	} else if (prm->result.status > 0) {
>> +		dev_err(&gdev->dev, "DSP returned error[%x] %x\n", hdr->opcode,
>> +			prm->result.status);
>> +		rc = -EINVAL;
>> +	} else {
>> +		dev_err(&gdev->dev, "DSP returned [%x]\n",
>> +			prm->result.status);
>> +		rc = 0;
>> +	}
>> +
>> +err:
>> +	mutex_unlock(&prm->lock);
>> +	return rc;
>> +}
> 
> In patch7 you had more or less the same code. can a helper be used?

Its possible, will abstract this out in audioreach.c.


> 
> +int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph,
> +				   struct gpr_pkt *pkt, uint32_t rsp_opcode)
> +{
> +
> +	struct device *dev = graph->dev;
> +	struct gpr_hdr *hdr = &pkt->hdr;
> +	int rc;
> +
> +	mutex_lock(&graph->cmd_lock);
> +	graph->result.opcode = 0;
> +	graph->result.status = 0;
> +
> +	rc = gpr_send_port_pkt(graph->port, pkt);
> +	if (rc < 0)
> +		goto err;
> +
> +	if (rsp_opcode)
> +		rc = wait_event_timeout(graph->cmd_wait,
> +					(graph->result.opcode == hdr->opcode) ||
> +					(graph->result.opcode == rsp_opcode),
> +					5 * HZ);
> +	else
> +		rc = wait_event_timeout(graph->cmd_wait,
> +					(graph->result.opcode == hdr->opcode),
> +					5 * HZ);
> +
> +	if (!rc) {
> +		dev_err(dev, "CMD timeout for [%x] opcode\n", hdr->opcode);
> +		rc = -ETIMEDOUT;
> +	} else if (graph->result.status > 0) {
> +		dev_err(dev, "DSP returned error[%x] %x\n", hdr->opcode,
> +			graph->result.status);
> +		rc = -EINVAL;
> +	} else {
> +		dev_err(dev, "DSP returned [%x]\n", graph->result.status);
> +		rc = 0;
> +	}
> +
> +err:
> +	mutex_unlock(&graph->cmd_lock);
> +	return rc;
> +}
> +EXPORT_SYMBOL_GPL(audioreach_graph_send_cmd_sync);
> 
> 
>> +static int q6prm_set_hw_core_req(struct device *dev, uint32_t hw_block_id,   bool enable)
>> +{
>> +	struct prm_cmd_request_hw_core *req;
>> +	struct apm_module_param_data *param_data;
>> +	struct gpr_pkt *pkt;
>> +	struct q6prm *prm = dev_get_drvdata(dev);
>> +	gpr_device_t *gdev  = prm->gdev;
>> +	void *p;
>> +	int rc = 0;
>> +	uint32_t opcode, rsp_opcode;
>> +
>> +	if (enable) {
>> +		opcode = PRM_CMD_REQUEST_HW_RSC;
>> +		rsp_opcode = PRM_CMD_RSP_REQUEST_HW_RSC;
>> +	} else {
>> +		opcode = PRM_CMD_RELEASE_HW_RSC;
>> +		rsp_opcode = PRM_CMD_RSP_RELEASE_HW_RSC;
>> +	}
>> +
>> +	p = audioreach_alloc_cmd_pkt(sizeof(*req), opcode, 0, gdev->svc.id,
>> +				     GPR_PRM_MODULE_IID);
>> +	if (IS_ERR(p))
>> +		return -ENOMEM;
>> +
>> +	pkt = p;
>> +	req = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
>> +
>> +	param_data = &req->param_data;
>> +
>> +	param_data->module_instance_id = GPR_PRM_MODULE_IID;
>> +	param_data->error_code = 0;
>> +	param_data->param_id = PARAM_ID_RSC_HW_CORE;
>> +	param_data->param_size = sizeof(*req) - APM_MODULE_PARAM_DATA_SIZE;
>> +
>> +	req->hw_clk_id = hw_block_id;
>> +
>> +	q6prm_send_cmd_sync(prm, pkt, rsp_opcode);
>> +
>> +	kfree(pkt);
>> +
>> +	return rc;
> 
> rc is not assigned, should this not trap the result of sending a command?
My bad! will fix such instances.


--srini

  reply	other threads:[~2021-07-15 10:32 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 15:30 [PATCH v2 00/16] ASoC: qcom: Add AudioReach support Srinivas Kandagatla
2021-07-14 15:30 ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 01/16] soc: dt-bindings: qcom: add gpr bindings Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 16:05   ` Pierre-Louis Bossart
2021-07-14 16:05     ` Pierre-Louis Bossart
2021-07-14 15:30 ` [PATCH v2 02/16] soc: qcom: apr: make code more reuseable Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 20:36   ` kernel test robot
2021-07-14 20:36     ` kernel test robot
2021-07-14 20:36     ` kernel test robot
2021-07-14 15:30 ` [PATCH v2 03/16] soc: qcom: apr: Add GPR support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 16:20   ` Pierre-Louis Bossart
2021-07-14 16:20     ` Pierre-Louis Bossart
2021-07-15 10:31     ` Srinivas Kandagatla
2021-07-15 10:31       ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 04/16] ASoC: qcom: dt-bindings: add bindings Audio Processing manager Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-28 17:36   ` Rob Herring
2021-07-28 17:36     ` Rob Herring
2021-07-29  9:18     ` Srinivas Kandagatla
2021-07-29  9:18       ` Srinivas Kandagatla
2021-07-29 11:13       ` Mark Brown
2021-07-29 11:13         ` Mark Brown
2021-07-30 11:06         ` Srinivas Kandagatla
2021-07-30 11:06           ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 05/16] ASoC: qcom: audioreach: add basic pkt alloc support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 16:30   ` Pierre-Louis Bossart
2021-07-14 16:30     ` Pierre-Louis Bossart
2021-07-15 10:31     ` Srinivas Kandagatla
2021-07-15 10:31       ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 06/16] ASoC: qcom: audioreach: add q6apm support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 16:40   ` Pierre-Louis Bossart
2021-07-14 16:40     ` Pierre-Louis Bossart
2021-07-15 10:31     ` Srinivas Kandagatla
2021-07-15 10:31       ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 07/16] ASoC: qcom: audioreach: add module configuration command helpers Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 16:48   ` Pierre-Louis Bossart
2021-07-14 16:48     ` Pierre-Louis Bossart
2021-07-15 10:32     ` Srinivas Kandagatla
2021-07-15 10:32       ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 08/16] ASoC: qcom: audioreach: add topology support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 09/16] ASoC: qcom: audioreach: add q6apm-dai support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 16:59   ` Pierre-Louis Bossart
2021-07-14 16:59     ` Pierre-Louis Bossart
2021-07-15 10:32     ` Srinivas Kandagatla
2021-07-15 10:32       ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 10/16] ASoC: qcom: audioreach: add bedai support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 17:03   ` Pierre-Louis Bossart
2021-07-14 17:03     ` Pierre-Louis Bossart
2021-07-15 10:32     ` Srinivas Kandagatla
2021-07-15 10:32       ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 11/16] ASoC: qcom: dt-bindings: add bindings for Proxy Resource Manager Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 12/16] ASoC: qcom: audioreach: add q6prm support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 17:09   ` Pierre-Louis Bossart
2021-07-14 17:09     ` Pierre-Louis Bossart
2021-07-15 10:32     ` Srinivas Kandagatla [this message]
2021-07-15 10:32       ` Srinivas Kandagatla
2021-07-15  7:40   ` kernel test robot
2021-07-15  7:40     ` kernel test robot
2021-07-15  7:40     ` kernel test robot
2021-07-14 15:30 ` [PATCH v2 13/16] ASoC: qcom: dt-bindings: add audioreach soundcard compatibles Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 14/16] ASoC: qcom: audioreach: add volume ctrl module support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 15/16] ASoC: qcom: audioreach: topology add dapm pga support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 15:30 ` [PATCH v2 16/16] ASoC: qcom: sm8250: Add audioreach support Srinivas Kandagatla
2021-07-14 15:30   ` Srinivas Kandagatla
2021-07-14 17:12   ` Pierre-Louis Bossart
2021-07-14 17:12     ` Pierre-Louis Bossart
2021-07-15 10:32     ` Srinivas Kandagatla
2021-07-15 10:32       ` Srinivas Kandagatla

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=50357647-7478-3848-74c4-1de50851d5d0@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=plai@codeaurora.org \
    --cc=robh@kernel.org \
    --cc=tiwai@suse.de \
    /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.