From nobody Wed Nov 27 16:33:47 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 00FE9189B9D; Wed, 9 Oct 2024 08:03:58 +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=1728461041; cv=none; b=u9sm6qBR2D7R3o2Zg/6hyN9H24qPNd29hcmRh4Ce0/xti3DguREoyR/lJkozcLs2eiQ4z9Wbzk7PH6M+1EB7+Jb0F1IU+q4Anq4LpBSLUEkfY5X5flNq46P+plD0a/v7MfM+X9KCOeQByrzkwP6ufH7mkWWUJsMTC8yluZqcY5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728461041; c=relaxed/simple; bh=RQg6ja9ZTYOb8GyYpD0SKqc9ZlmRkKP+HuimxKmw9o8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CdXHT5GusqZO1dIsmkbSaC0NTr3kVaZ3VVJqkb3BldqqxfkhhgxA47wpNB1W2ChlSz466YjMUe2zIHVszY5U/r9b4g/LGBacoglisY+okSXuHjgK9S4vawzPkRQV5Nn7ATJTiEEKww8W0Z3fsv9IgH56dda9mVY2XgNe42karYk= 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=ts9XTxB2; 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="ts9XTxB2" Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4994SC5N004331; Wed, 9 Oct 2024 10:03:22 +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= y79txdEzzDmqftwd9hTeqbAyi+c6QQoV0XV6rE4nuds=; b=ts9XTxB2g/v3BgVo ysdWtb+x7d1wDbzAIahwnSNqLJPGZdGgHAdelzd+Footb4oOXbHu95XVmRtfRZ23 RJgDcVGm/7240d5a7R75c2uXVvukvRjT9hx7AmZboU4YOU76XL8+qzquSbzXCmDe evCsE/nhfRbC170CWINz+YMTbmHO2do0wfDKhGoCseQDIEAD6j0OqY1pnL0T8qz0 c4ent0f8VgXxUt5DM75psKpLFQGy3cs0HtPeNNP5RHfDrn7e4fe3f2c3HhnKYBE3 rDA3ftd3w/2R8jrpVuljiN3doAhrJi0smPCcfvUz0BxxbheTZdSqHu8b55Y40K9c Jgn66Q== 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 422xv7ahqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Oct 2024 10:03:22 +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 CBA8440052; Wed, 9 Oct 2024 10:02:15 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node5.st.com [10.75.129.134]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 231B4219BB4; Wed, 9 Oct 2024 10:01:26 +0200 (CEST) Received: from SAFDAG1NODE1.st.com (10.75.90.17) by EQNDAG1NODE5.st.com (10.75.129.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 9 Oct 2024 10:01:25 +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; Wed, 9 Oct 2024 10:01:25 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v11 3/7] remoteproc: core: Refactor resource table cleanup into rproc_release_fw Date: Wed, 9 Oct 2024 10:01:04 +0200 Message-ID: <20241009080108.4170320-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009080108.4170320-1-arnaud.pouliquen@foss.st.com> References: <20241009080108.4170320-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 --- Update vs v9 revision: - add justification of the patch in the commit message --- 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