LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	Arun Kumar Neelakantam <aneela@codeaurora.org>,
	Sibi Sankar <sibis@codeaurora.org>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	devicetree@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH v5 06/10] soc: qcom: Add AOSS QMP genpd provider
Date: Fri, 1 Feb 2019 15:39:00 -0800
Message-ID: <CAD=FV=Us8-VBGhwuJHCAGAxV13FOYOx2WBDegQ60SSG=oSO=EQ@mail.gmail.com> (raw)
In-Reply-To: <20190131003933.11436-7-bjorn.andersson@linaro.org>

Hi,

On Wed, Jan 30, 2019 at 4:40 PM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> +struct qmp_pd {
> +       struct qmp *qmp;
> +
> +       struct generic_pm_domain pd;
> +
> +       const char *name;

nit: why do you need name?  Can't you just reach in and use pd.name
since they're the same?


> +static int qmp_pd_clock_toggle(struct qmp_pd *res, bool enable)
> +{
> +       char buf[AOSS_QMP_PD_MSG_LEN];
> +
> +       snprintf(buf, sizeof(buf), "{class: clock, res: %s, val: %d}",
> +                res->name, !!enable);

nit: "enable" is a bool, so "!!" shouldn't be necessary right?


> +       return qmp_send(res->qmp, buf, sizeof(buf));

It appears that you write a string less than 96 bytes onto your stack
buffer but then send the full 96 bytes of stack to the AOSS.  That
doesn't seem like a very good idea to me.  Sorry, but your secret plan
to embed NSA code in the AOSS firmware and scrape data off the kernel
stack has been foiled.


> +static int qmp_pd_image_toggle(struct qmp_pd *res, bool enable)
> +{
> +       char buf[AOSS_QMP_PD_MSG_LEN];
> +
> +       snprintf(buf, sizeof(buf),
> +                "{class: image, res: load_state, name: %s, val: %s}",
> +                res->name, enable ? "on" : "off");
> +       return qmp_send(res->qmp, buf, sizeof(buf));

Please tell me you're joking that for turning on/off clocks "val" is
1/0 but for turning off images "val" is on/off.


> +static int qmp_pd_probe(struct platform_device *pdev)
> +{
> +       struct genpd_onecell_data *data;
> +       struct device *parent = pdev->dev.parent;
> +       struct qmp_pd *res;
> +       struct qmp *qmp;
> +       size_t num = ARRAY_SIZE(sdm845_resources);
> +       int i;
> +
> +       qmp = dev_get_drvdata(pdev->dev.parent);
> +       if (!qmp)
> +               return -EINVAL;
> +
> +       res = devm_kcalloc(&pdev->dev, num, sizeof(*res), GFP_KERNEL);
> +       if (!res)
> +               return -ENOMEM;
> +
> +       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> +       if (!data)
> +               return -ENOMEM;
> +
> +       data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains),
> +                                    GFP_KERNEL);
> +
> +       for (i = 0; i < num; i++) {
> +               pm_genpd_init(&res[i].pd, NULL, true);
> +               res[i].qmp = qmp;
> +               res[i].name = sdm845_resources[i].name;
> +
> +               res[i].pd.name = sdm845_resources[i].name;
> +               res[i].pd.power_on = sdm845_resources[i].on;
> +               res[i].pd.power_off = sdm845_resources[i].off;
> +
> +               data->domains[data->num_domains++] = &res[i].pd;

nit: data->domains[i] = &res[i].pd;

...and then somewhere in this function (not in the loop) just write:

data->num_domains = num;


I think that's the same, right?  They you don't have to re-compute
num_domains by adding 1 at at time and it'd also be more obvious that
all the array accesses in the loop were the same number?


-Doug

  parent reply index

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31  0:39 [PATCH v5 00/10] Qualcomm AOSS QMP driver and modem dts Bjorn Andersson
2019-01-31  0:39 ` [PATCH v5 01/10] arm64: dts: qcom: sdm845: Update reserved memory map Bjorn Andersson
2019-01-31 16:58   ` Sibi Sankar
2019-01-31  0:39 ` [PATCH v5 02/10] arm64: dts: qcom: sdm845: Define rmtfs memory Bjorn Andersson
2019-01-31 17:09   ` Sibi Sankar
2019-01-31  0:39 ` [PATCH v5 03/10] arm64: dts: sdm845: Introduce ADSP and CDSP PAS nodes Bjorn Andersson
2019-02-01  5:49   ` Sibi Sankar
2019-02-01 23:54   ` Doug Anderson
2019-01-31  0:39 ` [PATCH v5 04/10] dt-bindings: soc: qcom: Add AOSS QMP binding Bjorn Andersson
2019-01-31  0:39 ` [PATCH v5 05/10] soc: qcom: Add AOSS QMP communication driver Bjorn Andersson
2019-02-01 23:36   ` Doug Anderson
2019-02-06  1:33     ` Bjorn Andersson
2019-01-31  0:39 ` [PATCH v5 06/10] soc: qcom: Add AOSS QMP genpd provider Bjorn Andersson
2019-02-01  7:15   ` Sibi Sankar
2019-02-01 23:39   ` Doug Anderson [this message]
2019-01-31  0:39 ` [PATCH v5 07/10] remoteproc: q6v5-mss: Vote for rpmh power domains Bjorn Andersson
2019-01-31  4:51   ` Bjorn Andersson
2019-01-31  0:39 ` [PATCH v5 08/10] remoteproc: q6v5-mss: Active powerdomain for SDM845 Bjorn Andersson
2019-01-31  4:51   ` Bjorn Andersson
2019-01-31  0:39 ` [PATCH v5 09/10] arm64: dts: qcom: Add AOSS QMP node Bjorn Andersson
2019-02-01  7:17   ` Sibi Sankar
2019-01-31  0:39 ` [PATCH v5 10/10] arm64: dts: qcom: sdm845: Add Q6V5 MSS node Bjorn Andersson

Reply instructions:

You may reply publically 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='CAD=FV=Us8-VBGhwuJHCAGAxV13FOYOx2WBDegQ60SSG=oSO=EQ@mail.gmail.com' \
    --to=dianders@chromium.org \
    --cc=andy.gross@linaro.org \
    --cc=aneela@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ohad@wizery.com \
    --cc=robh+dt@kernel.org \
    --cc=sibis@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox