From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.70.22 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796222920; b=VzczznaLOuIAAryU+S/FtDfL7zC7bh0wpTCYcy2gRpLuSG5pi2Ala5Q4AodDw+Ovl534 tjbiwa/udSPDY1zoRQJk/gEBcmC0ivxY70VHJVyVJ2QX1U4m0fLWmnBpIpMu6yBr7UWZa yuLShzK+bm8pKFfbfUKZFiLCjB4cDCapPIaDLq1Qy9TOGOm8o//FbABGauKloXcWbqmyK pk1UctRrbU1iKXMykRrr1LkxB70WNw1WJWyBm+u7C3Hc8gDgP3ROFWLHXjOWdrFf9RXB0 vJ1yx+J3K2U/zZHXz07MJXRaKwDT276aOmrYPQUDIm/6KmH/m76vaHaXYYeWRMK8eFQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222920; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:References:In-Reply-To:To:CC: X-Mailer:X-Originating-IP:X-ClientProxiedBy:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=06GiTk9LFUKAKhQ2WkOsbLzgd6iCjcMdNp+q+EFxlOw=; b=HmodHF7538D5NjAmtaE/ZR2Hcdsny5bh1q/FA1IrdGYsVvRHyJGtBW461GoKsBtUa+yk EhD/vQFGH5Rs0RdqN/W4qAOH2AnTFY46uOKMWvNibG+OaE90ICfu/JzUdoF0vJoigjvfv gqx7Qs7oZ2V2tx3zSnQ7WJ0f17vQEjd0i+G8gZ7pBzjBCc8JXks5SqzjuFJvQ59sGIG/I 94IuaWcUXVd1zWXs8vGg3aNAMKREJ+m4CE1xb0hpCCzTdR7H2PM6vu/DfGYLLHJ/dXGfN 4eZOwQDcFqxToOQmdVoN/Pi3djG653hbcOPfjqi3yfyP6G8iDbxpdzn0h7uFGi9Mxzw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=kDt04NbB; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.70.22 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011022.outbound.protection.outlook.com [52.101.70.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC162606A322; Wed, 2 Dec 2026 14:48:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC162606A322 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, unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=kDt04NbB ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D1C+D9z1NFxZmhnyCYcgwF/7C4AnpSUe4G/Q6RPPxOeKIJ/5kwLOfxwCF+janvYVQY5DV0qohUdFrImDs6/84i+GUkbjovuqt/rI7Vqh3eGoEdDSu+izJw+Jq17Iksh3vwhjwHftF8ooU3BNlzGXFGyCaVNJdte2yrx2wwv/FnxahWhCfifuut1u080FPr6VfzO9n2FnSylpcnmad+hcw1Aa/gVHi10cYK1hBzKluG7U3nOyU/m2gq4xgVX03xLbSE8CCj9J5/lnmhUpsK+PlXLAg9a/g23Nwpi6nlu/gofadNjXWJB7jyuvxGvQ+CPpUZOuZMBkfMgDpVYuBCwP+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=06GiTk9LFUKAKhQ2WkOsbLzgd6iCjcMdNp+q+EFxlOw=; b=TpcmXQPgzl0OZZl6zgO/VNkN5fbH/wDhi0gWdvSqpIdGM8p5bjAvi41x9gaj97fsgeuMklImmyNnZ8aHlexHcVBGj593LcKeZtCF4kDzi3ourTtylJMHt2b9/MZ4NGQBTDi2HlR7+cedjBT8ira3kbE9+P5f4JmO5vCnms6v+LIBqxNjY/71e54NNjLhbOYi+VnqOd+7bxlkUnNOR+cCmJqJ/SyKGvByYfSf2haa4BWTjizdat5S2Em1iVfpiT1e6mWJslUX64FFsyeF9OzMXtIDnQtM/M/BnbHefdlPUY+V7r0iQSoQhETxzenY0qRMI7mxrNW4Y/uoI+wqBgDE4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.59) smtp.rcpttodomain=pengutronix.de smtp.mailfrom=foss.st.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=foss.st.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=06GiTk9LFUKAKhQ2WkOsbLzgd6iCjcMdNp+q+EFxlOw=; b=kDt04NbBBY7FDeMH0o+13lqnW2JHqCLPwmeFDX0U1Mn+/qnyE/x0+0hnjaqO00PSjpnZGRp75jVUU0Nj19NxcOVuFumpEql0g+UqlBOcBbVwOlmGSC0QVb5+6p++qd1XvRGkn+fuYqS1udKDijGmpxS+ub+D12M898moHnM7wE8yvp4hkPz6AUYOMzPByvaO6C+YZvTf9026VBjw6Zgn5lS6ddJyVmjZ/Y7HF6xUNAqhm3XiducyBvlsQfQqnDQQhz+Yt4JqIS5B2C5MZhhidgpN70KL4M1P4I/4OmEeFyDlFYMOTI+vTYuRbSVtzjmXnbJGy/7e6hkYLKKhiWWd5A== Received: from ZR0P278CA0079.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:22::12) by AS4PR10MB5824.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:513::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.5; Wed, 2 Dec 2026 14:48:36 +0000 Received: from ZR1PEPF0000E462.eurprd04.prod.outlook.com (2603:10a6:910:22:cafe::1a) by ZR0P278CA0079.outlook.office365.com (2603:10a6:910:22::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Wed, 2 Dec 2026 14:48:36 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=fail (sender IP is 164.130.1.59) smtp.mailfrom=foss.st.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=foss.st.com; Received-SPF: Fail (protection.outlook.com: domain of foss.st.com does not designate 164.130.1.59 as permitted sender) receiver=protection.outlook.com; client-ip=164.130.1.59; helo=smtpO365.st.com; Received: from smtpO365.st.com (164.130.1.59) by ZR1PEPF0000E462.mail.protection.outlook.com (10.167.241.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 14:48:35 +0000 Received: from STKDAG1NODE2.st.com (10.75.128.133) by smtpo365.st.com (10.250.44.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 15:49:42 +0100 Received: from localhost (10.48.87.127) by STKDAG1NODE2.st.com (10.75.128.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 15:48:35 +0100 From: Arnaud Pouliquen Date: Wed, 2 Dec 2026 15:48:19 +0100 Subject: [PATCH v23 3/6] remoteproc: Introduce optional release_fw operation X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261202-rproc_tee_v23-b4-v23-3-bac8e36eb405@foss.st.com> References: <20261202-rproc_tee_v23-b4-v23-0-bac8e36eb405@foss.st.com> In-Reply-To: <20261202-rproc_tee_v23-b4-v23-0-bac8e36eb405@foss.st.com> To: Bjorn Andersson , Mathieu Poirier , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Maxime Coquelin" , Alexandre Torgue , Fabien Dessenne , Arnaud Pouliquen , Philipp Zabel CC: , , , , , "Jens Wiklander" , X-Mailer: b4 0.13.0 X-ClientProxiedBy: STKCAS1NODE1.st.com (10.75.128.134) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZR1PEPF0000E462:EE_|AS4PR10MB5824:EE_ X-MS-Office365-Filtering-Correlation-Id: c4f1c086-7b4c-47c7-9cff-08df5083582b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|1800799024|82310400026|7416014|376014|22082099003|18002099003|921020|10067099003|56012099006|261028144727099003|261021121427099003|261102123227099003|261022105027099003|261021135927099003|261021123027099003|261022075727099003|261022115727099003|261026140227099003|261026121527099003|261009223027099003|5023799004|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: Cu7oHhBoGknAO1IXlAS3k3wmilX2nyJsVIjAkZjrTlgaz1Fn/lmSuM4GLxxokUcmFAWnzFmS8FLDIU7GvQaPzI/Ef1yUqhW19wF7BdLUC2m4nVXA/x8BlPplRxhNfg2IQsZKBeI6PlBE4H3zwNQ7gQbheiwcZAeT/YlvEYWYpbAhBDVYeSi0KcxZPd/Xy1og1FJ/JBZgKSlrrxCtefKxmSPy0xVsdy+DOKN1S6IjRtmM1PYRt8z2yS+RW/FxqtY1jFeqey92DtU+J0E15ZTNnVKaRerQUkPW5ewaupWO1gV8F58kKCzG3xwczNymM+aeoky57tV8+FliRF143+NejvVADqStd4DSkIbtxjLysCWj2vlUuGNMqFF6znHl5R+vBsLS2lcTB/dv96/CYYIWwEdz+pS9Siij9rZmCU2beiXk+RIgR+Nl0O01MMKzpvJ51+4sZGzuKhemILEzz9Prv4LRBFPxyr6SOfDmAeivCXa2fEZhfyNnhX+l9z07vvfRQ1dusSVOTW2tpQkiNl+DDLCokXKhq3F/6ugZ8y+5Q+KmeFxRUTxOgIZqGhZSzl9jAU1FSTv3lGicFHQda4pLijrjqaLEf4usLKKzLzV29Bhq8toqVRi2p61IrUNU5eNk9EDahTTOXb2Yg2Wc/UJVFMYHDA25z2c1BlG2MZX4h+48xbJDMHBZvFds4xIjReKJjF/gE3pNvmI1iCZ/ZRUurxluyWYYqU+HAf8ytFbuNgaBb5leqZqRWiHVnzpjCpms X-Forefront-Antispam-Report: CIP:164.130.1.59;CTRY:IT;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:smtpO365.st.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(1800799024)(82310400026)(7416014)(376014)(22082099003)(18002099003)(921020)(10067099003)(56012099006)(261028144727099003)(261021121427099003)(261102123227099003)(261022105027099003)(261021135927099003)(261021123027099003)(261022075727099003)(261022115727099003)(261026140227099003)(261026121527099003)(261009223027099003)(5023799004)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KYKc5iygudYtxPT0QzaRWQ5OUI5Yj5eJllQn5/wMPtcm7UGzD2yWWNm1DfS7BDGZ5eXdnVyN/4LVZ+pkOI/il/5gu+WNZtp2Rq3sghpjhbJqYYaFQZznBF6pFyV55ut6x2K/R5Ie5OlDt/zv+VL5Akisf4X80XUZQ4iSN7KiPbZYaBUy4XQA+CfJQeG8BHTVI5jT9tfjDSa4qylke72LzHOVTzDgrjUw3GtqDfgOtpVxSFx6J/gqLhTvqC0JhCiWoso8ki005HokJHogRVRBSfmmybLpj96yzSZ+siRBhU8q3GD0fT3WMq6LNNgXipkgx/qAzCAqEqo+nK8R5oXdnQT/3dJPXolUPBqN0K/XdTW1XRFEFlqUf/oHrSax1tVymw42tWtakqulrAteUdT4NvtU9c9efHgOGw6QjXFu5eSIj88bqbmDICowOq6ywonz X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 14:48:35.9752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4f1c086-7b4c-47c7-9cff-08df5083582b X-MS-Exchange-CrossTenant-Id: 75e027c9-20d5-47d5-b82f-77d7cd041e8f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=75e027c9-20d5-47d5-b82f-77d7cd041e8f;Ip=[164.130.1.59];Helo=[smtpO365.st.com] X-MS-Exchange-CrossTenant-AuthSource: ZR1PEPF0000E462.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR10MB5824 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_boot. --- 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/remoteproc_core.c index e31c6b209424..a9b3d0f4a0d6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1849,6 +1849,8 @@ static int rproc_boot_recovery(struct rproc *rproc) /* boot the remote processor up again */ ret = rproc_start(rproc, firmware_p); + if (ret) + rproc_release_fw(rproc); release_firmware(firmware_p); @@ -2000,6 +2002,8 @@ int rproc_boot(struct rproc *rproc) } ret = rproc_fw_boot(rproc, firmware_p); + if (ret) + rproc_release_fw(rproc); release_firmware(firmware_p); } @@ -2052,6 +2056,8 @@ static int __rproc_shutdown(struct rproc *rproc, bool force) rproc_disable_iommu(rproc); + rproc_release_fw(rproc); + /* Free the copy of the resource table */ kfree(rproc->cached_table); rproc->cached_table = NULL; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 3a742ef6ef60..1042c035bc0b 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -275,4 +275,10 @@ bool rproc_u64_fit_in_size_t(u64 val) return val <= SIZE_MAX; } +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 1acfd1bf25dd..c97104f11b17 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -89,6 +89,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); @@ -111,6 +115,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); }; /** -- 2.43.0