From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 024B8C54EE9 for ; Thu, 22 Sep 2022 15:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZuppssNjEVLjilX+KDcHk6ETGVFid6P4vHMHnF7/AM4=; b=Bl0Ta+IFC3pjcq x3z8UzDb0qUST+C5Fgs/AhE7WNU3d9uNyZhVzukXdyMBRwFCqpLIKpVGsw11Zzgl6C5Oe7IHqX7Vj e4cGt2NSWFRPWrxA1Ht2OqUuDm5+mEd9sWM6fOctSL72Sqbyp8sDprDti1l3KeImvWdsE/lZzf5is FjsVwB0dqCEwMPKb47zdSJ6UmUSpNTrkhrJxLdYl5QC2p83TGe7UvHPqs/cRRPzms/drUVVmfaIWb CtFNKlQt/irxWh4uywFpDspAn/0/lFzh4Y0zxlrUF27WIoqdVjCeHuzEjYhxZzhmURQUbvTYYC59f Tj8H5f6V+axhKHTQRODA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obO85-00GRmF-8m; Thu, 22 Sep 2022 15:28:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obO81-00GRkF-50 for linux-arm-kernel@lists.infradead.org; Thu, 22 Sep 2022 15:28:42 +0000 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 7D665139F; Thu, 22 Sep 2022 08:28:43 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 05B013F73D; Thu, 22 Sep 2022 08:28:35 -0700 (PDT) Date: Thu, 22 Sep 2022 16:28:25 +0100 From: Cristian Marussi To: Shivnandan Kumar Cc: sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, quic_rgottimu@quicinc.com, quic_avajid@quicinc.com Subject: Re: Query regarding "firmware: arm_scmi: Free mailbox channels if probe fails" Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220922_082841_280965_B30DABA7 X-CRM114-Status: GOOD ( 16.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 22, 2022 at 03:54:31PM +0100, Cristian Marussi wrote: > On Thu, Sep 22, 2022 at 10:31:47AM +0530, Shivnandan Kumar wrote: > > Hi Christian, > > > Hi Shivnandan, [snip] > Looking at the transport layer that you use, mailbox, I see that while > setup/free helpers are synchronized on an internal chan->lock, the RX > path inside the mailbox core is not, so I tried this: > > > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c > index 4229b9b5da98..bb6173c0ad54 100644 > --- a/drivers/mailbox/mailbox.c > +++ b/drivers/mailbox/mailbox.c > @@ -157,9 +157,13 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) > */ > void mbox_chan_received_data(struct mbox_chan *chan, void *mssg) > { > + unsigned long flags; > + > + spin_lock_irqsave(&chan->lock, flags); > /* No buffering the received data */ > if (chan->cl->rx_callback) > chan->cl->rx_callback(chan->cl, mssg); > + spin_unlock_irqrestore(&chan->lock, flags); > } > EXPORT_SYMBOL_GPL(mbox_chan_received_data); > ...sorry... a small change on the tentative above fix... ----8<------ diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 4229b9b5da98..6fbe183acdae 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -157,9 +157,13 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) */ void mbox_chan_received_data(struct mbox_chan *chan, void *mssg) { + unsigned long flags; + + spin_lock_irqsave(&chan->lock, flags); /* No buffering the received data */ - if (chan->cl->rx_callback) + if (chan->cl && chan->cl->rx_callback) chan->cl->rx_callback(chan->cl, mssg); + spin_unlock_irqrestore(&chan->lock, flags); } EXPORT_SYMBOL_GPL(mbox_chan_received_data); ------8<----- Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel