Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp778161iog; Thu, 30 Jun 2022 09:58:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1th+wT/ljvIcQ4XUc+hIp6qaIYDp+8Rqvxis5TK3AV1PF7OQiCCCTpc6wAHDiO1+YbX9Srr X-Received: by 2002:a17:906:f17:b0:6fe:94f6:cb8a with SMTP id z23-20020a1709060f1700b006fe94f6cb8amr9900985eji.456.1656608284500; Thu, 30 Jun 2022 09:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656608284; cv=none; d=google.com; s=arc-20160816; b=TaoL8UzCEf3+k9Q5HHXm+W+R15svpnRGwdLHZTa1M6OfoP+rJCHbrGcMumbBOf9WHS hZsjD3HYTs6LJ/BKTNOxEbCXDqqEBvArZfyS3qrcXN0xQGPJv3lnQN3Yh/JXhCm9sGn1 4e+WF1TCAvTNbe20ukLY8tknVSPthjN4enkFA+/cv9B3XTmBhsxejLvOw245AWaqaQwH 1O5wCyVY6zsavMtLdPSPkb4rYcTgzpaCdgGDVkBI6tYZ4zWTgmfy9DHyuSiDXISVpj+F j3RJGuhaAAyDbkb40oBrSE53nENzCgz6YtKobMoUDoHxykraxW1c2RxZGWjuRAE7c3sr AUIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=PPK7NJXmodZO2xtaWKpT2ki8JN6en9ktaebVlvJYU0M=; b=WThhApPb4qYi4DWhkgiDCEBuFqgyX/0+fGd7Yr5zjxuRHxIAATkyLJLuJACFKqXpmV /09uAy2aHfsXm3rG7+VQv25gFx0XqA2o4pPOnKK3CZnI6O2ersZL08tidV9TD/vwrzGz aw6cHqgNpyDF6ygS6vkucCBCTLE71+E1MaTyXl38Tr/v6/NaJYOzFpXH1GdiO2anZ/+U faE5hOojfa4xwZisox/fwwq/9FRRuAuq+IYFyNwf7DhhxiDzAf/5jvuYu328GF9cSTI1 WkM8+Mg4jI26BKIKBhndtgKbenaUspxArKDheu3vwciJ26AD8enihDkcAwyEBkB0ilVD ZtPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=tElMf53u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rp11-20020a170906d96b00b00717917b7d9csi2578683ejb.438.2022.06.30.09.57.34; Thu, 30 Jun 2022 09:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=tElMf53u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235789AbiF3QhG (ORCPT + 99 others); Thu, 30 Jun 2022 12:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235814AbiF3QhA (ORCPT ); Thu, 30 Jun 2022 12:37:00 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6941F3B559; Thu, 30 Jun 2022 09:36:59 -0700 (PDT) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25UDw2pc015110; Thu, 30 Jun 2022 18:36:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=PPK7NJXmodZO2xtaWKpT2ki8JN6en9ktaebVlvJYU0M=; b=tElMf53uO4MQd5obAVU2EXwhBYahEIvAisQM0Jlz1WtsxJBdK8k8qZDjfaDPugJPUMcg rCY0TP934ffw3jfgUIYvehxRwjm0j4/svm9Kcukj2it2QtF2rxLUNRl1ZwKNZoEeJh5R 1Tm1KSP2R20ADF77XYtEWtyH1GSxpX4lqs6M+wwLbzFDJwXur5XCTY58pl7cGZ4MjXXR BRPVPlp9pjJKaa/UoRROkPMHrpQr89gsDKf03kq8DvjAJ6tgac4KL1Byo9fmeYerhe8t BwWF6i1qaYPOTEEXctjvkAK5id7fWZF4HLJJv+8l34q7kjvHof2IzOaXxLPOLfceEWTz tA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3h1d648y1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Jun 2022 18:36:50 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 05CC610002A; Thu, 30 Jun 2022 18:36:49 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 012DC226FC5; Thu, 30 Jun 2022 18:36:49 +0200 (CEST) Received: from [10.252.24.34] (10.75.127.44) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 30 Jun 2022 18:36:45 +0200 Message-ID: <7881ee36-89f6-3ba9-f4ac-7c4e614728dd@foss.st.com> Date: Thu, 30 Jun 2022 18:36:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 1/2] remoteproc: core: Introduce rproc_del_carveout Content-Language: en-US To: Chris Lew , , CC: , , References: <1654888985-3846-1-git-send-email-quic_clew@quicinc.com> <1654888985-3846-2-git-send-email-quic_clew@quicinc.com> From: Arnaud POULIQUEN In-Reply-To: <1654888985-3846-2-git-send-email-quic_clew@quicinc.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-30_12,2022-06-28_01,2022-06-22_01 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 6/10/22 21:23, Chris Lew wrote: > To mirror the exported rproc_add_carveout(), add a rproc_del_carveout() > so memory carveout resources added by devices outside of remoteproc can > manage the resource lifetime more accurately. > > Signed-off-by: Chris Lew > --- > drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++++++++++ > include/linux/remoteproc.h | 1 + > 2 files changed, 21 insertions(+) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 02a04ab34a23..ee71fccae970 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1001,6 +1001,26 @@ void rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) > EXPORT_SYMBOL(rproc_add_carveout); > > /** > + * rproc_del_carveout() - remove an allocated carveout region > + * @rproc: rproc handle > + * @mem: memory entry to register > + * > + * This function removes specified memory entry in @rproc carveouts list. > + */ > +void rproc_del_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) > +{ > + struct rproc_mem_entry *entry, *tmp; > + > + list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { > + if (entry == mem) { > + list_del(&mem->node); > + return; > + } > + } > +} > +EXPORT_SYMBOL(rproc_del_carveout); This API seems to me quite dangerous because it can be called while carveouts are in use. At least some checks should be added... What about using rproc_resource_cleanup instead? Regards, Arnaud > + > +/** > * rproc_mem_entry_init() - allocate and initialize rproc_mem_entry struct > * @dev: pointer on device struct > * @va: virtual address > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 7c943f0a2fc4..43112aa78ffe 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -658,6 +658,7 @@ struct rproc *devm_rproc_alloc(struct device *dev, const char *name, > int devm_rproc_add(struct device *dev, struct rproc *rproc); > > void rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); > +void rproc_del_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); > > struct rproc_mem_entry * > rproc_mem_entry_init(struct device *dev,