From nobody Sun Nov 24 19:05:19 2024 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (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 69FDA4C62E; Mon, 4 Nov 2024 13:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730727505; cv=none; b=Pprq0i9VYmzpq5qaBYx+fASmdcN2yyvEtUJ6vWR/Te/Y+rKHZwuezMoB6GAi3K4TN5qD5J7iXlIEpqo8NO2UOZmd6672MuxNxWObHdM5rcsXg3/cIeq6uOUgftVTQ9/bVFzUmXhMf/Q3l65f3SkIabpn2lvuQhfDNNS8XYpk1ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730727505; c=relaxed/simple; bh=cJuK47Izb/yOOkLNmgo4HCInjKy++jMUEPG88YvhDbM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O1bMZxowfMi8i78MWPXFvBCMOOkJdWNc4kwWXIzc5rljmZo74auwPLxPUuv9lrJACAGFa95un6fYP0pcVsJt8WeVULqgSvCb8jVc21JbW9qmQVCjvwpwJsuBgMkWNWpTd/FYdTN5jhWisUZrGpTdSFShXmbuhQZakoVwsDwAFM4= 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=ArB+8vi+; arc=none smtp.client-ip=185.132.182.106 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="ArB+8vi+" Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A4DKAPY029431; Mon, 4 Nov 2024 14:37:59 +0100 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=ArB+8vi+oYEc42Ev kBmnpQ1kaXyOvHw3Bfm+ylkrZSJYqAlIWggkuDEuKLbVoyN9fce37EBOvt8o5m0+ vlTO8Erlg4qGdid6vBChNQbioGB4lPlRUKNRlN7KClWEa5JKZVdTAhD46V1XLsBF 2LEde0qOJ4oN7J4Mj9SUwm7Zgz683w0OrF+TX2d+xMIgeIZ26R86nN6SspXVciSj TCL+T3vVSJ3eYPTj00Tzi0FKA1UzvRLbMSg7Sojij8omVgcRitUjYEfcRLe6YvWN vrfwipJg03rMggnD8wOK/on91Detomn1SBzQaxNQn5F/EuYlK2yHFWgNIfRCyE8F sYHiHA== 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 42nd0578u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Nov 2024 14:37:58 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 9F8FE40047; Mon, 4 Nov 2024 14:36:51 +0100 (CET) Received: from Webmail-eu.st.com (eqndag1node4.st.com [10.75.129.133]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 1820F28AEE3; Mon, 4 Nov 2024 14:35:56 +0100 (CET) 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; Mon, 4 Nov 2024 14:35:55 +0100 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; Mon, 4 Nov 2024 14:35:55 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v13 3/7] remoteproc: core: Refactor resource table cleanup into rproc_release_fw Date: Mon, 4 Nov 2024 14:35:11 +0100 Message-ID: <20241104133515.256497-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104133515.256497-1-arnaud.pouliquen@foss.st.com> References: <20241104133515.256497-1-arnaud.pouliquen@foss.st.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SAFCAS1NODE1.st.com (10.75.90.11) 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 Content-Type: text/plain; charset="utf-8" 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/remo= teproc_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 r= proc *rproc) return 0; } =20 +static void rproc_release_fw(struct rproc *rproc) +{ + /* Free the copy of the resource table */ + kfree(rproc->cached_table); + rproc->cached_table =3D NULL; + rproc->table_ptr =3D NULL; +} =20 /** * rproc_resource_cleanup() - clean up and free all acquired resources @@ -1485,9 +1492,7 @@ static int rproc_fw_boot(struct rproc *rproc, const s= truct firmware *fw) =20 clean_up_resources: rproc_resource_cleanup(rproc); - kfree(rproc->cached_table); - rproc->cached_table =3D NULL; - rproc->table_ptr =3D 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) =20 rproc_disable_iommu(rproc); =20 - /* Free the copy of the resource table */ - kfree(rproc->cached_table); - rproc->cached_table =3D NULL; - rproc->table_ptr =3D NULL; + rproc_release_fw(rproc); out: mutex_unlock(&rproc->lock); return ret; @@ -2133,10 +2135,7 @@ int rproc_detach(struct rproc *rproc) =20 rproc_disable_iommu(rproc); =20 - /* Free the copy of the resource table */ - kfree(rproc->cached_table); - rproc->cached_table =3D NULL; - rproc->table_ptr =3D NULL; + rproc_release_fw(rproc); out: mutex_unlock(&rproc->lock); return ret; --=20 2.25.1