Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1213191ybj; Tue, 5 May 2020 15:33:38 -0700 (PDT) X-Google-Smtp-Source: APiQypLucX3bC/0+qRzVRcEkBxQILIxt8KyEY1BP/HPHuWjPXhi6JsN1V6MbgOlkOYQAAKNaGhye X-Received: by 2002:aa7:d342:: with SMTP id m2mr4754395edr.341.1588718018243; Tue, 05 May 2020 15:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588718018; cv=none; d=google.com; s=arc-20160816; b=zy3YERr32zxLIeeYd8SVMC0b6sBU0Kab3yJGRipCXymurgCd5I6oD+W1CzdmOdGyqP fOOjv1bpXtYrbNEmtbJvQdUbDbxnNVHQVZcSGmH/5V/7juCXHQe33IY1fHbVYp3L8ABQ fy+jr9d84XHhOsqGisEK/n1DgAcIAkbIPAhyZ/f3u6EoKErq14ixbsjBDCgLFwyXRKzU uK5EcebYc3fJlycpcBIac+sZsVAK9QDc18+H2XVC12Vi9vewqO3cuHDF0wUNioQi1qpR D4sB+vW/B6T8WKS2cr4UKAazfDsw6GYbUls2iMB6f2kg2XEt6Elp6APKLKS6k0xvtnnx WeOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2xxVztmNYqOGfjjdgr4754NPPqPnQ38+rwBroaQlUMI=; b=FbbAWlOlexSL270mN0u1yNu+eNpteP0+WQd/+SiUheqQOCFNQmbDNLjzzcjUO/tQR4 V3rtMbXsNlmKJe6Lz51XvTJkAqgzopSNymENWxyGljrRXd6gF7MFmLkt2/zBbV+TKbXA 9m2PIivg/XiHAU/jK7UxmOWIiUBzaAwOwS1TIATXspJT0lPVr5Ut10qwuUUKZvy+BxAS p+SgnnPzk791H2AVdS+c4lhlHy8udFNeG+bEZjVlheDosfqkjsqbM3v88F4WQtFb9QAM 0zFW6KkK/xmolooYzzThSG1nf3Xh8Ycz3hUn1PUtCn7/xWmC+dUH2G46QJOTOF4K2GZW Rm3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YOLnVZG2; 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 p4si56792ejd.3.2020.05.05.15.33.14; Tue, 05 May 2020 15:33:38 -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=YOLnVZG2; 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 S1729327AbgEEWbO (ORCPT + 99 others); Tue, 5 May 2020 18:31:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728934AbgEEWbO (ORCPT ); Tue, 5 May 2020 18:31:14 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42420C061A41 for ; Tue, 5 May 2020 15:31:14 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t16so1456652plo.7 for ; Tue, 05 May 2020 15:31:14 -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; bh=2xxVztmNYqOGfjjdgr4754NPPqPnQ38+rwBroaQlUMI=; b=YOLnVZG2/hq4lTk59fWo+fRGNhnSnVIsi7eSgGm1NIlRpfElJK1gZjV2pzJjHSLTMx DSQZSG5Kz2uif3xFuLyv4H8KeOE6KVw5+9paaylOxI9dSf3IOYfaEFJGtJHrHGefxTBt 4CtdqD3u+ZAW6E9+5UoxrSeSbjj6Os2TNffLe60CNTwbzNqfAEKQ9yL/6SmC29ap7X4a 6DWKkcMRxznVf4f9wIDD8/IHorxf6vUJYWzejerjtAXSqym783ByP6sxQLA1UHj8+7kW JPvE9NmZuZwlgif3BRDodLj/A9/cAyJJxT2/1xobZ3B8vBqPwKfvfu2l5C6bhSjH1gck sDIQ== 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; bh=2xxVztmNYqOGfjjdgr4754NPPqPnQ38+rwBroaQlUMI=; b=IuDMxtrmWmvCw3TJSKVMz6zE2bQ7pEX5p3rSr4zGnlRiYPY0j3sWTIYMjaL+P6WMbd JOmi8nNUCa8eKRlDUnulSaFaxKhk8OX1o1y6sdwSFwUBu1sWd4UQAl/wJeZalUFMabJA rX5YTNmCASklZyBDHZbIDfoM53oMbfnNhh4VcpwzOfnOKG9TDg75k2/gYloOtnSUMa06 9eI6a4YBTgT3xC6/FtGgsYVZ/DcGSld2b1VDzCUU3aYbpCQTe6gFvFEW63NPJ0pLsFdc CpG02Lo7rG8lXlS7tN+gcUxWXb2cFNXcSi+yDx/quxNGme2R5GQHL0xlFCe47rz0cNgk C0Jg== X-Gm-Message-State: AGi0PuZvnwalTB1I/myOKd/4IXB4HHkj/Vop9QsCgVLZG+dfHqBTTpoW i487l4C6hcaWNLUZBedSA37EeA== X-Received: by 2002:a17:90b:957:: with SMTP id dw23mr5793353pjb.101.1588717873532; Tue, 05 May 2020 15:31:13 -0700 (PDT) Received: from builder.lan (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id g16sm20985pfq.203.2020.05.05.15.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 15:31:12 -0700 (PDT) Date: Tue, 5 May 2020 15:31:58 -0700 From: Bjorn Andersson To: Mathieu Poirier 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: <20200505223158.GB2329931@builder.lan> References: <20200424200135.28825-1-mathieu.poirier@linaro.org> <20200424200135.28825-3-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200424200135.28825-3-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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? 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 >