From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Rishabh Bhatnagar <rishabhb@codeaurora.org>
Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org,
psodagud@codeaurora.org, tsoni@codeaurora.org,
sidgup@codeaurora.org
Subject: Re: [PATCH 1/2] remoteproc: qcom: Add bus scaling capability during bootup
Date: Wed, 1 Apr 2020 13:17:07 -0700 [thread overview]
Message-ID: <20200401201707.GG267644@minitux> (raw)
In-Reply-To: <1585357147-4616-1-git-send-email-rishabhb@codeaurora.org>
On Fri 27 Mar 17:59 PDT 2020, Rishabh Bhatnagar wrote:
> During bootup since remote processors cannot request for
> additional bus bandwidth from the interconect framework,
> platform driver should provide the proxy resources. This
> is useful for scenarios where the Q6 tries to access the DDR
> memory in the initial stages of bootup. For e.g. during
> bootup or after recovery modem Q6 tries to zero out the bss
> section in the DDR. Since this is a big chunk of memory if
> don't bump up the bandwidth we might encounter timeout issues.
> This patch makes a proxy vote for maximizing the bus bandwidth
> during bootup and removes it once processor is up.
>
> Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> ---
> drivers/remoteproc/qcom_q6v5_pas.c | 43 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index edf9d0e..8f5db8d 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -20,6 +20,7 @@
> #include <linux/qcom_scm.h>
> #include <linux/regulator/consumer.h>
> #include <linux/remoteproc.h>
> +#include <linux/interconnect.h>
These are sorted alphabetically, please maintain this.
> #include <linux/soc/qcom/mdt_loader.h>
> #include <linux/soc/qcom/smem.h>
> #include <linux/soc/qcom/smem_state.h>
> @@ -28,6 +29,9 @@
> #include "qcom_q6v5.h"
> #include "remoteproc_internal.h"
>
> +#define PIL_TZ_AVG_BW 0
> +#define PIL_TZ_PEAK_BW UINT_MAX
Please just inline these in do_bus_scaling().
> +
> struct adsp_data {
> int crash_reason_smem;
> const char *firmware_name;
> @@ -62,6 +66,7 @@ struct qcom_adsp {
> int proxy_pd_count;
>
> int pas_id;
> + struct icc_path *bus_client;
Please rename this proxy_path
> int crash_reason_smem;
> bool has_aggre2_clk;
>
> @@ -124,6 +129,25 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw)
>
> }
>
> +static int do_bus_scaling(struct qcom_adsp *adsp, bool enable)
adsp_bus_vote()
> +{
> + int rc;
This driver uses "int ret".
> + u32 avg_bw = enable ? PIL_TZ_AVG_BW : 0;
No need to carry a variable for 0 or 0, jut pass 0 in the function call
directly.
> + u32 peak_bw = enable ? PIL_TZ_PEAK_BW : 0;
> +
> + if (adsp->bus_client) {
No need for this check, icc_set_bw(NULL, ..) is a nop.
> + rc = icc_set_bw(adsp->bus_client, avg_bw, peak_bw);
> + if (rc) {
> + dev_err(adsp->dev, "bandwidth request failed(rc:%d)\n",
"failed to request bandwidth: %d\n"
> + rc);
> + return rc;
> + }
> + } else
> + dev_info(adsp->dev, "Bus scaling not setup for %s\n",
No need to print this.
> + adsp->rproc->name);
> + return 0;
> +}
> +
> static int adsp_start(struct rproc *rproc)
> {
> struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
> @@ -131,9 +155,13 @@ static int adsp_start(struct rproc *rproc)
>
> qcom_q6v5_prepare(&adsp->q6v5);
>
> + ret = do_bus_scaling(adsp, true);
> + if (ret)
> + goto disable_irqs;
> +
> ret = adsp_pds_enable(adsp, adsp->active_pds, adsp->active_pd_count);
> if (ret < 0)
> - goto disable_irqs;
> + goto unscale_bus;
>
> ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
> if (ret < 0)
> @@ -183,6 +211,8 @@ static int adsp_start(struct rproc *rproc)
> adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
> disable_active_pds:
> adsp_pds_disable(adsp, adsp->active_pds, adsp->active_pd_count);
> +unscale_bus:
> + do_bus_scaling(adsp, false);
> disable_irqs:
> qcom_q6v5_unprepare(&adsp->q6v5);
>
> @@ -198,6 +228,7 @@ static void qcom_pas_handover(struct qcom_q6v5 *q6v5)
> clk_disable_unprepare(adsp->aggre2_clk);
> clk_disable_unprepare(adsp->xo);
> adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
> + do_bus_scaling(adsp, false);
> }
>
> static int adsp_stop(struct rproc *rproc)
> @@ -280,6 +311,14 @@ static int adsp_init_regulator(struct qcom_adsp *adsp)
> return PTR_ERR_OR_ZERO(adsp->px_supply);
> }
>
> +static void adsp_init_bus_scaling(struct qcom_adsp *adsp)
> +{
> + adsp->bus_client = of_icc_get(adsp->dev, NULL);
> + if (!adsp->bus_client)
!adsp->bus_client means there's no interconnects property in the DT
node, you still need to test for errors with IS_ERR().
And in particular you're not guaranteed that the provider has probed, so
you need to propagate EPROBE_DEFER.
> + dev_warn(adsp->dev, "%s: unable to get bus client \n",
> + __func__);
This is a dev_err() for the case of IS_ERR().
And please drop the __func__, it doesn't add any value.
> +}
> +
> static int adsp_pds_attach(struct device *dev, struct device **devs,
> char **pd_names)
> {
> @@ -410,6 +449,8 @@ static int adsp_probe(struct platform_device *pdev)
> if (ret)
> goto free_rproc;
>
> + adsp_init_bus_scaling(adsp);
> +
As stated above, you need to propagate actual errors here (i.e. not the
case where of_icc_get() returned NULL, but when it returned IS_ERR())
Regards,
bjorn
> ret = adsp_pds_attach(&pdev->dev, adsp->active_pds,
> desc->active_pd_names);
> if (ret < 0)
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
prev parent reply other threads:[~2020-04-01 20:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-28 0:59 [PATCH 1/2] remoteproc: qcom: Add bus scaling capability during bootup Rishabh Bhatnagar
2020-03-30 16:06 ` Mathieu Poirier
2020-03-30 16:13 ` Mathieu Poirier
2020-03-30 19:03 ` rishabhb
2020-04-01 20:17 ` Bjorn Andersson [this message]
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=20200401201707.GG267644@minitux \
--to=bjorn.andersson@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=psodagud@codeaurora.org \
--cc=rishabhb@codeaurora.org \
--cc=sidgup@codeaurora.org \
--cc=tsoni@codeaurora.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: 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.