All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Klimov <alexey.klimov@arm.com>
To: Jassi Brar <jaswinder.singh@linaro.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mailbox: fix completion order for blocking requests
Date: Tue, 11 Apr 2017 13:45:38 +0100	[thread overview]
Message-ID: <20170411124538.GB4973@arm.com> (raw)
In-Reply-To: <CAJe_ZhdV_5zxSygOBngqxc86GVWgRNjjZtNTL+dHQtwa=qgruA@mail.gmail.com>

On Thu, Apr 06, 2017 at 10:45:26PM +0530, Jassi Brar wrote:
> On 6 April 2017 at 22:28, Alexey Klimov <alexey.klimov@arm.com> wrote:
> > Hi Jassi/Sudeep,
> >
> > On Wed, Mar 29, 2017 at 07:01:09PM +0100, Sudeep Holla wrote:
> >>
> >>
> >> On 29/03/17 18:43, Jassi Brar wrote:
> ...
> 
> >> > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> >> > index 9dfbf7e..e06c50c 100644
> >> > --- a/drivers/mailbox/mailbox.c
> >> > +++ b/drivers/mailbox/mailbox.c
> >> > @@ -41,6 +41,7 @@ static int add_to_rbuf(struct mbox_chan *chan, void *mssg)
> >> >
> >> >     idx = chan->msg_free;
> >> >     chan->msg_data[idx] = mssg;
> >> > +   init_completion(&chan->tx_cmpl[idx]);
> >>
> >> reinit would be better.
> >
> Of course.
> 
> ....
> > From: Alexey Klimov <alexey.klimov@arm.com>
> > Date: Thu, 6 Apr 2017 13:57:02 +0100
> > Subject: [RFC][PATCH] mailbox: per-channel arrays with msg data and completion
> >  structures
> >
> > When a mailbox client doesn't serialize sending of the message itself,
> > and asks mailbox framework to block on mbox_send_message(), one
> > completion structure per channel is not enough. Client can make a few
> > mbox_send_message() calls at the same time, and there is no guaranteed
> > order of going to sleep on completion.
> >
> > If mailbox controller acks a message transfer, then tx_tick() wakes up
> > the first thread that waits on completion.
> > If mailbox controller doesn't ack the transfer and timeout happens, then
> > tx_tick() calls complete, and the next caller trying to sleep on
> > completion wakes up immediately.
> >
> > This patch fixes this by changing completion structures to be inserted
> > into an array that contains a) pointer to data provided by client and
> > b) the completion structure. Thus active_req field tracks the index of
> > the current running request that was submitted to mailbox controller.
> >
> > Signed-off-by: Alexey Klimov <alexey.klimov@arm.com>
> > ---
> >  drivers/mailbox/mailbox.c          | 40 +++++++++++++++++++++++---------------
> >  drivers/mailbox/pcc.c              | 10 +++++++---
> >  include/linux/mailbox_controller.h | 24 +++++++++++++++++------
> ...
> >  3 files changed, 49 insertions(+), 25 deletions(-)
> >
>  Versus   4 files changed, 17 insertions(+), 8 deletions(-)
> 
> I think we should just keep it simpler if it works just as fine.

Along with this patch you still need at least one patch from Sudeep with subject:
"[PATCH 1/3] mailbox: always wait in mbox_send_message for blocking Tx mode"

Decision to block or not shouldn't depend on racy reading of active_req field.

Best regards,
Alexey Klimov.

  reply	other threads:[~2017-04-11 12:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 17:43 [PATCH] mailbox: fix completion order for blocking requests Jassi Brar
2017-03-29 18:01 ` Sudeep Holla
2017-04-06 16:58   ` Alexey Klimov
2017-04-06 17:15     ` Jassi Brar
2017-04-11 12:45       ` Alexey Klimov [this message]
2017-04-23 10:03         ` Jassi Brar
2017-05-25 16:40           ` Alexey Klimov
2017-05-25 17:34             ` Jassi Brar

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=20170411124538.GB4973@arm.com \
    --to=alexey.klimov@arm.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=jaswinder.singh@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /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.