Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp341366pxu; Wed, 7 Oct 2020 04:45:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGlp+XapgAIMMDh0bZNRD07RQDl/VDJMBnmY/Cqso0QWiZ8GlWn//ds5JRf4XnpbIom9mk X-Received: by 2002:aa7:de06:: with SMTP id h6mr3070092edv.31.1602071106215; Wed, 07 Oct 2020 04:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602071106; cv=none; d=google.com; s=arc-20160816; b=sSsr1PAtxWTXLwenpWpQNrwNsnJuWPDA1WB/29jSoQvWASeWUrVfh8LdO5Qozk7IJK lScVSXl4movUNX6rx2W5zyPH7Pl3zsH4soY9JY9qnrOEirV5UBPyhBZxK9wJvoovBxKM 86UZpjgFdMsd5d3oJnKq0HNgX+SsaOI8Lo8GsMeXiSI+e6X/zMXqNKZWnlUIMG8kGgs5 /yu/6FTkf0O3nLC7DC/PhANNQCeyHTWZHk1u9w3+LgX0n12hK96mf8UePfiHHWjF3PwY 0csBIA2wnSzx2Iq+itU/f4P8T59eNW4hCUbsgMgwTxz3EwFpeWHtjmu+ezscLwS0MwQp k5pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WyPzRrxhFRlHV/otV3YTnFSaBBQ2ApSnsvsEbKQATeU=; b=G0obbeiVsmHX8lvYarMe/x4kPVasEJehG6qOmnxbNxdHkF0uxAB0NW7oBoUTXk4J4z js2nPfo6vpVAYJQ92Pua61GTrcrPRMkzfXiAIyl2XG/LEdx0Dw2DeyFLXKMXpkKYB9zf ELAraHuKikLjs96CRS/6A5gBtUmiAEh8weRvDoPutQxAbLnBr/jUag08WJW0TdbL8z8m wZG1/LE3lWy4RYFcC2lBCpNAhwz8W258AzFvFWK1FkJFnJ1NIrA5f4feowPhItXlu8YT US63+c2sH5Z83Je4uASyPFk5HsyTBCoX9RGKQx/FVCz+6R3KishREypoC7ts3OkZjMTP vtsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pg3si1447773ejb.685.2020.10.07.04.44.43; Wed, 07 Oct 2020 04:45:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbgJGLkk (ORCPT + 99 others); Wed, 7 Oct 2020 07:40:40 -0400 Received: from foss.arm.com ([217.140.110.172]:42396 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbgJGLkj (ORCPT ); Wed, 7 Oct 2020 07:40:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 11E2D31B; Wed, 7 Oct 2020 04:40:39 -0700 (PDT) Received: from bogus (unknown [10.57.54.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E2BD33F71F; Wed, 7 Oct 2020 04:40:36 -0700 (PDT) Date: Wed, 7 Oct 2020 12:40:34 +0100 From: Sudeep Holla To: Jassi Brar Cc: Jassi Brar , Viresh Kumar , ALKML , DTML , LKML , Sudeep Holla , Vincent Guittot , Frank Rowand , Bjorn Andersson , Rob Herring , Rob Herring Subject: Re: [PATCH 4/4] mailbox: arm_mhu: Add ARM MHU doorbell driver Message-ID: <20201007114034.rkiujybiknaedy7m@bogus> References: <20200928114445.19689-1-sudeep.holla@arm.com> <20200928114445.19689-5-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 02, 2020 at 02:42:37PM -0500, Jassi Brar wrote: > On Mon, Sep 28, 2020 at 6:45 AM Sudeep Holla 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