Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp463658ybv; Fri, 7 Feb 2020 02:42:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzKqgxKkYpt3ZdMv9BckiMj7qz6gVjmooxna3FCGdUptg/yudp4JOszE0velJh9YVyAx6x4 X-Received: by 2002:aca:4994:: with SMTP id w142mr1570051oia.178.1581072171245; Fri, 07 Feb 2020 02:42:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581072171; cv=none; d=google.com; s=arc-20160816; b=qUAJ7NzfP6bYAlLM/oUJarzm6cdo80Zt5GMLZno0SxNfKvDvzV0epm4YHMKUVw8QOz pGLf64DB3HyobZGWRvSBXKAIZs28RgQWKRGH58nxm8s+e9XxTmyKmLvG56WnEMbMwd83 DodLYv9KoeJpjqStlOGrYe1XMC66FbHuHDM+Jz67opH/q7gYm+KNLQ0smL3QPL+1XhYC Hq1v4Z20YueAaayj9FYNJzCNshfklEtk3pcwamtAcLNvOL8PA7v9GaVUP3sT1qq/ODFc rcCycUkHV3vEJdxTUIKETftxatRuA0LaTZpEfppz0JHTLNzzartXjAc/mClDPnbuBPgS oqtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GXILm0I5IyZchXO3FWsbqsS+MS2i8T8Zre1bWIXkhL8=; b=gJVtCC3RpZB7RKOmK9/jMyVsNA1NWZkmcIpLhDBQ/k/aDTX5luXF3fIMLj1zDVK37Y Q72zOfUOMEwsKy+fvYg0+4hCZucIphEp8x7y0NVtdGv5bxyjgeoADHRXBC45LYZF88K+ xnzbUfAb1JPiKesIQKk1Npqv0HVMmPxAaFYRDwNwBvNwzlc+QekjVW2vyOaE6hxjT5qX /djyqpSSW7LCgTe4IeDNW6OoqcnkL2NjFHQujPcRvfKGJ4a8fbYctjR9qt36AMJzschf DOvlZwkzXnmueX3iqOpVg4w06DpxRxBParF3XIQIuvi5DYUME0E3c7/8TOr7I0wA+QDS pmew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p207si3619769oic.111.2020.02.07.02.42.39; Fri, 07 Feb 2020 02:42:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbgBGKku (ORCPT + 99 others); Fri, 7 Feb 2020 05:40:50 -0500 Received: from foss.arm.com ([217.140.110.172]:38670 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbgBGKku (ORCPT ); Fri, 7 Feb 2020 05:40:50 -0500 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 55FDE30E; Fri, 7 Feb 2020 02:40:49 -0800 (PST) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 576A13F52E; Fri, 7 Feb 2020 02:40:48 -0800 (PST) Date: Fri, 7 Feb 2020 10:40:43 +0000 From: Sudeep Holla To: Peng Fan Cc: "viresh.kumar@linaro.org" , "f.fainelli@gmail.com" , dl-linux-imx , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linux-kernel , Sudeep Holla Subject: Re: [PATCH 2/2] firmware: arm_scmi: mark channel free when init Message-ID: <20200207104043.GA36345@bogus> References: <1580993846-17712-1-git-send-email-peng.fan@nxp.com> <1580993846-17712-2-git-send-email-peng.fan@nxp.com> <20200206143337.GC3383@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 07, 2020 at 02:16:04AM +0000, Peng Fan wrote: > > > Subject: Re: [PATCH 2/2] firmware: arm_scmi: mark channel free when init > > > > On Thu, Feb 06, 2020 at 08:57:26PM +0800, peng.fan@nxp.com wrote: > > > From: Peng Fan > > > > > > The firmware itself might not mark channel free, so let's explicitly > > > mark it free when do initialization. > > > > > > Also move struct scmi_shared_mem to common.h > > > > > > Signed-off-by: Peng Fan > > > --- > > > drivers/firmware/arm_scmi/common.h | 19 +++++++++++++++++-- > > > drivers/firmware/arm_scmi/mailbox.c | 2 ++ > > > drivers/firmware/arm_scmi/shmem.c | 18 ------------------ > > > 3 files changed, 19 insertions(+), 20 deletions(-) > > > > > > diff --git a/drivers/firmware/arm_scmi/common.h > > > b/drivers/firmware/arm_scmi/common.h > > > index fd091a4ccbff..5df262a564a4 100644 > > > --- a/drivers/firmware/arm_scmi/common.h > > > +++ b/drivers/firmware/arm_scmi/common.h > > > @@ -211,8 +211,23 @@ extern const struct scmi_desc scmi_mailbox_desc; > > > void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr); > > > void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, > > > int id); > > > > > > -/* shmem related declarations */ > > > -struct scmi_shared_mem; > > > +/* > > > + * SCMI specification requires all parameters, message headers, > > > +return > > > + * arguments or any protocol data to be expressed in little endian > > > + * format only. > > > + */ > > > +struct scmi_shared_mem { > > > + __le32 reserved; > > > + __le32 channel_status; > > > +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR BIT(1) > > > +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE BIT(0) > > > + __le32 reserved1[2]; > > > + __le32 flags; > > > +#define SCMI_SHMEM_FLAG_INTR_ENABLED BIT(0) > > > + __le32 length; > > > + __le32 msg_header; > > > + u8 msg_payload[0]; > > > +}; > > > > > > void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem, > > > struct scmi_xfer *xfer); > > > diff --git a/drivers/firmware/arm_scmi/mailbox.c > > > b/drivers/firmware/arm_scmi/mailbox.c > > > index 68ed58e2a47a..2d34bf6e94e2 100644 > > > --- a/drivers/firmware/arm_scmi/mailbox.c > > > +++ b/drivers/firmware/arm_scmi/mailbox.c > > > @@ -104,6 +104,8 @@ static int mailbox_chan_setup(struct > > scmi_chan_info *cinfo, struct device *dev, > > > cinfo->transport_info = smbox; > > > smbox->cinfo = cinfo; > > > > > > + iowrite32(BIT(0), &smbox->shmem->channel_status); > > > + > > > > +arm list > > > If we need this then we may need to put this as a function in shmem.c I am > > still not convinced if we can do this unconditionally, i.e. will that affect Rx > > channel if there's notification pending before we initialise. But we can deal > > with that later. > > Per understanding, channel is specific to an agent, it could not be shared. > So the shmem binded to the channel will not be used by others. > Yes > Since this is the initialization process, the firmware might not init the shmem. > But, is there any particular reason for firmware not to ? It means platform holds the channel and needs to release it to agent(OSPM) in this case after initialisation. > The shmem.c shmem_tx_prepare will spin until channel free, so I did the patch. > Otherwise it might spin forever. > Yes I guessed that to be reason. > I'll add a check as following > if (tx) > iowrite32(BIT(0), &smbox->shmem->channel_status); > Not yet, I need answers to above query. > I not find a good place to put this in shmem.c (: > Least of the problem :), let us first agree if we have to have it. > > > > Also what about error fields ? I would rather clear it to 0, not just BIT(0) > > Tx channel error should also be cleared, fix in v2. > OK but wait for a while before you post for the discussion to end. -- Regards, Sudeep