From: Sudeep Holla <sudeep.holla@arm.com>
To: "Jon Medhurst (Tixy)" <tixy@linaro.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Liviu Dudau <Liviu.Dudau@arm.com>,
Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <Mark.Rutland@arm.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 1/4] mailbox: add support for System Control and Power Interface(SCPI) protocol
Date: Wed, 29 Apr 2015 14:08:14 +0100 [thread overview]
Message-ID: <5540D7BE.9010201@arm.com> (raw)
In-Reply-To: <1430310338.27241.45.camel@linaro.org>
On 29/04/15 13:25, Jon Medhurst (Tixy) wrote:
> On Wed, 2015-04-29 at 12:43 +0100, Jon Medhurst (Tixy) wrote:
>> On Wed, 2015-04-29 at 11:53 +0100, Sudeep Holla wrote:
>>> On 28/04/15 14:54, Jon Medhurst (Tixy) wrote:
>>>> On Mon, 2015-04-27 at 12:40 +0100, Sudeep Holla wrote:
>> [...]
>>>>> + int ret;
>>>>> + u8 token, chan;
>>>>> + struct scpi_xfer *msg;
>>>>> + struct scpi_chan *scpi_chan;
>>>>> +
>>>>> + chan = atomic_inc_return(&scpi_info->next_chan) % scpi_info->num_chans;
>>>>> + scpi_chan = scpi_info->channels + chan;
>>>>> +
>>>>> + msg = get_scpi_xfer(scpi_chan);
>>>>> + if (!msg)
>>>>> + return -ENOMEM;
>>>>> +
>>>>> + token = atomic_inc_return(&scpi_chan->token) & CMD_TOKEN_ID_MASK;
>>>>
>>>> So, this 8 bit token is what's used to 'uniquely' identify a pending
>>>> command. But as it's just an incrementing value, then if one command
>>>> gets delayed for long enough that 256 more are issued then we will have
>>>> a non-unique value and scpi_process_cmd can go wrong.
>>>>
>>>
>>> IMO by the time 256 message are queued up and serviced we would timeout
>>> on the initial command. Moreover the core mailbox has sent the mailbox
>>> length to 20(MBOX_TX_QUEUE_LEN) which needs to removed to even get the
>>> remote chance of hit the corner case.
>>
>> The corner case can be hit even if the queue length is only 2, because
>> other processes/cpus can use the other message we don't own here and
>> they can send then receive a message using that, 256 times. The corner
>> case doesn't require 256 simultaneous outstanding requests.
>>
>> That is the reason I suggested that rather than using an incrementing
>> value for the 'unique' token, that each message instead contain the
>> value of the token to use with it.
>
> Of course, I failed to mention that this solution to this problem makes
> thing worse for the situation where we timeout messages, because the
> same token will get reused quicker in that case. So, in practice, if we
> have timeouts, and a unchangeable protocol limitation of 256 tokens,
> then using those tokens in order, for each message sent is probably the
> best we can do.
>
I agree, I think we must be happy with that for now :)
> Perhaps that's the clue, generate and add the token to the message, just
> before transmission via the MHU, at a point where we know no other
> request can overtake us. In scpi_tx_prepare? Perhaps, it might also be
> good to only use up a token if we are expecting a response, and use zero
> for other messages?
>
> Something like this totally untested patch...
>
Looks good and best we can do with the limitations we have IMO
Regards,
Sudeep
next prev parent reply other threads:[~2015-04-29 13:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1430134846-24320-1-git-send-email-sudeep.holla@arm.com>
[not found] ` <1430134846-24320-1-git-send-email-sudeep.holla-5wv7dgnIgG8@public.gmane.org>
2015-04-27 11:40 ` [PATCH 1/4] mailbox: add support for System Control and Power Interface(SCPI) protocol Sudeep Holla
2015-04-28 7:36 ` Paul Bolle
2015-04-28 8:41 ` Sudeep Holla
2015-04-28 13:54 ` Jon Medhurst (Tixy)
2015-04-29 10:53 ` Sudeep Holla
2015-04-29 11:43 ` Jon Medhurst (Tixy)
2015-04-29 12:25 ` Jon Medhurst (Tixy)
2015-04-29 13:08 ` Sudeep Holla [this message]
2015-04-30 8:49 ` Jon Medhurst (Tixy)
2015-04-29 13:01 ` Sudeep Holla
2015-05-13 16:52 ` Jassi Brar
2015-05-13 17:09 ` Sudeep Holla
[not found] ` <55538540.1010505-5wv7dgnIgG8@public.gmane.org>
2015-05-14 7:02 ` Jassi Brar
2015-05-14 7:30 ` Jassi Brar
[not found] ` <CABb+yY0J1j=wMaKj+1nohU7qJpVS83BD_AX3Mf56T5+6V6+NOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-14 8:25 ` Sudeep Holla
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=5540D7BE.9010201@arm.com \
--to=sudeep.holla@arm.com \
--cc=Liviu.Dudau@arm.com \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=tixy@linaro.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;
as well as URLs for NNTP newsgroup(s).