Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp10720ybk; Fri, 8 May 2020 12:39:28 -0700 (PDT) X-Google-Smtp-Source: APiQypKv49dsYcbPUyp9CuTHsv20C9n+wejVTwIs/woUeC/JIHgPP4eCjwGNBqqdCxVHcZZbmAKY X-Received: by 2002:a05:6402:793:: with SMTP id d19mr3524177edy.95.1588966768781; Fri, 08 May 2020 12:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588966768; cv=none; d=google.com; s=arc-20160816; b=mT+x/CsytTBsMOr7D950o3Er7YXZHlWFPBzsYoF3MPQGa2n4svRC3eAUUn/kVk0qXh teMr38iP41opQx7N1Afk2vALX8r10qY6T/GvczJu+0ILysAlZBYGgjuCF3UE49soNR38 XMIsLXNRjDXdF42bVf0HY8RQbHxR0PVnfeNrwziDFityo01EUwZuSC7oD9PNxCn2Sguq 1nZha1Wd5t61AXyWnPhdzNjBbXADhc86ukMn0dtBGXeiYlsVQa70z3N5HbUVWiHYrU4M 5xggpxUT+A7pLvRbg9YgGdks1x3sdYcRDaTuvUXBty4ZY884qTN/ggkm01Xgra7UYGDJ QuOQ== 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:dkim-signature; bh=MM+EfAjkHc8LoqfMvtzvccHII1WH38gRuXMGYiBBnFE=; b=EzQEbUPAptfQBCfiN4eRtX/kHox25xuoB2+hzrf/885ZU0r6Goh16a6VXIEN759PS7 ZpWfohrAJeHD0Klk2Tv58D6W1MO4Ffc5VVG3MT4WC+zzGdPWmVEYKl1nR1LbW4/yAhOe WazSydreKoGanNE6GicJ4Fg6u6lX/QGPFxyTOt+3tWggoCLR1j20q2H0MjcitmBw2lVf s+pMOSkau7acbptMdVKQaPaP7Z4SI45rqigPjudxziQSeo9kdrmCH8Fy/Ghl7JpyTvSz wFq8zi/2/vO+oNtyhBOg3Q1j2USFQpANIOcY8KjYsaBQr/uNA1+Ar4p6SN7cCDHLdP5w btFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WwYKQExG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by19si1408591ejc.362.2020.05.08.12.39.03; Fri, 08 May 2020 12:39:28 -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; dkim=pass header.i=@linaro.org header.s=google header.b=WwYKQExG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgEHTh1 (ORCPT + 99 others); Fri, 8 May 2020 15:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726767AbgEHTh1 (ORCPT ); Fri, 8 May 2020 15:37:27 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E4E8C061A0C for ; Fri, 8 May 2020 12:37:27 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id m7so1173002plt.5 for ; Fri, 08 May 2020 12:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MM+EfAjkHc8LoqfMvtzvccHII1WH38gRuXMGYiBBnFE=; b=WwYKQExGgTsrssSscMFy2ZBRu0gm/Ws61srkCzbPrdobD6SIqhjBoo9/qTYuJmsrSd mzp77tIMnN9Y4WcLsFL1cGbN3P/qcSC58VVgYrhsZMI16iyUVJfP/cH7l30NpcsNt4Aj Yj6AN4YQBscNlDxlEEO/OuUdkQUyXSV7mRPaVaK9PY5iHNMBELaz8lWHDvxbr0/5wO7+ cQjYwqhhRuB6P8Q3bJTgkqGhQEKiBcRWN/ip7offgtTJBRrCuMv34z0K/JDztIhsFqmS 5qXsvrIg7mHwVghYDxZIPyKWmc/bZ63YwLd1R54Hjc8f7ZsVaijK9hUa7P7yufVdpLEV WV1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MM+EfAjkHc8LoqfMvtzvccHII1WH38gRuXMGYiBBnFE=; b=Uyna81hxzMzIUGKpB99oTbl/Nw5gVO0WPas1oHks+Tq1dru24vM3zQySVe1P6XLbBe D+6RBnoHj/UgLcAARJ2n5nIS76C0Qf8klUv2Y4jcEOOLS6+RD+YLMjw8eqBEhMvm+5L8 9cjHPOwLCUggzVDof5H+6YFEQ4R7HLoJajJS6NvckyW7SuiDKgO/b5ehmzluVxhhSaLD x28749s6cYLXaI89eGxcVXi312TxcLLI8ykckaVODA5LeQIxKYQY+2lTAy8opc6pdQiC L76kOzZ73EMl6NA52bIDBbLEvhfiNJnhrR77HANFL4H4Rf5HjR5T3HO1R67abI1mDlJ+ Om9g== X-Gm-Message-State: AGi0PuZDII7WJtzApbop7GJj/CDZiIgArkzipdsD5PLMVKClK3B1eewz 44z5bJJqy0aiseo78wCuxfBFNg0uiKo= X-Received: by 2002:a17:902:bcc4:: with SMTP id o4mr3594492pls.275.1588966646505; Fri, 08 May 2020 12:37:26 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c84sm2640455pfb.153.2020.05.08.12.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 12:37:25 -0700 (PDT) Date: Fri, 8 May 2020 13:37:23 -0600 From: Mathieu Poirier To: Bjorn Andersson Cc: ohad@wizery.com, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 02/14] remoteproc: Introduce function rproc_alloc_internals() Message-ID: <20200508193723.GB4526@xps15> References: <20200424200135.28825-1-mathieu.poirier@linaro.org> <20200424200135.28825-3-mathieu.poirier@linaro.org> <20200505223158.GB2329931@builder.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505223158.GB2329931@builder.lan> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 05, 2020 at 03:31:58PM -0700, Bjorn Andersson wrote: > On Fri 24 Apr 13:01 PDT 2020, Mathieu Poirier wrote: > > > In scenarios where the remote processor's lifecycle is entirely > > managed by another entity there is no point in allocating memory for > > a firmware name since it will never be used. The same goes for a core > > set of operations. > > > > As such introduce function rproc_alloc_internals() to decide if the > > allocation of a firmware name and the core operations need to be done. > > That way rproc_alloc() can be kept as clean as possible. > > > > Signed-off-by: Mathieu Poirier > > --- > > drivers/remoteproc/remoteproc_core.c | 31 +++++++++++++++++++++++----- > > 1 file changed, 26 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > > index 448262470fc7..1b4756909584 100644 > > --- a/drivers/remoteproc/remoteproc_core.c > > +++ b/drivers/remoteproc/remoteproc_core.c > > @@ -2076,6 +2076,30 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops) > > return 0; > > } > > > > +static int rproc_alloc_internals(struct rproc *rproc, > > + const struct rproc_ops *ops, > > + const char *name, const char *firmware) > > +{ > > + int ret; > > + > > + /* > > + * In scenarios where the remote processor's lifecycle is entirely > > + * managed by another entity there is no point in carrying a set > > + * of operations that will never be used. > > + * > > + * And since no firmware will ever be loaded, there is no point in > > + * allocating memory for it either. > > While this is true, I would expect that there are cases where the > remoteproc has ops but no firmware. > That is a scenario I did not envisioned, but I agree, the remote processor could be fetching from a private ROM memory and still required handling from the remoteproc core. > How about splitting this decision already now; i.e. moving the if(!ops) > to rproc_alloc_ops() and perhaps only allocate firmware if ops->load is > specified? > Or just add "if (ops->load)" before calling rproc_alloc_firmware()... Otherwise we need to change the calling order of rproc_alloc_firmware() and rproc_alloc_ops() in order to make sure 'ops' is valid when calling the former. Either way I'll add a comment with the rationale you have detailed above. > Regards, > Bjorn > > > + */ > > + if (!ops) > > + return 0; > > + > > + ret = rproc_alloc_firmware(rproc, name, firmware); > > + if (ret) > > + return ret; > > + > > + return rproc_alloc_ops(rproc, ops); > > +} > > + > > /** > > * rproc_alloc() - allocate a remote processor handle > > * @dev: the underlying device > > @@ -2105,7 +2129,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, > > { > > struct rproc *rproc; > > > > - if (!dev || !name || !ops) > > + if (!dev || !name) > > return NULL; > > > > rproc = kzalloc(sizeof(struct rproc) + len, GFP_KERNEL); > > @@ -2128,10 +2152,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, > > if (!rproc->name) > > goto put_device; > > > > - if (rproc_alloc_firmware(rproc, name, firmware)) > > - goto put_device; > > - > > - if (rproc_alloc_ops(rproc, ops)) > > + if (rproc_alloc_internals(rproc, ops, name, firmware)) > > goto put_device; > > > > /* Assign a unique device index and name */ > > -- > > 2.20.1 > >