From patchwork Fri Aug 30 09:51:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 13784864 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C087BCA0EFB for ; Fri, 30 Aug 2024 10:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0DlUTkUaPavTozbvsNzJHph9lUJ8rhMJbIvd+RFIDXU=; b=P7bm1Lx95IqU6lyHFn3Y78uj/f or25JticUGwdyFtgwNU/CN0YH5MrwkYJ1nsjsRhk5bKZ/vEsSZaAZ/+MsJ9gtPH71M0fo0aFq9t4C p29uwBMlhIP/FcsUkTAeid9RjS4JojeWKasKlhHVhjecJekfMDRVSlRxnCS1wtsM0W8v70Ypx+A9Z izl44W7ZmiEFV0fSE4zbG8yfWaFJwp+IuHAT10ZvOXRgrf1660lRVZ3ZGvOLaCxMEJga3SXadYv8U LjrTg2tQPZzVdQm4ENDJQrmu9uhFjsXjdOz0bEXDgsq9Xr3qdvBwUCH5zoU65jCZg06U2cTm9+tPz poz8Vt0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjyRG-00000005gAA-0ECx; Fri, 30 Aug 2024 10:01:06 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjyJl-00000005e6F-29oY for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 09:53:25 +0000 Received: from pps.filterd (m0369458.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U7T05s005594; Fri, 30 Aug 2024 11:53:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= 0DlUTkUaPavTozbvsNzJHph9lUJ8rhMJbIvd+RFIDXU=; b=XHyn1gCeEcu6GMeE Tnfw5YP8LI/TAMks9Mo0CCENu6SyrHuhfgzyLBxIV//EPQFgYmmPMtf9SCE/z28T UJ4eKObCmPrMhmIFs4O45WzbUScfx5AO/Jqd8t9KHdI8lfrin+z/m7Tr0eQRkt2W k23+rrEAWBYWetFRCnd8SwelykdqqLADbf/nLLI0dnnlGouk5tkoZCNPLqrSF32O 860j75F1a+tyiqUis9YKDgMk7b887tFT09uTSnfuHwCXUFqIxqzJhi2r6D59dadr DDUmMeAXM4wUkE9gqBjc616inTaPM6/LkhrLIUrOsoB90PITu75Md5dxK/ZOclDQ iJhOUA== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 41b14tabey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Aug 2024 11:53:10 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 5902A4004B; Fri, 30 Aug 2024 11:53:06 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node4.st.com [10.75.129.133]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AC31A256519; Fri, 30 Aug 2024 11:52:17 +0200 (CEST) Received: from SAFDAG1NODE1.st.com (10.75.90.17) by EQNDAG1NODE4.st.com (10.75.129.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 30 Aug 2024 11:52:17 +0200 Received: from localhost (10.48.86.121) by SAFDAG1NODE1.st.com (10.75.90.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 30 Aug 2024 11:52:17 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v9 3/7] remoteproc: core: Refactor resource table cleanup into rproc_release_fw Date: Fri, 30 Aug 2024 11:51:43 +0200 Message-ID: <20240830095147.3538047-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240830095147.3538047-1-arnaud.pouliquen@foss.st.com> References: <20240830095147.3538047-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.48.86.121] X-ClientProxiedBy: SAFCAS1NODE2.st.com (10.75.90.13) To SAFDAG1NODE1.st.com (10.75.90.17) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_04,2024-08-30_01,2024-05-17_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240830_025321_965317_03310D2C X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch centralizing the cleanup of the resource table into a new helper function rproc_release_fw(). Suggested-by: Mathieu Poirier Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ace11ea17097..7694817f25d4 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1256,6 +1256,13 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) return 0; } +static void rproc_release_fw(struct rproc *rproc) +{ + /* Free the copy of the resource table */ + kfree(rproc->cached_table); + rproc->cached_table = NULL; + rproc->table_ptr = NULL; +} /** * rproc_resource_cleanup() - clean up and free all acquired resources @@ -1485,9 +1492,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) clean_up_resources: rproc_resource_cleanup(rproc); - kfree(rproc->cached_table); - rproc->cached_table = NULL; - rproc->table_ptr = NULL; + rproc_release_fw(rproc); unprepare_rproc: /* release HW resources if needed */ rproc_unprepare_device(rproc); @@ -2067,10 +2072,7 @@ int rproc_shutdown(struct rproc *rproc) rproc_disable_iommu(rproc); - /* Free the copy of the resource table */ - kfree(rproc->cached_table); - rproc->cached_table = NULL; - rproc->table_ptr = NULL; + rproc_release_fw(rproc); out: mutex_unlock(&rproc->lock); return ret; @@ -2133,10 +2135,7 @@ int rproc_detach(struct rproc *rproc) rproc_disable_iommu(rproc); - /* Free the copy of the resource table */ - kfree(rproc->cached_table); - rproc->cached_table = NULL; - rproc->table_ptr = NULL; + rproc_release_fw(rproc); out: mutex_unlock(&rproc->lock); return ret;