public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Raju P L S S S N <rplsssn@codeaurora.org>
To: Doug Anderson <dianders@chromium.org>
Cc: Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>,
	linux-arm-msm@vger.kernel.org,
	"open list:ARM/QUALCOMM SUPPORT" <linux-soc@vger.kernel.org>,
	Rajendra Nayak <rnayak@codeaurora.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Evan Green <evgreen@chromium.org>,
	Matthias Kaehlcke <mka@chromium.org>,
	Lina Iyer <ilina@codeaurora.org>
Subject: Re: [PATCH v9 09/10] drivers: qcom: rpmh: add support for batch RPMH request
Date: Mon, 11 Jun 2018 22:47:30 +0530	[thread overview]
Message-ID: <9db0ca7e-6ca9-7e00-5092-7e561b997fbd@codeaurora.org> (raw)
In-Reply-To: <CAD=FV=X7Bv587F753AXJ2VtxedLdeBhk8JQf-a8E4h33JfFiWA@mail.gmail.com>

Hi,

On 5/31/2018 3:20 AM, Doug Anderson wrote:
> Hi,
> 
> On Thu, May 24, 2018 at 3:45 AM, Raju P L S S S N
> <rplsssn@codeaurora.org> wrote:
>>   #define DEFINE_RPMH_MSG_ONSTACK(dev, s, q, name)       \
>>          struct rpmh_request name = {                    \
>> @@ -35,6 +37,7 @@
>>                  .completion = q,                        \
>>                  .dev = dev,                             \
>>                  .needs_free = false,                            \
>> +               .wait_count = NULL,                     \
> 
> You ignored my feedback on v8 that wait_count is not useful.  Please
> squash in <http://crosreview.com/1079905>.  That also has a fix where
> it introduces a WARN_ON for the timeout case in batch mode too.

Oh. Sorry.. I missed it. Thanks for pointing out. Will take up in next spin

> 
> 
>> +/**
>> + * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the
>> + * batch to finish.
>> + *
>> + * @dev: the device making the request
>> + * @state: Active/sleep set
>> + * @cmd: The payload data
>> + * @n: The array of count of elements in each batch, 0 terminated.
>> + *
>> + * Write a request to the RSC controller without caching. If the request
>> + * state is ACTIVE, then the requests are treated as completion request
>> + * and sent to the controller immediately. The function waits until all the
>> + * commands are complete. If the request was to SLEEP or WAKE_ONLY, then the
>> + * request is sent as fire-n-forget and no ack is expected.
>> + *
>> + * May sleep. Do not call from atomic contexts for ACTIVE_ONLY requests.
>> + */
>> +int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
>> +                    const struct tcs_cmd *cmd, u32 *n)
>> +{
>> +       struct rpmh_request *rpm_msg[RPMH_MAX_REQ_IN_BATCH] = { NULL };
>> +       DECLARE_COMPLETION_ONSTACK(compl);
>> +       atomic_t wait_count = ATOMIC_INIT(0);
>> +       struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
>> +       int count = 0;
>> +       int ret, i, j;
>> +
>> +       if (IS_ERR(ctrlr) || !cmd || !n)
>> +               return -EINVAL;
>> +
>> +       while (n[count++] > 0)
>> +               ;
>> +       count--;
>> +       if (!count || count > RPMH_MAX_REQ_IN_BATCH)
>> +               return -EINVAL;
>> +
>> +       for (i = 0; i < count; i++) {
>> +               rpm_msg[i] = __get_rpmh_msg_async(state, cmd, n[i]);
>> +               if (IS_ERR(rpm_msg[i])) {
>> +                       ret = PTR_ERR(rpm_msg[i]);
>> +                       for (j = i-1; j >= 0; j--) {
>> +                               if (rpm_msg[j]->needs_free)
> 
> How could needs_free be false here?

Yes. Just an additional check. Can be omitted. Will do it in next spin.

> 
>> +                                       kfree(rpm_msg[j]);
>> +                       }
>> +                       return ret;
>> +               }
>> +               cmd += n[i];
>> +       }
>> +
>> +       if (state != RPMH_ACTIVE_ONLY_STATE)
>> +               return cache_batch(ctrlr, rpm_msg, count);
> 
> Previously I said:
>> Don't you need to free rpm_msg items in this case?
> 
> ...but I think that wasn't clear enough.  Perhaps I should have said:
> 
> Don't you need to free rpm_msg items in the case where cache_batch
> returns an error?  AKA squash in <http://crosreview.com/1079906>.

Now I got it. will add the changes in next spin.

> 
> 
>> +
>> +       atomic_set(&wait_count, count);
>> +
>> +       for (i = 0; i < count; i++) {
>> +               rpm_msg[i]->completion = &compl;
>> +               rpm_msg[i]->wait_count = &wait_count;
>> +               ret = rpmh_rsc_send_data(ctrlr->drv, &rpm_msg[i]->msg);
>> +               if (ret) {
>> +                       int j;
> 
> You're shadowing another "j" variable.  Please squash in
> <http://crosreview.com/1080027>.
> 

Agreed.

>> +
>> +                       pr_err("Error(%d) sending RPMH message addr=%#x\n",
>> +                              ret, rpm_msg[i]->msg.cmds[0].addr);
>> +                       for (j = i; j < count; j++)
>> +                               rpmh_tx_done(&rpm_msg[j]->msg, ret);
> 
> Previously I said:
> 
>> Note that you'll probably do your error handling in this
>> function a favor if you rename __get_rpmh_msg_async()
>> to __fill_rpmh_msg() and remove the memory
>> allocation from there
> 
> I tried to implement this but then I realized cache_batch() requires
> individual allocation.  Sigh.
> 
> OK, I attempted this in <http://crosreview.com/1080028>.  This gets
> rid of several static-sized arrays and gets rid of all of the little
> memory allocations in rpmh_write_batch(), replacing it with one bigger
> one.  In my mind this is an improvement, but I welcome other opinions.
> 
> As discussed previously, I'm still of the belief that we'll be better
> off getting rid of separate "batch" data structures.  I'll see if I
> can find some time to do that too and see how it looks.
> 
> 
> -Doug
> 

Thanks,
Raju

  reply	other threads:[~2018-06-11 17:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 10:45 [PATCH v9 00/10] drivers/qcom: add RPMH communication support Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs Raju P L S S S N
2018-05-28  5:32   ` Raju P L S S S N
2018-05-30 21:49   ` Doug Anderson
2018-06-11 17:07     ` Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 02/10] dt-bindings: introduce RPMH RSC bindings for Qualcomm SoCs Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 03/10] drivers: qcom: rpmh-rsc: log RPMH requests in FTRACE Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 04/10] drivers: qcom: rpmh: add RPMH helper functions Raju P L S S S N
2018-05-30 21:49   ` Doug Anderson
2018-06-11 17:11     ` Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 07/10] drivers: qcom: rpmh: cache sleep/wake state requests Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously Raju P L S S S N
2018-05-24 10:45 ` [PATCH v9 09/10] drivers: qcom: rpmh: add support for batch RPMH request Raju P L S S S N
2018-05-30 21:50   ` Doug Anderson
2018-06-11 17:17     ` Raju P L S S S N [this message]
2018-05-24 10:45 ` [PATCH v9 10/10] drivers: qcom: rpmh-rsc: allow active requests from wake TCS Raju P L S S S N

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=9db0ca7e-6ca9-7e00-5092-7e561b997fbd@codeaurora.org \
    --to=rplsssn@codeaurora.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=mka@chromium.org \
    --cc=rnayak@codeaurora.org \
    --cc=sboyd@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox