LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Lina Iyer <ilina@codeaurora.org>
Cc: andy.gross@linaro.org, david.brown@linaro.org,
linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org,
rnayak@codeaurora.org, bjorn.andersson@linaro.org,
linux-kernel@vger.kernel.org, sboyd@kernel.org,
evgreen@chromium.org, dianders@chromium.org
Subject: Re: [PATCH v6 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS
Date: Fri, 27 Apr 2018 11:40:17 -0700 [thread overview]
Message-ID: <20180427184017.GI243180@google.com> (raw)
In-Reply-To: <20180427173943.GD6380@codeaurora.org>
On Fri, Apr 27, 2018 at 11:39:43AM -0600, Lina Iyer wrote:
> On Wed, Apr 25 2018 at 15:41 -0600, Matthias Kaehlcke wrote:
> > On Thu, Apr 19, 2018 at 04:16:30PM -0600, Lina Iyer wrote:
> > > Sleep and wake requests are sent when the application processor
> > > subsystem of the SoC is entering deep sleep states like in suspend.
> > > These requests help lower the system power requirements when the
> > > resources are not in use.
> > >
> > > Sleep and wake requests are written to the TCS slots but are not
> > > triggered at the time of writing. The TCS are triggered by the firmware
> > > after the last of the CPUs has executed its WFI. Since these requests
> > > may come in different batches of requests, it is the job of this
> > > controller driver to find and arrange the requests into the available
> > > TCSes.
> > >
> > > Signed-off-by: Lina Iyer <ilina@codeaurora.org>
> > > Reviewed-by: Evan Green <evgreen@chromium.org>
> > > ---
> > > drivers/soc/qcom/rpmh-internal.h | 8 +++
> > > drivers/soc/qcom/rpmh-rsc.c | 120 +++++++++++++++++++++++++++++++
> > > 2 files changed, 128 insertions(+)
> > >
> > > diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
> > > index d9a21726e568..6e19fe458c31 100644
> > > --- a/drivers/soc/qcom/rpmh-internal.h
> > > +++ b/drivers/soc/qcom/rpmh-internal.h
> >
> > <snip>
> >
> > > +static int find_match(const struct tcs_group *tcs, const struct tcs_cmd *cmd,
> > > + int len)
> > > +{
> > > + int i, j;
> > > +
> > > + /* Check for already cached commands */
> > > + for_each_set_bit(i, tcs->slots, MAX_TCS_SLOTS) {
> > > + for (j = 0; j < len; j++) {
> > > + if (tcs->cmd_cache[i] != cmd[0].addr) {
> >
> > Shouldn't the condition be 'tcs->cmd_cache[i + j] != cmd[j].addr'?
> >
> Here, we are trying to find the first address from the request and its
> position 'i' in the cmd_cache.
>
> > Otherwise the code below the following if branch will never be
> > executed. Either the 'tcs->cmd_cache[i] != cmd[0].addr' branch isn't
> > entered because the addresses match, or the addresses don't match
> > and the inner loop is aborted after the first iteration.
> >
> > > + if (j == 0)
> > > + break;
> > > + WARN(tcs->cmd_cache[i + j] != cmd[j].addr,
> > > + "Message does not match previous sequence.\n");
> We now check for the sequence using the iterator 'j' only after we have
> found 'i' (the beginning of our request).
>
> I hope that helps clear the concern.
It doesn't, maybe I'm just confused, the driver has a certain
complexity and I don't claim to have a comprehensive understanding :)
If I understand correctly find_match() is used to find a sequence of
commands of length 'len' in the command cache. If that is correct I
would expect it to do the following:
1. iterate through the commands in the command cache and find a
command that matches the first command in the sequence
2. verify that the (len - 1) subsequent commands match those in the
sequence, otherwise bail out
If I'm not mistaken the current version of find_match() only checks
that the first command exists. After that it happily increases the
command index, but doesn't perform any checks (after finding the first
command 'tcs->cmd_cache[i] != cmd[0].addr' remains false for the
subsequent values of j). When j reaches (len - 1) the function
returns the index of the first command in the cache, regardless of
whether the other commands match or not.
Please correct me if I'm just confused, I think the negative logic of
'tcs->cmd_cache[i] != cmd[0].addr' doesn't help the readability of the
code.
next prev parent reply other threads:[~2018-04-27 18:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 22:16 [PATCH v6 00/10] drivers/qcom: add RPMH communication support Lina Iyer
2018-04-19 22:16 ` [PATCH v6 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs Lina Iyer
2018-04-19 22:16 ` [PATCH v6 02/10] dt-bindings: introduce RPMH RSC bindings for Qualcomm SoCs Lina Iyer
2018-05-01 23:45 ` Doug Anderson
2018-05-02 14:56 ` Lina Iyer
2018-04-19 22:16 ` [PATCH v6 03/10] drivers: qcom: rpmh-rsc: log RPMH requests in FTRACE Lina Iyer
2018-04-19 22:16 ` [PATCH v6 04/10] drivers: qcom: rpmh: add RPMH helper functions Lina Iyer
2018-04-26 18:05 ` Matthias Kaehlcke
2018-04-27 16:55 ` Lina Iyer
2018-04-19 22:16 ` [PATCH v6 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS Lina Iyer
2018-04-25 21:41 ` Matthias Kaehlcke
2018-04-27 17:39 ` Lina Iyer
2018-04-27 18:40 ` Matthias Kaehlcke [this message]
2018-04-27 19:45 ` Lina Iyer
2018-04-27 20:06 ` Matthias Kaehlcke
2018-04-27 21:32 ` Lina Iyer
2018-04-27 21:54 ` Matthias Kaehlcke
2018-04-27 23:24 ` Doug Anderson
2018-05-01 16:10 ` Lina Iyer
2018-05-01 16:42 ` Doug Anderson
2018-05-01 17:35 ` Lina Iyer
2018-05-01 16:45 ` Matthias Kaehlcke
2018-04-19 22:16 ` [PATCH v6 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Lina Iyer
2018-04-25 22:11 ` Matthias Kaehlcke
2018-04-27 16:44 ` Lina Iyer
2018-04-27 16:54 ` Matthias Kaehlcke
2018-04-19 22:16 ` [PATCH v6 07/10] drivers: qcom: rpmh: cache sleep/wake state requests Lina Iyer
2018-04-19 22:16 ` [PATCH v6 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously Lina Iyer
2018-04-19 22:16 ` [PATCH v6 09/10] drivers: qcom: rpmh: add support for batch RPMH request Lina Iyer
2018-04-25 23:41 ` Matthias Kaehlcke
2018-04-27 16:24 ` Lina Iyer
2018-04-19 22:16 ` [PATCH v6 10/10] drivers: qcom: rpmh-rsc: allow active requests from wake TCS Lina Iyer
2018-04-26 1:14 ` Matthias Kaehlcke
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=20180427184017.GI243180@google.com \
--to=mka@chromium.org \
--cc=andy.gross@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=david.brown@linaro.org \
--cc=dianders@chromium.org \
--cc=evgreen@chromium.org \
--cc=ilina@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-soc@vger.kernel.org \
--cc=rnayak@codeaurora.org \
--cc=sboyd@kernel.org \
--subject='Re: [PATCH v6 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).