From: Sudeep Holla <sudeep.holla@arm.com>
To: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Jassi Brar <jaswinder.singh@linaro.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
ALKML <linux-arm-kernel@lists.infradead.org>,
DTML <devicetree@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Sudeep Holla <sudeep.holla@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Frank Rowand <frowand.list@gmail.com>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Rob Herring <robh@kernel.org>, Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH 4/4] mailbox: arm_mhu: Add ARM MHU doorbell driver
Date: Wed, 7 Oct 2020 12:40:34 +0100 [thread overview]
Message-ID: <20201007114034.rkiujybiknaedy7m@bogus> (raw)
In-Reply-To: <CABb+yY11d8uS34yfE6-c_NP6n5pmxvmjs67aOKEAduhUpnU3Uw@mail.gmail.com>
On Fri, Oct 02, 2020 at 02:42:37PM -0500, Jassi Brar wrote:
> On Mon, Sep 28, 2020 at 6:45 AM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> > +
> > +static void mhu_db_shutdown(struct mbox_chan *chan)
> > +{
> > + struct mhu_db_channel *chan_info = chan->con_priv;
> > + struct mbox_controller *mbox = &chan_info->mhu->mbox;
> > + int i;
> > +
> > + for (i = 0; i < mbox->num_chans; i++)
> > + if (chan == &mbox->chans[i])
> > + break;
> > +
> > + if (mbox->num_chans == i) {
> > + dev_warn(mbox->dev, "Request to free non-existent channel\n");
> > + return;
> > + }
> > +
> > + /* Reset channel */
> > + mhu_db_mbox_clear_irq(chan);
> > + chan->con_priv = NULL;
> >
> request->free->request will fail because of this NULL assignment.
> Maybe add a 'taken' flag in mhu_db_channel, which should also be
> checked before calling mbox_chan_received_data because the data may
> arrive for a now relinquished channel.
>
Good point, but the new 'taken' flag will have the same race as con_priv.
We need a lock here and can we use chan->lock or do you prefer this
driver maintains it own for this purpose.
mbox_request_channel releases the lock before calling startup and
mbox_free_channel acquires the after shutdown returns, so technically
we can reuse the same lock.
> > +
> > +static struct mbox_chan *mhu_db_mbox_xlate(struct mbox_controller *mbox,
> > + const struct of_phandle_args *spec)
> > +{
> > + struct arm_mhu *mhu = dev_get_drvdata(mbox->dev);
> > + struct mhu_db_channel *chan_info;
> > + struct mbox_chan *chan = NULL;
> > + unsigned int pchan = spec->args[0];
> > + unsigned int doorbell = spec->args[1];
> > + int i;
> > +
> > + /* Bounds checking */
> > + if (pchan >= MHU_CHANS || doorbell >= MHU_NUM_DOORBELLS) {
> > + dev_err(mbox->dev,
> > + "Invalid channel requested pchan: %d doorbell: %d\n",
> > + pchan, doorbell);
> > + return ERR_PTR(-EINVAL);
> > + }
> > +
> > + for (i = 0; i < mbox->num_chans; i++) {
> > + chan_info = mbox->chans[i].con_priv;
> > +
> > + /* Is requested channel free? */
> > + if (chan_info &&
> > + mbox->dev == chan_info->mhu->dev &&
> > + pchan == chan_info->pchan &&
> > + doorbell == chan_info->doorbell) {
> > + dev_err(mbox->dev, "Channel in use\n");
> > + return ERR_PTR(-EBUSY);
> > + }
> > +
> You may want to reuse mhu_db_mbox_to_channel.
Good point, thanks for pointing that out, will update.
--
Regards,
Sudeep
next prev parent reply other threads:[~2020-10-07 11:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 11:44 [PATCH 0/4] mailbox: arm_mhu: Add ARM MHU doorbell controller driver Sudeep Holla
2020-09-28 11:44 ` [PATCH 1/4] dt-bindings: mailbox : arm,mhu: Convert to Json-schema Sudeep Holla
2020-09-28 11:44 ` [PATCH 2/4] dt-bindings: mailbox: add doorbell support to ARM MHU Sudeep Holla
2020-09-28 11:44 ` [PATCH 3/4] mailbox: arm_mhu: Match only if compatible is "arm,mhu" Sudeep Holla
2020-09-28 11:44 ` [PATCH 4/4] mailbox: arm_mhu: Add ARM MHU doorbell driver Sudeep Holla
2020-10-02 19:42 ` Jassi Brar
2020-10-07 11:40 ` Sudeep Holla [this message]
2020-10-07 15:43 ` Jassi Brar
2020-10-08 8:49 ` Sudeep Holla
2020-10-07 6:05 ` Viresh Kumar
2020-10-07 11:43 ` 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=20201007114034.rkiujybiknaedy7m@bogus \
--to=sudeep.holla@arm.com \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=jassisinghbrar@gmail.com \
--cc=jaswinder.singh@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@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).