Received: by 10.192.165.148 with SMTP id m20csp531667imm; Wed, 9 May 2018 17:54:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoItGankSQiKwvg0ngfCMI4BjbS2jNM+Svq1AA3vk50WNRd8yHEfeYr1/o8jkRraQjCqgPD X-Received: by 2002:a65:43cb:: with SMTP id n11-v6mr36589642pgp.287.1525913669500; Wed, 09 May 2018 17:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525913669; cv=none; d=google.com; s=arc-20160816; b=VJ5jm3ETzOUKF/6YDhjcM8/gwBDbv4CqqSqKckJBXR4DDWgMG9sTj1k4aAYVvVgVqQ PWoLeTcf+9zi+VT5tA81/D1OyFmM5CzavXCreRFZwuTO9gga3+QqImGa7eqJeC2ioS6D bbl5Hrg6FiP8QWDkFDH/cnk2KDX12nsVo37vr+xa9gnOzLQZILzz46gqdZSh4lvJrjMe Tf0Gdz5mLD4b64XwxYPWCzosPffMDMMLpUo0NQqEa0V0df0wwm+u0Lc3kYFXVu6dOqhm ocgZJ168iDYf8pAe4rviiITIcCZvVc3e7xyGTnQi4tRfDCERSz6eyrwmLCYkh4CSLFDn YIUQ== 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:arc-authentication-results; bh=W2oMD7zE4fXtOaH5g8HeNHIwWTrrIa5+efOFDtxYbOE=; b=JDwhkV0lXMTKdyYP2JxYy5e8jv06Sx0pWXuUEm0uLIqTPG7kgRlT/t76Ua/rEsYnIH ZTdIgcB5DBRg19W1s08vUxSYK7shMkrcvAPACoBBKPN+u/coOcO2SJ+qC0r4Usj+iQtK ARCxlEbQg3P+NLmAIJxyHweFzy8/DcvCxANSoWqFoeOah4sA+0ObKjRWdMPUAUoDPSUZ 6l4cixGtL4aUymurPKh1AScVyCvb/WWor9Zzxj4kK1yhm3o3S38VsfMUl0WC+HMQ6oTw z9IuvCZvrfgfWHk5MBzvZdIDL4YcBgDZnNKWXit0nOGJIVKiE2/lnq5j4PYfdfC7izRZ eBFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jXkih6EM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f88si28118839pfk.107.2018.05.09.17.54.15; Wed, 09 May 2018 17:54:29 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=jXkih6EM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966051AbeEJAwy (ORCPT + 99 others); Wed, 9 May 2018 20:52:54 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38603 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965924AbeEJAww (ORCPT ); Wed, 9 May 2018 20:52:52 -0400 Received: by mail-pf0-f196.google.com with SMTP id o76-v6so208066pfi.5 for ; Wed, 09 May 2018 17:52:52 -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=W2oMD7zE4fXtOaH5g8HeNHIwWTrrIa5+efOFDtxYbOE=; b=jXkih6EMzbZArZbFqrbloiHKgfmbrLOpjZVZHqFYiIcsL7ImQRc2P7QOUO0sQ8JroJ 5zzyItsPTsC8CCsBelogNBMlBzIsTBl1GVX0UwQjaTAOOXWztObEN+BwQz5LtKH03ekH qpIpI8xaPkGZfTL75QG9kujOPIwFnYWDCL/0s= 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=W2oMD7zE4fXtOaH5g8HeNHIwWTrrIa5+efOFDtxYbOE=; b=sAwuMaLKalF7G/y09VUk+SZRvflTiiKOf735hoCiotEc4ljWm4TZf4n+Cwq5g/9xu9 Raclq8zt9hgvygQCnfvECm/bKd1qknExAw+c0jA3XkzkZN1HGxFVjtiXiStwFvYhSVol m+SIlQaLjHebAWAqDNYsdBCIjJop1++Xxlf9+mKfCN1nSMJ28HYRmcCjH1L/9lphYSpS uPjjHSf3r8UFaifTNY4yBjY73xbNvQaqaqKmdLJO21wb37LKQmta2QRCWAhcIr/bVdSQ /a8PJnVu+SXex8uYigEXwrB5E2HqBXXDh/OaoJHAkPX/NOJoHdoTSTEzzzH1NF1Z223O H7Vg== X-Gm-Message-State: ALKqPwc7y+tD7PgSK+fOiqv67EYnXOB+s2ADpr280Z7OGfmflshD5f1D 3EEF2Wsypp//QfD9jcWz/ypZaw== X-Received: by 2002:a63:824a:: with SMTP id w71-v6mr6303229pgd.37.1525913571961; Wed, 09 May 2018 17:52:51 -0700 (PDT) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t14sm7376065pfh.109.2018.05.09.17.52.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 17:52:51 -0700 (PDT) Date: Wed, 9 May 2018 17:52:49 -0700 From: Bjorn Andersson To: Loic Pallardy Cc: ohad@wizery.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com, benjamin.gaignard@linaro.org Subject: Re: [PATCH v3 08/13] remoteproc: add prepare and unprepare ops Message-ID: <20180510005249.GF29093@builder> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> <1519921440-21356-9-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519921440-21356-9-git-send-email-loic.pallardy@st.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 01 Mar 08:23 PST 2018, Loic Pallardy wrote: > On some SoC architecture, it is needed to enable HW like > clock, bus, regulator, memory region... before loading > co-processor firmware. > > This patch introduces prepare and unprepare ops to execute > platform specific function before firmware loading and after > stop execution. > > Signed-off-by: Loic Pallardy > --- > drivers/remoteproc/remoteproc_core.c | 20 +++++++++++++++++++- > include/linux/remoteproc.h | 4 ++++ > 2 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 7a500cb..0ebbc4f 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1058,12 +1058,22 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > return ret; > } > > + /* Prepare rproc for firmware loading if needed */ > + if (rproc->ops->prepare) { > + ret = rproc->ops->prepare(rproc); > + if (ret) { > + dev_err(dev, "can't prepare rproc %s: %d\n", > + rproc->name, ret); > + goto disable_iommu; > + } > + } We do allow drivers to implement custom versions of parse_fw() - and they can call the resource-table-parse-fw from the custom function. So with the proposed refactoring in patch 9 I would like for parse_fw() to call back into the core to fill out the resource lists and then before jumping to rproc_start() we loop over the allocator functions. > + > rproc->bootaddr = rproc_get_boot_addr(rproc, fw); > > /* load resource table */ > ret = rproc_load_rsc_table(rproc, fw); > if (ret) > - goto disable_iommu; > + goto unprepare_rproc; > > /* reset max_notifyid */ > rproc->max_notifyid = -1; > @@ -1086,6 +1096,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > kfree(rproc->cached_table); > rproc->cached_table = NULL; > rproc->table_ptr = NULL; > +unprepare_rproc: > + /* release HW resources if needed */ > + if (rproc->ops->unprepare) > + rproc->ops->unprepare(rproc); > disable_iommu: > rproc_disable_iommu(rproc); > return ret; > @@ -1331,6 +1345,10 @@ void rproc_shutdown(struct rproc *rproc) > /* clean up all acquired resources */ > rproc_resource_cleanup(rproc); > > + /* release HW resources if needed */ > + if (rproc->ops->unprepare) > + rproc->ops->unprepare(rproc); And this would then be handled by the rproc_resource_cleanup() function, looping over all resources and calling release(). Regards, Bjorn