From nobody Wed Oct 8 21:10:56 2025 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 8968F29E100; Wed, 25 Jun 2025 09:42:48 +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=1750844570; cv=none; b=qJXK/mGn7L05ZIF2I8Y4fiOXMI5HcMZ/TtS4H2B0tS+gMCMoiY/v/g3/UnbPsJCoeiw5IilV53XTRq/qVLQxvTtQZaNGAU5RFP+7ZkMXg/9aagtu5HB1P7l0hnlLiMT1l/GUHTMz/i8eYJU57Wn9wVTztxjR4ykZ5hdX9quo1aU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750844570; c=relaxed/simple; bh=lZfD+YUUQDhP6yaf0o/cBVBmv+bHdcchlvAjTFO/J9s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FU3n8n2D5KT7hMKM1XClL+Oz3E8SuNbda2wBAQSqum2sIITRSnN88gq7YZ43tXd8+T/AK5opkKPICJhb3e/H2OyZbwyFrZsA2d9/EbGzmPIAmaNAFyiZH0rUGPGBgkRoqEQuiyg1kEgNHrVpwM6JnESMQwCrQkHI4oqqS6sL/rM= 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=MUtoyXLV; 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="MUtoyXLV" Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55P9Km6S003331; Wed, 25 Jun 2025 11:42:39 +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= ojmhJAy4kOZ99ywAmMVFOdSAyDd/xKvGbLo9PtJ+AI0=; b=MUtoyXLVTty64s82 6Z802vYSt/VhKKhT0dyRmpdc7G+/x6ELrqzQoMclRL+iHHJrrFAhBroDqyMGbgW4 jGJrFYMD2CdUgbNFoCvWtEjf2Tct9/pvRDm58GGdrYizYn7TdyqpDyJ9n6PSN9xx 3S2JerluaMB2arnVk29q4TSyYKsgtkhDT+6lxw0hnfd9GwQ8Oc2av11HkzfH8qCn L76sjPKVRM1p5Uq4iIFKwStOpnuhtn89ktUTuIbAColKeNPaT4WDl9zr3lQnOYr4 S+ZAU4XW8laizrar6NbpEqBJqkbA9AtZbTAuXzB7Ns1lYpZymiTiYREph/Xr0nrk N5Mgdw== 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 47dkmjrswd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Jun 2025 11:42:38 +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 CEA814004B; Wed, 25 Jun 2025 11:41:30 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node4.st.com [10.75.129.133]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B07294838C9; Wed, 25 Jun 2025 11:40:43 +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.39; Wed, 25 Jun 2025 11:40:43 +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.39; Wed, 25 Jun 2025 11:40:43 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v19 3/6] remoteproc: Introduce optional release_fw operation Date: Wed, 25 Jun 2025 11:40:25 +0200 Message-ID: <20250625094028.758016-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250625094028.758016-1-arnaud.pouliquen@foss.st.com> References: <20250625094028.758016-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: EQNCAS1NODE4.st.com (10.75.129.82) To SAFDAG1NODE1.st.com (10.75.90.17) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-06-25_02,2025-06-23_07,2025-03-28_01 Content-Type: text/plain; charset="utf-8" The release_fw operation allows releasing remote processor resources configured during rproc_parse_fw() and rproc_load_segments(). For example, it can release carveouts mapped during these operations. This operation is invoked in the following cases: - When an error occurs during remote processor boot. - When an error occurs during remote processor recovery start. - After stopping the remote processor. This operation is required for the remoteproc_tee implementation following a stop or upon encountering an error. Since the remoteproc image is loaded during resource table parsing, multiple failure scenarios may occur prior to remote processor startup, including issues with resource handling and carveout allocation. Signed-off-by: Arnaud Pouliquen --- Updates from version 18: - Rewrite rproc_ops::release_fw documentation - Improve commit message Updates from version 16: - Removed the rproc:load_fw() ops introduced in previous version. - Removed duplicate calls to rproc_release_fw in rproc_fw_boot and rproc_bo= ot. --- drivers/remoteproc/remoteproc_core.c | 6 ++++++ drivers/remoteproc/remoteproc_internal.h | 6 ++++++ include/linux/remoteproc.h | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remo= teproc_core.c index d06eef1fa424..4c1a4bc9e7b7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1857,6 +1857,8 @@ static int rproc_boot_recovery(struct rproc *rproc) =20 /* boot the remote processor up again */ ret =3D rproc_start(rproc, firmware_p); + if (ret) + rproc_release_fw(rproc); =20 release_firmware(firmware_p); =20 @@ -1998,6 +2000,8 @@ int rproc_boot(struct rproc *rproc) } =20 ret =3D rproc_fw_boot(rproc, firmware_p); + if (ret) + rproc_release_fw(rproc); =20 release_firmware(firmware_p); } @@ -2067,6 +2071,8 @@ int rproc_shutdown(struct rproc *rproc) =20 rproc_disable_iommu(rproc); =20 + rproc_release_fw(rproc); + /* Free the copy of the resource table */ kfree(rproc->cached_table); rproc->cached_table =3D NULL; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/= remoteproc_internal.h index 0cd09e67ac14..c7fb908f8652 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -221,4 +221,10 @@ bool rproc_u64_fit_in_size_t(u64 val) return (val <=3D (size_t) -1); } =20 +static inline void rproc_release_fw(struct rproc *rproc) +{ + if (rproc->ops->release_fw) + rproc->ops->release_fw(rproc); +} + #endif /* REMOTEPROC_INTERNAL_H */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 8fd0d7f63c8e..a2bb51a113b1 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -381,6 +381,10 @@ enum rsc_handling_status { * @panic: optional callback to react to system panic, core will delay * panic at least the returned number of milliseconds * @coredump: collect firmware dump after the subsystem is shutdown + * @release_fw: Optional function to release resources allocated during + * parse_fw() or load() operations. This function is called after + * stopping the remote processor or in case of an error during the + * boot or recovery sequence. */ struct rproc_ops { int (*prepare)(struct rproc *rproc); @@ -403,6 +407,7 @@ struct rproc_ops { u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); unsigned long (*panic)(struct rproc *rproc); void (*coredump)(struct rproc *rproc); + void (*release_fw)(struct rproc *rproc); }; =20 /** --=20 2.25.1