Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp979624rwb; Thu, 22 Sep 2022 08:39:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zus6vJpxaPKR7pwK5A631Oe0CrAMiH9Zl3TSyyOXf0qkPmKETIpuy0bdqOZa9QpoJBnMG X-Received: by 2002:a17:902:c7d2:b0:178:8e76:c78a with SMTP id r18-20020a170902c7d200b001788e76c78amr4030642pla.116.1663861148338; Thu, 22 Sep 2022 08:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663861148; cv=none; d=google.com; s=arc-20160816; b=EZnRnU1/sqr4+e7TsQ5XGHsTHt0eA9FUis2f48F/WxVXHEq5Jy0eZVGED0kOHoNTMk tpn3eYVCRV3qqjIdwjT2fEImmXEVkkcGMGUpLU8JYFRfVy3jYNgFTkQBvIgUEaLXSO+x LB6bdHV8MVhbjS6LvvoiAMnmwabIGO/b6ogeIpT9AZcVa6P3at67tph2tfQGjUOTPeru UrGXgRZi1tgA6ApQWtuX3jCsiZ0Ml//pCC/5jgvbVD3RPT1rAOmhQ1PZS4TlLN2HyudU 98MIgLRM2775Br/doPWsh5IFssSa5VHpeO/yYGC1L1kP14woiEWNT4B0hoXs81wUXfLH ueNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=FnsDNS5Vk2e16rLBD6/Dd95pnlAXbZN3tOGrx+OoNQI=; b=fe2hZUcMxYvK969Dm041YFOFY8GikD5+b3MMmovIHQdKFeXA6ehizydrD53OQn3sgX q4ONXhb/bRhbdMewRP0bfhM/GaaHprV3W7SOQvB1TDQ9QlpViO1zYKHVjsox4Qo0z0GA XorNui4WHCyyi497/SVBvJPiJtt99vHcu7yM7Qwow6DNINNX1cdBSnU4axiyv5pvW6ZK uzevwm5QWpjKjtdxOnm6rJDZTXzXpoPpc3DmBM/eGbHCISe7R2gvlK2TQJH2tnPIEq2/ xVaPQwf/OSoEACN1z5p4LXT6iiUtMKa95KcJR+X06mFw45P1s0n8zmBom6UHdrj1Zyg7 uxXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a63140a000000b00434b19dc958si6179260pgl.349.2022.09.22.08.38.54; Thu, 22 Sep 2022 08:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232099AbiIVP3F (ORCPT + 99 others); Thu, 22 Sep 2022 11:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232127AbiIVP2i (ORCPT ); Thu, 22 Sep 2022 11:28:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46972F1D47 for ; Thu, 22 Sep 2022 08:28:37 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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