From patchwork Fri Oct 25 20:59:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 13851790 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CF12217F26; Fri, 25 Oct 2024 21:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729890101; cv=none; b=Yv6ZZ8sGVrssqnD+Zk4GDRpi+gZx1bm3QiUuPptrPSjK9WhSe+tnyIaUOdIgPoLo+nUlriQXPYGm4rB0hg7BISIajTF2KrgX4byzeACybWjYo8DgQenk82CaBY5lJv3MaC0DmUypgDigY47IOsq9CG8HajEFsCWXa/oq7A0N+Ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729890101; c=relaxed/simple; bh=cJuK47Izb/yOOkLNmgo4HCInjKy++jMUEPG88YvhDbM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r9/cKoTZLo5STVS69ARwL8R9Cdn/cLoP2zdaCIOaeRD0WB6XJOICLEcgsMGUcCuPKRIQs/sOwHE0Nf75QTvmKutZ4e4eERqCyOXFOVAapFfd31k6pIPIAlG9oup3fn4G4Wx9DvnLWTlC1wgvoE859xcL2sSd9LOLobguVMi3fHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=YXh9WzDS; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="YXh9WzDS" Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49PGF1DI020510; Fri, 25 Oct 2024 23:01:27 +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= ZNLtnXlcsjv6+bG/WiTbNNMC780ssIybEZlto6rwvE4=; b=YXh9WzDSjdnG4nAI W5qwjIDBsYQHa5dHyFdoL0JRb3FKz3xRWyPXHTChYLS8P6OL9nilYGlv5w2FhOsU p7Bkm7vJt/WezC4rwdLMhERyJyJGS2zWKcShttgDVf8ALVFIweB3ZVHnamPjYPiS cNiGoQhSq7TCPzbFM5m9KN1j31AbhH8mcLo2lo1HNTMZBuS2rN7XLfsvFLVd/6le +G1L6B96n+6ncTup3Ca9TmB57MLyhWt5QmnVPnpcrl8J3tp3177VmgDnIttuPvT/ FanSob8qg2z5NpwL4F9yv6tibOzwBPJU7KF7oy45r1CiOGLI7ryoqIIJ/V3XnCgy KA5sJQ== 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 42g9brt9m8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Oct 2024 23:01:27 +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 08C9840048; Fri, 25 Oct 2024 23:00:28 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node6.st.com [10.75.129.135]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 53FF2231534; Fri, 25 Oct 2024 22:59:36 +0200 (CEST) Received: from SAFDAG1NODE1.st.com (10.75.90.17) by EQNDAG1NODE6.st.com (10.75.129.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 25 Oct 2024 22:59:36 +0200 Received: from localhost (10.252.3.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, 25 Oct 2024 22:59:35 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v12 3/7] remoteproc: core: Refactor resource table cleanup into rproc_release_fw Date: Fri, 25 Oct 2024 22:59:20 +0200 Message-ID: <20241025205924.2087768-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241025205924.2087768-1-arnaud.pouliquen@foss.st.com> References: <20241025205924.2087768-1-arnaud.pouliquen@foss.st.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 This patch centralizing the cleanup of the resource table into a new helper function rproc_release_fw(). More than just factorizing the code into a common function, it is the first step to integrate the release of the firmware image loaded by the OP-TEE remoteproc framework. 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;