public inbox for linux-arm-msm@vger.kernel.org
 help / color / mirror / Atom feed
From: Melody Olvera <quic_molvera@quicinc.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Andy Gross <agross@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Robert Marko <robimarko@gmail.com>,
	Guru Das Srinagesh <quic_gurus@quicinc.com>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	<linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-remoteproc@vger.kernel.org>
Subject: Re: [PATCH v2 6/7] remoteproc: qcom_q6v5_pas: Add support to attach a DSP
Date: Mon, 20 Mar 2023 16:46:04 -0700	[thread overview]
Message-ID: <e5753441-894d-e6f2-c628-eb931a6b2986@quicinc.com> (raw)
In-Reply-To: <20230316022740.umavd6jviftktag7@ripper>



On 3/15/2023 7:27 PM, Bjorn Andersson wrote:
> On Mon, Mar 06, 2023 at 03:12:01PM -0800, Melody Olvera wrote:
>> Some chipsets will have DSPs which will have begun running prior
>> to linux booting, so add support to late attach these DSPs by
>> adding support for:
>> - run-time checking of an offline or running DSP via rmb register
>> - a late attach framework to attach to the running DSP
>> - a handshake mechanism to ensure full and proper booting via rmb
>>
>> Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
>> ---
>>  drivers/remoteproc/qcom_q6v5_pas.c | 103 ++++++++++++++++++++++++++++-
>>  1 file changed, 102 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
>> index 0871108fb4dc..e22be6a029a8 100644
>> --- a/drivers/remoteproc/qcom_q6v5_pas.c
>> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
>> @@ -242,10 +242,89 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw)
>>  	return ret;
>>  }
>>  
>> +static int adsp_attach(struct rproc *rproc)
>> +{
>> +	struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
>> +	int i, ret;
>> +
>> +	ret = qcom_q6v5_prepare(&adsp->q6v5);
>> +	if (ret)
>> +		return ret;
>> +
>> +	ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
>> +	if (ret < 0)
>> +		goto disable_irqs;
>> +
>> +	ret = clk_prepare_enable(adsp->xo);
>> +	if (ret)
>> +		goto disable_proxy_pds;
>> +
>> +	ret = clk_prepare_enable(adsp->aggre2_clk);
>> +	if (ret)
>> +		goto disable_xo_clk;
>> +
>> +	if (adsp->cx_supply) {
>> +		ret = regulator_enable(adsp->cx_supply);
>> +		if (ret)
>> +			goto disable_aggre2_clk;
>> +	}
>> +
>> +	if (adsp->px_supply) {
>> +		ret = regulator_enable(adsp->px_supply);
>> +		if (ret)
>> +			goto disable_cx_supply;
>> +	}
>> +
>> +	/* if needed, signal Q6 to continute booting */
>> +	if (adsp->q6v5.rmb_base) {
>> +		for (i = 0; i < RMB_POLL_MAX_TIMES; i++) {
>> +			if (readl_relaxed(adsp->q6v5.rmb_base + RMB_BOOT_WAIT_REG)) {
>> +				writel_relaxed(1, adsp->q6v5.rmb_base + RMB_BOOT_CONT_REG);
>> +				break;
>> +			}
>> +			msleep(20);
>> +		}
>> +
>> +		if (!readl_relaxed(adsp->q6v5.rmb_base + RMB_BOOT_WAIT_REG)) {
>> +			dev_err(adsp->dev, "Didn't get rmb signal from  %s\n", rproc->name);
>> +			goto disable_px_supply;
>> +		}
>> +	}
>> +
>> +	ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000));
>> +	if (ret == -ETIMEDOUT) {
>> +		dev_err(adsp->dev, "start timed out\n");
>> +		qcom_scm_pas_shutdown(adsp->pas_id);
>> +		goto disable_px_supply;
>> +	}
>> +
>> +	return 0;
>> +
>> +disable_px_supply:
>> +	if (adsp->px_supply)
>> +		regulator_disable(adsp->px_supply);
>> +disable_cx_supply:
>> +	if (adsp->cx_supply)
>> +		regulator_disable(adsp->cx_supply);
>> +disable_aggre2_clk:
>> +	clk_disable_unprepare(adsp->aggre2_clk);
>> +disable_xo_clk:
>> +	clk_disable_unprepare(adsp->xo);
>> +disable_proxy_pds:
>> +	adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
>> +disable_irqs:
>> +	qcom_q6v5_unprepare(&adsp->q6v5);
>> +
>> +	/* Remove pointer to the loaded firmware, only valid in adsp_load() & adsp_start() */
>> +	adsp->firmware = NULL;
>> +
>> +	return ret;
>> +}
>> +
>>  static int adsp_start(struct rproc *rproc)
>>  {
>>  	struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
>> -	int ret;
>> +	int i, ret;
>>  
>>  	ret = qcom_q6v5_prepare(&adsp->q6v5);
>>  	if (ret)
>> @@ -304,6 +383,22 @@ static int adsp_start(struct rproc *rproc)
>>  		goto release_pas_metadata;
>>  	}
>>  
>> +	/* if needed, signal Q6 to continute booting */
> Why does this come before the wait_for_start()? Is the DSP actually up
> and running when you hit attach, or is it just loaded?

Yeah so DSP is loaded and partially booted, but it's waiting for a signal from our driver
to complete the boot process through to err_ready.

>
>> +	if (adsp->q6v5.rmb_base) {
> Afaict this is copy-paste from attach, please move it to a helper
> function.

Sure.

>
>> +		for (i = 0; i < RMB_POLL_MAX_TIMES; i++) {
>> +			if (readl_relaxed(adsp->q6v5.rmb_base + RMB_BOOT_WAIT_REG)) {
>> +				writel_relaxed(1, adsp->q6v5.rmb_base + RMB_BOOT_CONT_REG);
>> +				break;
>> +			}
>> +			msleep(20);
>> +		}
>> +
>> +		if (!readl_relaxed(adsp->q6v5.rmb_base + RMB_BOOT_WAIT_REG)) {
> If you hit the break above, there should be no reason to read this
> register again.
>
> Seems cleaner to write this as:
>
> 	ret = readl_poll_timeout();
> 	if (ret < 0)
> 		goto release;
>
> 	writel(1, ...);

That is much cleaner; I didn't know about the poll timeout function. Will rewrite using it.

Thanks,
Melody
>
> Regards,
> Bjorn
>
>> +			dev_err(adsp->dev, "Didn't get rmb signal from  %s\n", rproc->name);
>> +			goto release_pas_metadata;
>> +		}
>> +	}
>> +
>>  	ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000));
>>  	if (ret == -ETIMEDOUT) {
>>  		dev_err(adsp->dev, "start timed out\n");
>> @@ -413,6 +508,7 @@ static unsigned long adsp_panic(struct rproc *rproc)
>>  static const struct rproc_ops adsp_ops = {
>>  	.unprepare = adsp_unprepare,
>>  	.start = adsp_start,
>> +	.attach = adsp_attach,
>>  	.stop = adsp_stop,
>>  	.da_to_va = adsp_da_to_va,
>>  	.parse_fw = qcom_register_dump_segments,
>> @@ -423,6 +519,7 @@ static const struct rproc_ops adsp_ops = {
>>  static const struct rproc_ops adsp_minidump_ops = {
>>  	.unprepare = adsp_unprepare,
>>  	.start = adsp_start,
>> +	.attach = adsp_attach,
>>  	.stop = adsp_stop,
>>  	.da_to_va = adsp_da_to_va,
>>  	.load = adsp_load,
>> @@ -728,6 +825,10 @@ static int adsp_probe(struct platform_device *pdev)
>>  	if (ret)
>>  		goto detach_proxy_pds;
>>  
>> +	if (adsp->q6v5.rmb_base &&
>> +			readl_relaxed(adsp->q6v5.rmb_base + RMB_Q6_BOOT_STATUS_REG))
>> +		rproc->state = RPROC_DETACHED;
>> +
>>  	qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name);
>>  	qcom_add_smd_subdev(rproc, &adsp->smd_subdev);
>>  	adsp->sysmon = qcom_add_sysmon_subdev(rproc,
>> -- 
>> 2.25.1
>>


  reply	other threads:[~2023-03-20 23:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 23:11 [PATCH v2 0/7] remoteproc: qcom_q6v5_pas: Add support for QDU1000/QRU1000 mpss Melody Olvera
2023-03-06 23:11 ` [PATCH v2 1/7] dt-bindings: firmware: qcom,scm: Update QDU1000/QRU1000 compatible Melody Olvera
2023-03-06 23:11 ` [PATCH v2 2/7] dt-bindings: soc: qcom: aoss: Document " Melody Olvera
2023-03-09  8:12   ` Krzysztof Kozlowski
2023-03-06 23:11 ` [PATCH v2 3/7] dt-bindings: remoteproc: mpss: Document QDU1000/QRU1000 mpss devices Melody Olvera
2023-03-09  8:33   ` Krzysztof Kozlowski
2023-03-09  8:34     ` Krzysztof Kozlowski
2023-03-13 21:11     ` Melody Olvera
2023-03-06 23:11 ` [PATCH v2 4/7] soc: qcom: mdt_loader: Enhance split binary detection Melody Olvera
2023-03-08  4:45   ` kernel test robot
2023-03-16  2:12   ` Bjorn Andersson
2023-03-21 17:42     ` Gokul Krishna Krishnakumar
2023-03-06 23:12 ` [PATCH v2 5/7] remoteproc: qcom: q6v5: Add support for q6 rmb registers Melody Olvera
2023-03-16  2:17   ` Bjorn Andersson
2023-03-20 23:30     ` Melody Olvera
2023-03-06 23:12 ` [PATCH v2 6/7] remoteproc: qcom_q6v5_pas: Add support to attach a DSP Melody Olvera
2023-03-16  2:27   ` Bjorn Andersson
2023-03-20 23:46     ` Melody Olvera [this message]
2023-03-06 23:12 ` [PATCH v2 7/7] remoteproc: qcom_q6v5_pas: Add QDU1000/QRU1000 mpss compatible & data Melody Olvera
2023-03-16  3:21 ` (subset) [PATCH v2 0/7] remoteproc: qcom_q6v5_pas: Add support for QDU1000/QRU1000 mpss Bjorn Andersson

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=e5753441-894d-e6f2-c628-eb931a6b2986@quicinc.com \
    --to=quic_molvera@quicinc.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=quic_gurus@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=robimarko@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox