From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Alexey Klimov <alexey.klimov@arm.com>
Subject: Re: [PATCH] mailbox: txdone_method shouldn't always be reset
Date: Thu, 16 Nov 2017 09:42:11 -0800 [thread overview]
Message-ID: <20171116174211.GQ28761@minitux> (raw)
In-Reply-To: <CABb+yY0WFxk75zPV5SV=9eCTi3ZTbaL9JYr4zH+5T11CLgkXUA@mail.gmail.com>
On Thu 16 Nov 09:06 PST 2017, Jassi Brar wrote:
> On Thu, Nov 16, 2017 at 10:21 PM, Jassi Brar <jassisinghbrar@gmail.com> wrote:
> > On Thu, Nov 16, 2017 at 11:01 AM, Bjorn Andersson
> > <bjorn.andersson@linaro.org> wrote:
> >> A client that knows how to drive txdone would temporarily "upgrade" the
> >> method to TXDONE_BY_ACK. But with the introduction of commit 33cd7123ac0ba
> >> ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone")
> >> there is no longer a distinction between a channel in "upgraded" state
> >> or a channel for a controller that only supports TXDONE_BY_ACK. So upon
> >> freeing the channel it will be "downgraded" to TXDONE_BY_POLL.
> >>
> >> But a channel that operates with the txdone method of TXDONE_BY_POLL
> >> requires that the controller implements the last_tx_done callback and
> >> that the associated hrtimer was initialized when the controller was
> >> registered.
> >>
> >> So the core now relies on the fact that subsequent calls to
> >> mbox_request_channel() "upgrades" the channel to TXDONE_BY_ACK or it
> >> will dereference the non-initialized hrtimer.
> >>
> > I think we just need avoid the channel not running under POLL
> >
> And also detect if the channel was originally driven under POLL before
> mbox_request_channel.
> So this is finally what I think we need.
>
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 674b35f..95e480e 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -124,7 +124,8 @@ static enum hrtimer_restart txdone_hrtimer(struct
> hrtimer *hrtimer)
> for (i = 0; i < mbox->num_chans; i++) {
> struct mbox_chan *chan = &mbox->chans[i];
>
> - if (chan->active_req && chan->cl) {
> + if (chan->active_req && chan->cl &&
> + chan->txdone_method == TXDONE_BY_POLL) {
The hrtimer code will crash before reaching this point if the channel
wasn't TXDONE_BY_POLL when it was created, so this part is not needed.
> txdone = chan->mbox->ops->last_tx_done(chan);
> if (txdone)
> tx_tick(chan, 0);
> @@ -418,7 +419,7 @@ void mbox_free_channel(struct mbox_chan *chan)
> spin_lock_irqsave(&chan->lock, flags);
> chan->cl = NULL;
> chan->active_req = NULL;
> - if (chan->txdone_method == TXDONE_BY_ACK)
> + if (chan->txdone_method == TXDONE_BY_ACK && chan->mbox->txdone_poll)
This should be enough, but the logic here is not obvious. This relies on
the fact that a mbox with txdone_poll would have been initialized as
txdone = POLL and that txdone now being ACK would imply that it was
"upgraded" in the request path.
So at least this would have to be captured in a comment.
(Using a bitmask with both POLL | ACK set did capture this in a more
direct way, but obviously wasn't clear to Sudeep)
> chan->txdone_method = TXDONE_BY_POLL;
>
> module_put(chan->mbox->dev->driver->owner);
Regards,
Bjorn
next prev parent reply other threads:[~2017-11-16 17:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 5:31 [PATCH] mailbox: txdone_method shouldn't always be reset Bjorn Andersson
2017-11-16 16:51 ` Jassi Brar
2017-11-16 17:06 ` Jassi Brar
2017-11-16 17:42 ` Bjorn Andersson [this message]
[not found] ` <CABb+yY0cwDCG=zKBT1ckoLSi+cHnmxcNbi2BXz2EstVTAo169w@mail.gmail.com>
[not found] ` <CABb+yY0SmdLyo7g46VqznHZravBv7qUTZcuQ5o4v+4QGMw-pyQ@mail.gmail.com>
[not found] ` <CABb+yY0EkKUMfLrQs4OjHkVPKghKND6hChfzmjS60asTrAcYyg@mail.gmail.com>
[not found] ` <CABb+yY0GkRpPgAgAFOMxLJ_7qh4wV7R5At8VFOxepuEN76K1QQ@mail.gmail.com>
[not found] ` <CABb+yY0nSnkYQtL28UwsqRCRkaZHSU2O-RM9r=50n0n7Owkf+A@mail.gmail.com>
2017-11-17 7:04 ` Bjorn Andersson
2017-11-17 9:51 ` Sudeep Holla
2017-11-17 12:40 ` Jassi Brar
2017-11-16 17:24 ` 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=20171116174211.GQ28761@minitux \
--to=bjorn.andersson@linaro.org \
--cc=alexey.klimov@arm.com \
--cc=jassisinghbrar@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox