Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4631137imm; Mon, 14 May 2018 10:14:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoxjMt1bALLAuHYd6c8OY6KrBv3zVmAgngAVBpSJa6x7h8sfU8D6zwgmOmzIU6Qst26CC3u X-Received: by 2002:a63:31d8:: with SMTP id x207-v6mr9164625pgx.411.1526318048036; Mon, 14 May 2018 10:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318048; cv=none; d=google.com; s=arc-20160816; b=b+07S9zabqwugQUfPLuFwxc9eiX1Cbsyu+c8z6EFr2vEzyrr4zVcI6pMaSPCW8SfNG dRREEQ1mqQ9M0AI3ytz8Jqiat2a8SlOHV/F0wC1JcBPMiFSDrdVoPfgZgeAXGIzTstSi VFmzp+6WUQjrs7WbZTWZ855fLA47EsOBxGFtHnSXtDBOgwAz2EQG5BSBDv0WPBLIBbRm F5sCOYQ2qz0L6+DCt3pwhdR6ug/i1Cw7IF0nMeVuE/zXiPo+LuzocETvPgSNBKcYTEIF FF2aC8D7YtNv/c2px8ghIkOOU/IcMr64xKxD+6UL5EVsENHAsy/rNJaRGPLJC2fYcbzr A5Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=T37DTnRxQBanbd7Yca6h0gAbwcjP9N2ibZdmjaaEDms=; b=AB2Mco9q+MvdpcDkcbFHnDyoxr8k737Zc1olbJ8ty15SfT3T6WpDDMC2f1jriMtzbW wIB78V2R0CSENDiTM5xb/6IhKkzuMU79spGS38rH6R2F6N/HIYbFegVBkzc9qwejAv0m fHiPoKeE7f1QFQdYBlyydb9IUzlSz/zmWHs2wLji1YxAq4SO4G3mZyvCEXhm2Vqmrv3s UEOvr82z1x4doGbnw5Ak9SpAQQeRJKmtvwA9OIZG3DUvywRpOwMjIVhWq8qecUXgxIbS IkfgmdQcDGVHyulDdeTxskAGAgiAgf4qmVfFMaUJ1ZiWza/0pgCPYWcAT2L+TSxlQcU2 buCg== 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 i65-v6si10553397pfb.343.2018.05.14.10.13.53; Mon, 14 May 2018 10:14:07 -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; 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 S1754433AbeENPDF convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 May 2018 11:03:05 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:48538 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752937AbeENPDD (ORCPT ); Mon, 14 May 2018 11:03:03 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w4EExIxT004073; Mon, 14 May 2018 17:03:01 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2hwq5e2t0c-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 14 May 2018 17:03:01 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2273831; Mon, 14 May 2018 15:03:01 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0813B58F1; Mon, 14 May 2018 15:03:01 +0000 (GMT) Received: from SFHDAG7NODE2.st.com (10.75.127.20) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 14 May 2018 17:03:00 +0200 Received: from SFHDAG7NODE2.st.com ([fe80::d548:6a8f:2ca4:2090]) by SFHDAG7NODE2.st.com ([fe80::d548:6a8f:2ca4:2090%20]) with mapi id 15.00.1347.000; Mon, 14 May 2018 17:03:00 +0200 From: Loic PALLARDY To: Bjorn Andersson CC: "ohad@wizery.com" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Arnaud POULIQUEN , "benjamin.gaignard@linaro.org" Subject: RE: [PATCH v3 08/13] remoteproc: add prepare and unprepare ops Thread-Topic: [PATCH v3 08/13] remoteproc: add prepare and unprepare ops Thread-Index: AQHTsXm9dYPIVY3zHU+69HELf8b3rKQobfSAgAdYTlA= Date: Mon, 14 May 2018 15:03:00 +0000 Message-ID: References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> <1519921440-21356-9-git-send-email-loic.pallardy@st.com> <20180510005249.GF29093@builder> In-Reply-To: <20180510005249.GF29093@builder> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.51] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-14_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Bjorn Andersson [mailto:bjorn.andersson@linaro.org] > Sent: Thursday, May 10, 2018 2:53 AM > To: Loic PALLARDY > Cc: ohad@wizery.com; linux-remoteproc@vger.kernel.org; linux- > kernel@vger.kernel.org; Arnaud POULIQUEN ; > benjamin.gaignard@linaro.org > Subject: Re: [PATCH v3 08/13] remoteproc: add prepare and unprepare ops > > 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. Agree Regards, Loic > > > + > > 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