[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABb+yY11d8uS34yfE6-c_NP6n5pmxvmjs67aOKEAduhUpnU3Uw@mail.gmail.com>
Date: Fri, 2 Oct 2020 14:42:37 -0500
From: Jassi Brar <jassisinghbrar@...il.com>
To: Sudeep Holla <sudeep.holla@....com>
Cc: Jassi Brar <jaswinder.singh@...aro.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
ALKML <linux-arm-kernel@...ts.infradead.org>,
DTML <devicetree@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Vincent Guittot <vincent.guittot@...aro.org>,
Frank Rowand <frowand.list@...il.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Rob Herring <robh@...nel.org>, Rob Herring <robh+dt@...nel.org>
Subject: Re: [PATCH 4/4] mailbox: arm_mhu: Add ARM MHU doorbell driver
On Mon, Sep 28, 2020 at 6:45 AM Sudeep Holla <sudeep.holla@....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.
> +
> +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.
Powered by blists - more mailing lists