From patchwork Fri Jun 10 19:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lew X-Patchwork-Id: 580739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A2A4CCA47D for ; Fri, 10 Jun 2022 19:23:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350190AbiFJTXk (ORCPT ); Fri, 10 Jun 2022 15:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348431AbiFJTXi (ORCPT ); Fri, 10 Jun 2022 15:23:38 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514D319A716; Fri, 10 Jun 2022 12:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654889014; x=1686425014; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=cbrgv8TDzoatHjPZVFim5i2LawHczsWot+p66zxC0K0=; b=XVd2CSTYzl3LZobVdcFDTg+fA8SVCaNn2svdc8eKLxgDNd7WvK8N2sJ9 KQznoI4Cz44I7XOyec+tgO9JyiLmzm3iWAEi9KIB1QhVaDNYx6HQwJDMy yQkoCPLRhdhrAu4ZJXaJ/AemJa60efXkeheKVf2bH9wOdUJsZ+Aa3A5Z2 0=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 10 Jun 2022 12:23:34 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 12:23:33 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 10 Jun 2022 12:23:33 -0700 Received: from hu-clew-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 10 Jun 2022 12:23:32 -0700 From: Chris Lew To: , CC: , , , Subject: [PATCH 1/2] remoteproc: core: Introduce rproc_del_carveout Date: Fri, 10 Jun 2022 12:23:04 -0700 Message-ID: <1654888985-3846-2-git-send-email-quic_clew@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1654888985-3846-1-git-send-email-quic_clew@quicinc.com> References: <1654888985-3846-1-git-send-email-quic_clew@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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); + +/** * 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, From patchwork Fri Jun 10 19:23:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lew X-Patchwork-Id: 581278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DC43C433EF for ; Fri, 10 Jun 2022 19:23:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233646AbiFJTXj (ORCPT ); Fri, 10 Jun 2022 15:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348545AbiFJTXi (ORCPT ); Fri, 10 Jun 2022 15:23:38 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC7B19A711; Fri, 10 Jun 2022 12:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654889015; x=1686425015; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=S+DeJ3MsyXef9jo7MlX4F9bDqqCTfY+AdSWc6kyR9DU=; b=ncy1UTC5atH6gW77/v/eQAPDyQK9dErNoTeO9y0XPdZGqiz1kTxCgaSU KY6a2M2ydId3Ivbp/9YYMt7YTBTW/YbddmDi2XguXN5Y9UdaXJbRQfny1 6G2F3R5yPfFOXFCh7Xma4zUoLuoWLfhJcp9e64u0yRHhCMY/QXFL6yNYY 4=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 10 Jun 2022 12:23:35 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 12:23:34 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 10 Jun 2022 12:23:33 -0700 Received: from hu-clew-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 10 Jun 2022 12:23:33 -0700 From: Chris Lew To: , CC: , , , Subject: [PATCH 2/2] remoteproc: core: Introduce rproc_mem_entry_free Date: Fri, 10 Jun 2022 12:23:05 -0700 Message-ID: <1654888985-3846-3-git-send-email-quic_clew@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1654888985-3846-1-git-send-email-quic_clew@quicinc.com> References: <1654888985-3846-1-git-send-email-quic_clew@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Introduce a helper to free the rproc_mem_entry allocated by rproc_mem_entry_init(). This helper is to help manage rproc carveouts added to an rproc outside of remoteproc. Signed-off-by: Chris Lew --- drivers/remoteproc/remoteproc_core.c | 13 +++++++++++++ include/linux/remoteproc.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ee71fccae970..161691fd2e96 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1069,6 +1069,19 @@ rproc_mem_entry_init(struct device *dev, EXPORT_SYMBOL(rproc_mem_entry_init); /** + * rproc_mem_entry_free() - free a rproc_mem_entry struct + * @mem: rproc_mem_entry allocated by rproc_mem_entry_init() + * + * This function frees a rproc_mem_entry_struct that was allocated by + * rproc_mem_entry_init(). + */ +void rproc_mem_entry_free(struct rproc_mem_entry *mem) +{ + kfree(mem); +} +EXPORT_SYMBOL(rproc_mem_entry_free); + +/** * rproc_of_resm_mem_entry_init() - allocate and initialize rproc_mem_entry struct * from a reserved memory phandle * @dev: pointer on device struct diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 43112aa78ffe..9b039f37da12 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -666,6 +666,7 @@ rproc_mem_entry_init(struct device *dev, int (*alloc)(struct rproc *, struct rproc_mem_entry *), int (*release)(struct rproc *, struct rproc_mem_entry *), const char *name, ...); +void rproc_mem_entry_free(struct rproc_mem_entry *mem); struct rproc_mem_entry * rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len,