From nobody Fri Dec 19 00:38:00 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 CAFC233A716; Wed, 17 Dec 2025 15:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=91.207.212.93 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986013; cv=fail; b=B3az16+kwtX2rwbjPYea8Rvzz7LEIY8XyrXJ8x9ZdZd0QIpaykJqEPVNxlKgkUMEyuyQ0TuODXVq/DoqdTLJjs6/CkKWJwWuM6CodemWlWsWVQOq/W6Ofpasv9f/vp+DDunkPjctegVIPCCJCRME1zFUSGQf8nCDXPjop2ym5v0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986013; c=relaxed/simple; bh=Kk4GEke4IVblXojl7mdy9F8b3uZrnqU+5WcKADizRVM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iq8/JNblqOCkUFdmsveNUiIlBs70JTwNuECAfi6ha58+zQili88nKsn0H/lEgMHs6BZrODkLT0ytDDY8iGZXka/ux4oeZ/rFZlCEf7VSqqI275j9oXwhsc6MAPdgGhm2IxS7pw7sE3OgpuZBaDADpbI2e3uK68OTB0FirZofoIM= ARC-Authentication-Results: i=2; 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=JP5c52y3; arc=fail 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="JP5c52y3" Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BHFUGmo499675; Wed, 17 Dec 2025 16:39:56 +0100 Received: from duzpr83cu001.outbound.protection.outlook.com (mail-northeuropeazon11012038.outbound.protection.outlook.com [52.101.66.38]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4b3de1m1mf-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Dec 2025 16:39:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZXe+eStgSpdtbHcTMlHHQKkCYcWGjbQHVYKkM4ZTnx+2Y+orm939NuTD29wHzXqQL4iXiQS4xFSveOZtXTHPU48yIs3gm5p7QGCMy9KN2ksop7ujGhRCgNaxUib1KQxaMct+P1QdR9NgGzOULV5GQE22FmTp3J2H8z/qtufxpY1kyiD8yZvhNFDCDwOeGkwiGyrUefzE0RkDoB9Mbx0ipGVgQAYLfScVY1vrHpNzjbaik4edeSxhq6bz+vRJQOp2MzYTC67+tLZy40OJkrxLe1ojIs6LC8Zik4bg5JYZJg+bOWC20xZ+0ddiyzcIPlEfyzKbx5YDGPt/jFAJZS4RJA== 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=rvU0TwiJItTMqYadl8AqJJTIeGCTej1jA0kpxBiUUCI=; b=vrt/EFT7qDsAyfZefyzaiXxpnmf7S7GVQdxKAd4sfSxAZflsuZAtKzZmlthyDaI7Lom9Bv3f3oXJSClSrSe2U6OzBv9qrgBB/2SX8kPD5Qa4noLuQPbzJTuLslofDtbiU4wzAl0UrW0at3uLWvjAHV3DsPg96fDJFB4y6aMmkvZfAuLpyJNUeOhqA221ppfH3eLJqpuX2zGg1FEpeehLj5XA6GiKp1AGdaoy/xaiE2uK2WPRmqza0B9SbMn/eXUf+jwlBkMJOFqtUS0vdfxY31ozcqRDoZ3iQ9MJSlhy58lrEE3XXFkWzKtELzXT+By5/U/NvXQV8LxnJrOaAohl2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.60) smtp.rcpttodomain=kernel.org 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=rvU0TwiJItTMqYadl8AqJJTIeGCTej1jA0kpxBiUUCI=; b=JP5c52y3zq51jHZHLWLMv9C6YL+O10+X7dtU2ClGVB7oLTDkYYU4qAf3jJZEJ34zhofFIatRTl7vfXUlY1iiGyYO+T2QIGZDmIBBk5gmLmrsQVYMIM8ntLOJSXlVpZxG7Xwu/Y/M7vdpYec0TTkKejZQkjqUNUGCBf0nVomak9I69qfRWBYEXKrToEUsHi8JFZUReyj5IQbeQ9BeQVCHQvuE5D1+YAa2z/RqpJOWbgl687FUQiY/zZFhCCrLpdUdIMBuQSX4unaeZjgYduKPutbATr+QseDZ7OIpjQF55jzjmsNYoTSVrkvRLLhTrk3l4sTZSgUIZO9gmszWeMUioQ== Received: from AS9PR06CA0461.eurprd06.prod.outlook.com (2603:10a6:20b:49a::12) by AS8PR10MB7231.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:619::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.13; Wed, 17 Dec 2025 15:39:54 +0000 Received: from AM2PEPF0001C70D.eurprd05.prod.outlook.com (2603:10a6:20b:49a:cafe::a) by AS9PR06CA0461.outlook.office365.com (2603:10a6:20b:49a::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9434.7 via Frontend Transport; Wed, 17 Dec 2025 15:39:45 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 164.130.1.60) 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.60 as permitted sender) receiver=protection.outlook.com; client-ip=164.130.1.60; helo=smtpO365.st.com; Received: from smtpO365.st.com (164.130.1.60) by AM2PEPF0001C70D.mail.protection.outlook.com (10.167.16.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:53 +0000 Received: from STKDAG1NODE2.st.com (10.75.128.133) by smtpO365.st.com (10.250.44.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 17 Dec 2025 16:40:37 +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.17; Wed, 17 Dec 2025 16:39:52 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Sumit Garg CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v20 1/6] dt-bindings: firmware: Add TEE remoteproc service binding Date: Wed, 17 Dec 2025 16:39:12 +0100 Message-ID: <20251217153917.3998544-2-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217153917.3998544-1-arnaud.pouliquen@foss.st.com> References: <20251217153917.3998544-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: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C70D:EE_|AS8PR10MB7231:EE_ X-MS-Office365-Filtering-Correlation-Id: bb3c8c8a-2055-4b37-20f1-08de3d828609 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?T5/G8WbgQekMePmqYcASZCBl343XH+nb89ba5MXYHlLpFQde/ba63HXZIxPE?= =?us-ascii?Q?49M64NK4xNBtxioAgmrhADKwFMt1OZXbohvku0zGph5wKU74pF8SLBZHXV38?= =?us-ascii?Q?ZIOuLVWFjvmF6FLZCEBpK7RuLgLiw+hTmHSmVsX3bJZeFL9keA7a/rtUl2DB?= =?us-ascii?Q?eRhgiehayHbCKAnNTuhmHIsx0/95d2dV5CdYnWPFGyM7Tp87FyXqfj6NG93E?= =?us-ascii?Q?hl6gBhob5ilgj2Li4JmJZrwx/pRhcsEceh8hlMYnKdqbCmLBiLtfi67Yv/SV?= =?us-ascii?Q?KUrbkIxtkwv2hv8u9O/poxG9Q1nNDo5wWo5RCxFo471dB15HCjMlZ8xyYirR?= =?us-ascii?Q?yGOlfyUlr1RL2WTChlswIQsvSCQZZf8oJXMn4YaKmr/e00HhitPTWZWqLRRk?= =?us-ascii?Q?8uEnzsz+3tvE+zlltJIxkNSqlSOp4T/MRUXy7tPr4Euw9vU3CleGISgBm4Fw?= =?us-ascii?Q?QCuW0PCjfurfehP5ntWvdAX5GhFbmOTviROow1/fSKPYqh7wqyN4jfZq/oSQ?= =?us-ascii?Q?fpfERySJQ2/H+4W1byPq3G3qD8Q9nQ9BaotMgwzAxE8+T+EyDXr6kYsy6/eH?= =?us-ascii?Q?+4NBtvxnmwT6LK/GM1qKI2kMo+S92AzzisddP7QecS5HiRv/OUBXGeVc3LBP?= =?us-ascii?Q?fGjmRJcbMLoySzEP1+QYWdzMzy0t5iiRQ4+qVyn8Q6oLcIET41VpviiNvTEY?= =?us-ascii?Q?ioQR+9vX/Y0SAHIYCRbl58GnZon49kDJQLETre5EbW7rnqx/HoYk0uglUUd2?= =?us-ascii?Q?1cEVWl+I7Nby1MF9y6AHku3bdp+SKSvevuesNwuy6WS8wKcIOyMYyUd4xYXz?= =?us-ascii?Q?Ttt3nJya4H67egNBL/+NcqdKfAZmaqLcFDHF+11NbimriQmGKM9ZYedk1Yq8?= =?us-ascii?Q?FxwQCT0yUrAKSbo+BBxTafjAnw41LwLaELcT0vdIIkaZ+q+uglFbxFnMmnVI?= =?us-ascii?Q?TNklr3TtG+E6/G9GSsk3JlQo36qOv75mE254WVgeaRUU3DGwwDYPya0MLgg0?= =?us-ascii?Q?yB7MQu/jRixPCllT+qbZtdAJ++BWIiEjVRFzn2VuoxSl8JEZwH78P0Q41QPZ?= =?us-ascii?Q?nJZlIX3RhqIsZVSg1dquIcMoUM5XIX0bhLcwC9MuPiaTZbu5XfrY+zGILt/x?= =?us-ascii?Q?MicQtSMMV4VWtwFMlOrFVhJ8e3SWYK8DNwYOM3n0QEXjEZ4KFX1ucUeBkU6r?= =?us-ascii?Q?yR4jmMHNOvpSqPq0AfS2SBZE2oZg4Xj2YK3jQeR2M8/KDG7wDqJMh7ofIhzW?= =?us-ascii?Q?gQe15qegynNmrlGJ9dcaajmCP9CscEKptn9W9apLwOLvHxbaz8knvJ7kXOqa?= =?us-ascii?Q?3dr0VnDjifadFXxfleBU4M9E29lfGsWZxTb2UQAeHkwAt0gYE5bTbGwwIvR8?= =?us-ascii?Q?wt51z5DPDJkyBKjgWuTrcBOHUeNKOuRkksL2rhpLCFdt2EljRGDgIA86vLD3?= =?us-ascii?Q?m26C0XPnWO5qojrcpR9oAknyzUiVWMmw7plqGt9XgtDokrqjz4oJrF8xF/n2?= =?us-ascii?Q?cVb7YANAb1+yozg=3D?= X-Forefront-Antispam-Report: CIP:164.130.1.60;CTRY:IT;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:smtpO365.st.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2025 15:39:53.6146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb3c8c8a-2055-4b37-20f1-08de3d828609 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.60];Helo=[smtpO365.st.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C70D.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB7231 X-Authority-Analysis: v=2.4 cv=JeOxbEKV c=1 sm=1 tr=0 ts=6942cecc cx=c_pps a=Ye+NqXUjxnSxkpZHLj4hLw==:117 a=uCuRqK4WZKO1kjFMGfU4lQ==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FOPVHIcnkjUA:10 a=wP3pNCr1ah4A:10 a=s63m1ICgrNkA:10 a=KrXZwBdWH7kA:10 a=VkNPw1HP01LnGYTKEx00:22 a=gEfo2CItAAAA:8 a=8b9GpE9nAAAA:8 a=MdngEct1hBrlLFZYPjYA:9 a=sptkURWiP4Gy88Gu7hUp:22 a=T3LWEMljR5ZiDmsYVIUa:22 X-Proofpoint-GUID: 1wJA3yjZtpCkFf2bmh_YLNTEovVwyZPK X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE3MDEyMyBTYWx0ZWRfX8UEa8sAi0bvH ci2MaOLoLt5y2a+8/n7QM3kwPfwTEq3sys7VTv1gg0d5+qtEfqKlHUB6gzCZ0VyhFD+dOO6f2qm NJVSaAdPJXWSt1sREq2pblBTGg7Qu2MMZGHhfjmu0w4L7vNTG3cXJoqZbPiZ5+dDN44BQGa9bC6 dxYIixG0jJCwrY7YJRbGB9qzDPNVNF/ZhClHhMfBK6QIctf+IqO2Ej2IW6z3lp1h33wHMaKG0/N JBBdhTDt4A8h+7iontCHNn8OCJbaQzFN1HvWruUoIMeUA8x2yBpQxSokpM6mqMp+ozqImba/pb2 eNt6APlioWXNyxEeYACXFGnXASONi7plsVWYfVuFv/TCk+jgrYMuf0ciXUmQdauRKpvFNA3pZOe g5YhAfpcgVwT4qLrZYtNjOsMt/E4zw== X-Proofpoint-ORIG-GUID: 1wJA3yjZtpCkFf2bmh_YLNTEovVwyZPK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-17_03,2025-12-16_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 adultscore=0 lowpriorityscore=0 clxscore=1011 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512170123 Content-Type: text/plain; charset="utf-8" Add a device tree binding for the TEE-based remote processor control service implemented as an OP-TEE Trusted Application identified by UUID 80a4c275-0a47-4905-8285-1486a9771a08. The TEE service node is a child of the "linaro,optee-tz" firmware node and acts as a container for remoteproc devices that are controlled via TEE. In addition, the "linaro,optee-tz" binding is updated to specify the '#address-cells' and '#size-cells' values used for child TEE service nodes. Signed-off-by: Arnaud Pouliquen --- .../arm/firmware/linaro,optee-tz.yaml | 6 +++ .../bindings/remoteproc/remoteproc-tee.yaml | 47 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/remoteproc= -tee.yaml diff --git a/Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz= .yaml b/Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.yaml index 5d033570b57b..ab69eecba9ad 100644 --- a/Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.yaml +++ b/Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.yaml @@ -41,6 +41,12 @@ properties: HVC #0, register assignments register assignments are specified in drivers/tee/optee/optee_smc.h =20 + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + required: - compatible - method diff --git a/Documentation/devicetree/bindings/remoteproc/remoteproc-tee.ya= ml b/Documentation/devicetree/bindings/remoteproc/remoteproc-tee.yaml new file mode 100644 index 000000000000..083ecf1f38cf --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/remoteproc-tee.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/remoteproc/remoteproc-tee.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TEE Remote Processor Control Service (UUID 80a4c275-0a47-4905-8285-= 1486a9771a08) + +maintainers: + - Arnaud Pouliquen + +description: | + Node describing a TEE-based remote processor control service implemented= as + a Trusted Application identified by UUID 80a4c275-0a47-4905-8285-1486a97= 71a08. + + It is a child of the OP-TEE firmware node ("linaro,optee-tz") and acts a= s a + container for child remoteproc devices (for example, the STM32MP15 M4 co= re + described by "st,stm32mp1-tee"). + +properties: + compatible: + const: rproc-service-80a4c275-0a47-4905-8285-1486a9771a08 + + reg: + description: | + Logical identifier of the TEE remoteproc service instance. + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^[a-zA-Z0-9,._-]+@[0-9a-fA-F]+$": + type: object + + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + +additionalProperties: false +... --=20 2.43.0 From nobody Fri Dec 19 00:38:00 2025 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 C1B9F17C77; Wed, 17 Dec 2025 15:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.182.106 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986013; cv=fail; b=Fr5i3lzkwvSC966pQrZ0hHaZpH03fGJyJjiS5Ox+9jvtG2X5+wGobEYTmWCuSuffYMwxDPMTEiXIBbwxa7EqXwepuvRBaU3SYyWgCR2zGnbtuoTSFGaWTwFDg5aazVsRQB+k2DoJIIAXX/9ycdwyzawrHaaHxz9HWFlkTuaG1ho= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986013; c=relaxed/simple; bh=p6jptTaSs7JBJgzDPJtk4MmJnAdK+bAJp2WTXTZ6Znc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mBOA4448LfBQLf5U7pw0lV2A9tQox2hHUDS9CW4u1NEW8Yv+R7R8NVGxp2dbjudfTVvDEjz8tiZ1SDkVRIhu5l/G+bCafu0Rw33ihRJMdTr5Uj9ynw2QANABe5SJMXuZZzPALp6BhyUiXRtNm4aLvJopP3uEbIG+ahG2Qr/4d8A= ARC-Authentication-Results: i=2; 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=Rt79TrLP; arc=fail 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="Rt79TrLP" Received: from pps.filterd (m0369458.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BHFaOhF3369922; Wed, 17 Dec 2025 16:39:58 +0100 Received: from mrwpr03cu001.outbound.protection.outlook.com (mail-francesouthazon11011063.outbound.protection.outlook.com [40.107.130.63]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4b3a3wmn86-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Dec 2025 16:39:58 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xsj0UjUsY2mkZPoOk6iuA+EjkdRAD2OkNP+cZdKCMl6LgVGrbsalm4s+FoxIFZidAmkmZ914yX29Kky7xAObQ2+sQXvQ277AV0wdYxIL39Izr+w57vmDrcCXZBqNPLgGIEkstC2c/Z++jB/ZNi23uWbTdGZfLkbngJ5/ljsyA4foo4E3lwtILqgPErcRhmiqLT5S7y7ia/nzmd3D03aFVH1z8z3IAm/o+bnfUautQkXdxZCLisSoaUd3hkgIWYR9v1MTx6FXyCpQUNlEuCdAn0POT9RP41SvMoAthmZwOofbsZ+7h8NjvsWx0wELeBLBXEGUgF+rjdIgqKXl0JzVPg== 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=KOl/LxvZc49Z7Tz8i0JalXOr+dGCvyAzl7LCpi4fZws=; b=GdoXXDXLTi1WdDx+ZOrxHckULHP9rUaObG14m7cYoijt2p0olqcXy+dcSPWzWRvjniIobEQJYMY846XjPRkG+zoidhWrwM93+NJNc6Q2TACYdDIjYmIrmYjpY6d2EJmkNqmh1OT8o25KfDWAUYq9ExveW55XgS7swDMilT293aSNKEkwpQ85Xn0R/I8AiTMy83gie7OR5WYOhqzMXKIjPCQaw6W8y9E/JexLV3fY8JNmHQ/WDFwkILLRATmbd7WXb7D51e4G51j7LhotbabKQH8dmqbl+xHqcyPPRSL8V86Gf0XZrA8htB49Tm6Uy3pcjxIoxi+6CHky99HLjOC5pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.59) smtp.rcpttodomain=kernel.org 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=KOl/LxvZc49Z7Tz8i0JalXOr+dGCvyAzl7LCpi4fZws=; b=Rt79TrLPZcCbARO1uHq7LiZeQvP3bpqgvmRcVoIeMoTzSPT1iTWY/PRhh2N3IP6TzwRTxIiFaATlUFpSn4YavNPzNGcpkGeb2ntbhGuTfpT1QYgVPrFO2KdRb45FFOXkMUHJQZkjQnghgRMVaN4w1cyzpV0lbsxsdPW15MEjeiqYJH/ffff8/NlkFdENMLHydcqTu2dYTEe6k8/r4nUFFt0Se/As+gnkERSLnrPIe8/4UkBbwd1lzURtu0fVlPilg9UJ7avZdpWj2WK6r4TMR8WpBalLEIxfX3GuUIxzRwJJq9lXxD4pS63BV2usAZxwSF/fnQVB01xt7j7AnO54dg== Received: from AS4P195CA0053.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::9) by DU0PR10MB6605.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:406::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.13; Wed, 17 Dec 2025 15:39:54 +0000 Received: from AMS0EPF00000197.eurprd05.prod.outlook.com (2603:10a6:20b:65a:cafe::92) by AS4P195CA0053.outlook.office365.com (2603:10a6:20b:65a::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:52 +0000 X-MS-Exchange-Authentication-Results: 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 AMS0EPF00000197.mail.protection.outlook.com (10.167.16.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:53 +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.17; Wed, 17 Dec 2025 16:40:41 +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.17; Wed, 17 Dec 2025 16:39:53 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Sumit Garg CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v20 2/6] dt-bindings: remoteproc: Add STM32 TEE-controlled rproc binding Date: Wed, 17 Dec 2025 16:39:13 +0100 Message-ID: <20251217153917.3998544-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217153917.3998544-1-arnaud.pouliquen@foss.st.com> References: <20251217153917.3998544-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: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000197:EE_|DU0PR10MB6605:EE_ X-MS-Office365-Filtering-Correlation-Id: cf3f32ad-19d9-4f47-9a0b-08de3d828620 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gmsqPHoYvB+7UOnacl4bs0DwlmN09pYjnmT63BNtTF/PoYWyNG0kEUzGiC6y?= =?us-ascii?Q?RtVYNd/N3BJxdVKegOJ6iKcy9RJC9rOM/cI4zy6G7xeJuw3VF30m6WvIXxWa?= =?us-ascii?Q?dOmTlIIzoMH4H3BY0tz7/YC5jgKRIdbKmvw9yBaj4+ltkaKTp3oOXmMCnCcI?= =?us-ascii?Q?BzLARjS5jcSR6V4+6kKzdr3ATE0wgps7qMY1XHHypH4ZJ9TNUSe9a77IxH/K?= =?us-ascii?Q?8a6+A7pDtteGfq7H7P6hBWLQ4iF9BfKtFy2c1JOPnKkFuhsq7eDv9aBZEo7h?= =?us-ascii?Q?6y+1Mwgu4+9Z8tE87c/i6PtbYu458FE0NpZABfLPvYI2SYCviY60tnCFOobu?= =?us-ascii?Q?drcaA0PNiROixZBstOY9srNIZTyOnOcIPhQRculTtr03LGVe2yxapXxkTuMv?= =?us-ascii?Q?WDXWWsRED5edXRpck4DXJZi6XIHKujDJoWhaRG1hxxbfgbxLVp1MQGdopwwv?= =?us-ascii?Q?zqTqKf971tTswXhiVtROnVIX2V0GVXEBS5htmSPOqKT3MsamJR08yxHAqmQ3?= =?us-ascii?Q?d2rDpNSP5Hm6FbJGYt25pD+Fi+ZAHUHcf1acf8Vsa2bgalmFgQHGyME7qjbm?= =?us-ascii?Q?0+RtsUg1NvSby9Y0KC6MYMKgNBBXQY5YKJ2K2RVJCqY2JEotxjdfBG+phDyK?= =?us-ascii?Q?Krb5qk/ioQ+J1yDBgEBotgC3U0l1iOjcuRZYSa2lUNYSB8K+pcR6FpU/XPbU?= =?us-ascii?Q?FKLpnOZZUkUuyt89QCn1fXRrEn/+Ybu+C6eQf3Aao4Si4k60FSbnZwdSvH7r?= =?us-ascii?Q?2KXTJ1s2M2sW6O0OvqWd0Cf0vGCVs3n+jxV5jlGxePKbhT2ucmS0hFeiMzTP?= =?us-ascii?Q?fPG/XbQVJ9IDMuVP9lzqYAJWuuhjJiPV609PD7KX88IvTS5FSDKE1KyFEM+7?= =?us-ascii?Q?iYrxitEd4AGcrtTNJq6EcVBJIwl5akuIGwp3Rc5RIdwKfeMCP4v9ULx1Yz2J?= =?us-ascii?Q?rc/8hD2+maNQ7iXuakv/ZkLvJ98KMOBfnirxr4T33izVElqoWDxerFfIumWP?= =?us-ascii?Q?tq0sltu6g8vY6tFKxToFfDNbQ08gb6HijbBNL3/X7FsXkbAer16a7KNts1B/?= =?us-ascii?Q?hmYCtQaUHYaY/hVnDAXYY/VxN/VuTyivLwr9tgomUTxSXjSJCeJgPTFKDdhI?= =?us-ascii?Q?lg2GB8JVHexnq69ZuWS9DzvsvOVlMoC/TUzfTwUAbN1ZP7lZ8lNGC2ylsfWn?= =?us-ascii?Q?GCld8v+gDYji52yrHOiqixYogNIY1MR8nFcoD6peedTYI0/vLYIB+znm2CHf?= =?us-ascii?Q?39nAPlShWHRzoWkPLpLx6llqqaeYTFAnOKLHZcJYxwq1EI4pneO3zRAmqF+u?= =?us-ascii?Q?BtZUKUI1lc03BEqM2CF1mvWgL4G/CGcHizAxHhVpRB1WdWisFlf+CDyRwTb7?= =?us-ascii?Q?kZaT6QObg65veVL8yC4X9NWs0kKpIWLnsOVlqEM5k/xgH4evlizxnHsov8rf?= =?us-ascii?Q?SIcsUbI3LWoCfvF4eH0Q6YmH7jcSilSgbJFJ8XzGZSUzI/0CNfK9yTZEAyL6?= =?us-ascii?Q?z1qZlr0np2q0ytJEX7ZENu5T83wzHqIvSIie?= 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)(36860700013)(7416014)(376014)(1800799024)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2025 15:39:53.7691 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf3f32ad-19d9-4f47-9a0b-08de3d828620 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: AMS0EPF00000197.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6605 X-Authority-Analysis: v=2.4 cv=HLHO14tv c=1 sm=1 tr=0 ts=6942cece cx=c_pps a=ymtDJClzu6q9zAPI/ygaog==:117 a=d6reE3nDawwanmLcZTMRXA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FOPVHIcnkjUA:10 a=wP3pNCr1ah4A:10 a=s63m1ICgrNkA:10 a=KrXZwBdWH7kA:10 a=VkNPw1HP01LnGYTKEx00:22 a=gEfo2CItAAAA:8 a=8b9GpE9nAAAA:8 a=Gk9aBJqvnsFLiQrOkBgA:9 a=sptkURWiP4Gy88Gu7hUp:22 a=T3LWEMljR5ZiDmsYVIUa:22 X-Proofpoint-ORIG-GUID: OvjVSdEVs_YFL8u5gyS0Cy0eaXj_U1Y5 X-Proofpoint-GUID: OvjVSdEVs_YFL8u5gyS0Cy0eaXj_U1Y5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE3MDEyMyBTYWx0ZWRfX5+LTN5UgMBkl iTUS16yDpCN6SQdQr0AZfI4M7kNyRjTBfDKeLaETVAulAWj+3RfLRTJas/7bRzndtoPVcnzbPsW 6pj63QQiBleBSuyrKbhegMlf0KRmbHNXtmKQSLvNYu2Y4jHE0ZCBM/XluEzJ3OIIncVMk8agsec spKeSiL/SxZaPd1281mskS/XQ5zEGHubm4VifarND8UAi3RZYM448DOragXOR1P+bK8VfZ6eaEO 3LdnN2q4a0yaT0J3bB8D6mLxnwKCtgC38kHY/KCyGcjONlIbLQkGPaU2Fpq7O/tx4+83axjCR// iYNKP+xYfrNl+ZUf31kTdrCWgd93rKRFI3B1Ud6IuJrHt3HbOmy6RJXS/WMOHOdZpWkpxRISu3L +sqfClPoxCh1sfw8NiNXVu3Vf0N0gQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-17_03,2025-12-16_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 phishscore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512170123 Content-Type: text/plain; charset="utf-8" Add a device tree binding for the STM32 remote processor controlled via a TEE Trusted Application. Provide an example of the STM32MP15 Cortex-M4 core exposed as a child of the TEE remoteproc service (rproc-service-80a4c275-0a47-4905-8285-1486a9771a08) and managed by the remoteproc through a TEE client driver. Signed-off-by: Arnaud Pouliquen --- .../remoteproc/st,stm32-rproc-tee.yaml | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/st,stm32-r= proc-tee.yaml diff --git a/Documentation/devicetree/bindings/remoteproc/st,stm32-rproc-te= e.yaml b/Documentation/devicetree/bindings/remoteproc/st,stm32-rproc-tee.ya= ml new file mode 100644 index 000000000000..e9cf8e781543 --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/st,stm32-rproc-tee.yaml @@ -0,0 +1,100 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/remoteproc/st,stm32-rproc-tee.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics STM32 remote processor controlled via TEE + +maintainers: + - Arnaud Pouliquen + +description: | + STM32MP remote processor controlled by a Trusted Application + running in OP-TEE. This node is a child of the TEE remoteproc service + (UUID 80a4c275-0a47-4905-8285-1486a9771a08) and exposes a remoteproc + instance managed by the Linux remoteproc core via the TEE rproc service. + + Firmware loading, authentication and remote processor start/stop are man= aged + by the TEE application. The STM32-specific driver handles platform resou= rces + such as the mailboxes and reserved-memory. + +properties: + compatible: + const: st,stm32mp15-m4-tee + + reg: + description: | + Remote processor identifier used by the TEE service. The <0> value + in the example denotes a single instance with ID 0. + maxItems: 1 + + mboxes: + description: | + Mailbox channels used for rpmsg/virtio functionality and processor + shutdown. + maxItems: 3 + + mbox-names: + items: + - const: vq0 + - const: vq1 + - const: shutdown + + memory-region: + description: | + List of phandles to reserved-memory nodes describing the memory layo= ut + for the interprocessors communication. + + interrupts: + description: | + Optional watchdog / status interrupt line used to detect crashes + and optionally wake up the system. + maxItems: 1 + + st,auto-boot: + type: boolean + description: | + If present, the remote processor will be automatically started by + the remoteproc core at boot. + + wakeup-source: + type: boolean + description: | + Indicates that the watchdog interrupt can be used as a wakeup source. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + rproc_service: rproc-service@0 { + compatible =3D "rproc-service-80a4c275-0a47-4905-8285-1486a9771a08"; + reg =3D <0 0>; + #address-cells =3D <1>; + #size-cells =3D <0>; + status =3D "okay"; + + m4: m4@0 { + compatible =3D "st,stm32mp15-m4-tee"; + reg =3D <0>; + + mboxes =3D <&ipcc 0>, <&ipcc 1>, <&ipcc 2>; + mbox-names =3D "vq0", "vq1", "shutdown"; + + memory-region =3D <&vdev0vring0>, <&m_ipc_shm>, <&mcuram2>, + <&vdev0vring1>, <&vdev0buffer>, <&retram>; + + interrupt-parent =3D <&exti>; + interrupts =3D <68 1>; + + st,auto-boot; + wakeup-source; + + status =3D "okay"; + }; + }; +... --=20 2.43.0 From nobody Fri Dec 19 00:38:00 2025 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 12A7333B6F4; Wed, 17 Dec 2025 15:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.182.106 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986014; cv=fail; b=Lx3tWDLndE8ZjG8GcpjE6OYKWLFV2nl4r0tejY37HDLFaQ49hrBYDM9+rC6/RFCSsfEuN/dusjFIV/bnguUyhfP7jOr3Xkzu/xHFnMvQmT4vZWBL7G/G8LinpNSpwxSDy946eWZiSf9jN8hXpKIpskFw3x6hEnoCaT+O42F5xzc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986014; c=relaxed/simple; bh=J9hfwHiZgZC1CSFh12EldpmuDF/6ZrdDPOvmH0oRFns=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AUxpV89pJreXF2NpQQrNdDVahQYFuiQhj89EBLa6CB/T/+cEuSY6cfY4lbMAvJd+VHsm9gtlpYy16qO3jAX2OhWrP+6ujHzgTyx31wUjzBBrkElytvb5h6YkwGWiCcRtk2XOoocznHwv3Zt/xNc8vxjadz68l9f7kmLG0ZXOjkY= ARC-Authentication-Results: i=2; 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=Iel72G6s; arc=fail 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="Iel72G6s" Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BHFWBYX617538; Wed, 17 Dec 2025 16:40:00 +0100 Received: from duzpr83cu001.outbound.protection.outlook.com (mail-northeuropeazon11012024.outbound.protection.outlook.com [52.101.66.24]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4b3bbecdfx-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Dec 2025 16:40:00 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uVpsd1HH0WUZoBbJ6X7//KBO0R5tVRTwcd4MqCDLQ+P7twBp/8vF1h+8FjbH/2mjK6t9Mjb5Y1Zv+ADoslFNQOPNWtR+9qqWSnoJhoqKzeYl9L6/0SMzXNCCDr5Uo5YvafU1Dx44cYYVfCieMnINNnEsD1ymOCY2OesDBttXses/YlVb0IWWiuCXQMe4AF/U7donHbqwi+sQLJ02j2+qtPiu8BKX2vU7NU3kaWjSFJ1x7lEg/kbp9Sot64S+DK8z1Tu8C8zpYn3AtU+1ZgF9TP2NJ+9cE2ljOQb4muHIk05+zLu4MYNh/tkdDUw/ShWb7o3vkclZR6BEAUMlkYQ8iQ== 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=Xra17NmZ0bE1TL7GUNzTpKv680VBaVNZOky9y00OaFc=; b=MDfJZp8TACKcmeQxhZV3Ua5KLaa3lgBewpnI9Oerj8TZ0D2noQNpT4cG46x5C+VuD1hlelaEcfGoosYNBRXqBPdIA+JNWehsdcQRNmpaIyUZWYiDJesuqsOeBlL04lXDM3rupCY/i/sRvjPLlwRdZ6cnAAttH5CHaW8REfcKz8Cm8+k3VRjHKOYCn5+rJlZnuGYG+Juh7qVdQ7P8pKFILdccmftfIT3idjsN5rBHz8vTXTrTWzlwU9Ft0PxJpZgdz65sOMKcNahR1Rk+ei/9A97lMb3pJCai9xW/LWQcX9ucdBFwNHltvrRboDxJyRL4hqdmEkds57ED9BEtqIzJrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.59) smtp.rcpttodomain=kernel.org 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=Xra17NmZ0bE1TL7GUNzTpKv680VBaVNZOky9y00OaFc=; b=Iel72G6s3MOusdAbwnO2BcCqoP3C1peAiFkMSOBjUYw81g9vy+bhAzEj+qs/SRvbB7hWB9wt6BuaKITyR17mu/IEqEU1q8MMMa3tvJ/iGdCe4FGscNQJ22k7sZIkFN2Ljf49AFP8BvaW/A1Q5NCYQxHIUtWAKL5Ywx84+9ztxWHBaPFT4C2adOvGqTOS/QcfC4T1ht0VVoW/qmx8uiWV2X3FYjbzqHTfIxo1kNnbgV4w8EUxIeUonfHeyOh1hQvywATj8NRN4CYt1+XV7uKcQWzztVgJGHMHgNci8/GYnSqZe4nUgymSnEldU2dugqSjZPDUeAu+xX55fl0aWlHUnw== Received: from AS4P195CA0051.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::17) by GV2PR10MB6381.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:bf::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6; Wed, 17 Dec 2025 15:39:55 +0000 Received: from AMS0EPF00000197.eurprd05.prod.outlook.com (2603:10a6:20b:65a:cafe::a) by AS4P195CA0051.outlook.office365.com (2603:10a6:20b:65a::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9434.7 via Frontend Transport; Wed, 17 Dec 2025 15:39:53 +0000 X-MS-Exchange-Authentication-Results: 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 AMS0EPF00000197.mail.protection.outlook.com (10.167.16.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:54 +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.17; Wed, 17 Dec 2025 16:40: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.17; Wed, 17 Dec 2025 16:39:53 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Sumit Garg CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v20 3/6] remoteproc: core: Introduce rproc_pa_to_va helper Date: Wed, 17 Dec 2025 16:39:14 +0100 Message-ID: <20251217153917.3998544-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217153917.3998544-1-arnaud.pouliquen@foss.st.com> References: <20251217153917.3998544-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: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000197:EE_|GV2PR10MB6381:EE_ X-MS-Office365-Filtering-Correlation-Id: 29d7d29c-6aab-46b8-89bd-08de3d8286ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZLnehrmQXsM0C1MTaB1xIzVCIQ0HOaYIT+ON3EYbpTR68g0SQtNB+LAUxHvc?= =?us-ascii?Q?/oWsHhZYwm/DaVHPszrqkMMgYP1dHYg0XcFW9cAWyWh5fY0yvU8K6IjQe4Rj?= =?us-ascii?Q?pBKIv7vS6JXWssbHkILq1r5dfHDGfCU9PTMDXyDxG9u+Dk3Guzl5f40ge8Bk?= =?us-ascii?Q?RKQJ9j4YELG8G9DzGJpAIdhcDNR5ieAsHVe/ZYWL5lNCOYZkQ+fetdWzEE7X?= =?us-ascii?Q?lrdhsRnMxKLFhLhknxj05wddgJ+MxvIiPNByq4FiW7ZtHCVTaUskheu7gs3l?= =?us-ascii?Q?xkU2jrG9naotbYa7ugGKkpfT6V3kMyfQAF5KTwlxv2k8oTXV5LAYzdF98Mwf?= =?us-ascii?Q?Bk70iO4R1A1F4/7KzTG1pRs/AZZeRSWtBU2QwVSpgj1iKovt+AYVWD2Py6Wa?= =?us-ascii?Q?ZJbNPabc4cBEvy64z5vRzg0Qi21gYVYE6la+yeeMy6wUaR4cqawmQPK8RR2o?= =?us-ascii?Q?Y94A038FJ4uTGyFHUstgLKAjvbQIqfgbQAkAxoGP2WBBnMWSfTlvmCuA4zFK?= =?us-ascii?Q?TeJ0o19H3rKWrsvgGazTUR0Mbc8oNwOmHL8PwiOTWQTOma1CpTjaWMh9Jrc8?= =?us-ascii?Q?03VKI7VtoOGIYMbT90M6cZ9jIehoNqhcaFyKsoXHObKdbadwvhP2Eynd7KUS?= =?us-ascii?Q?P2b/P0Kp/Xw8+/C7b2q59t++9ZPFC79zsW+IIIp6XxePL10Q3IT4MzQXiEFa?= =?us-ascii?Q?JpwLRDAVkB2NpOBzWgGgePlz0JpSoDki8uRJVJHdX9aFGaJN3yBktvq8Irud?= =?us-ascii?Q?n8/i5x296qKC2K70fBG4ZDv9q1pguspqxZdP4DqOhQq8I5j38giA2qBH7MSJ?= =?us-ascii?Q?j1lQjl+Zbjb+TIhBfSfoe0TukLIP1CXc5oA1NKU8Jzd53KiSiTtYyMy/su+p?= =?us-ascii?Q?W8cUH1J8I0rnYZ8lrw1f0tfgohp6OpS5GN1hskG2q6wi1K7n22MPCUGpMigN?= =?us-ascii?Q?Q0oxOTQVdR4Nu+n7fXWbdfeNfSwANT30DuBwqTmhyi+s21O1TaTfEaM+XQDP?= =?us-ascii?Q?20rGbcPeo4umluGu19JUI2eJBONgsl4/E0lG9b6DRCs5pOz54fkQ0SXwVyic?= =?us-ascii?Q?hEs3EAJzCrQqwLGmMKz82+JybFtTxySaHT9D/KuS7+mpd+CBhUDnWGaNfner?= =?us-ascii?Q?MEgvTsyAhX/j4JMVSRjAOEl6TY7ncbqP07J2nBLppk7jikJQHmDqxe6kIy5R?= =?us-ascii?Q?zn/4/kG8SoLIlKHL+7E5RqOLBXa3Uho5dzmyw6gZbK+gg3kigCrvJtvDq+e0?= =?us-ascii?Q?knPBTMSHEuqwpmYdhkyTkgngOxz70oBh+bq73F/EM6p/Se53FzoAUYG8Ah8d?= =?us-ascii?Q?Xf2hYqiov4A3FgSYMNv3hiMmJBQvD2KAdJOxqZBrLfZaz7X21DgGvjPGsp4E?= =?us-ascii?Q?KYzs/GSeR5cHhYdRdIrujSqYwG48QsDEnp2hhf+0eKnncUxIdWEdzF4HkBC8?= =?us-ascii?Q?unPCEQKlrTHEtquhlZjtDIHkZRHRt5jk01NhUz1XyvgpxyY73sBzIOVfwBXg?= =?us-ascii?Q?KpgdHx1JTxegJiQR/2klJKC83it7+FM+esYhFWiodh84UTg0GNJN1JfyknsL?= =?us-ascii?Q?mbciSeiKssFiXYMGoXM=3D?= 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)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2025 15:39:54.9129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29d7d29c-6aab-46b8-89bd-08de3d8286ce 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: AMS0EPF00000197.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR10MB6381 X-Authority-Analysis: v=2.4 cv=JK82csKb c=1 sm=1 tr=0 ts=6942ced0 cx=c_pps a=qOkcUHOkeTdS7jQc1VlYeQ==:117 a=d6reE3nDawwanmLcZTMRXA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FOPVHIcnkjUA:10 a=wP3pNCr1ah4A:10 a=s63m1ICgrNkA:10 a=KrXZwBdWH7kA:10 a=VkNPw1HP01LnGYTKEx00:22 a=8b9GpE9nAAAA:8 a=UTKkbO-VyYAnisI0h10A:9 a=T3LWEMljR5ZiDmsYVIUa:22 X-Proofpoint-ORIG-GUID: 3EGPlHkhSBc1mYEUuGNLajJxZd2r5HPj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE3MDEyMyBTYWx0ZWRfXyIhhG+WrFna7 jdRLpt+9946auDaGtGyjPLEJWngDsM4VwC3necqlolSvYINDm8nZkQt7xna5kT0jcqTD1Lnnfym yxnB5DK1t3NRi4AQg6mrOv6ykpLJGl9lbMcWfkF7aIL1X9GXHJi0QeQkDBkwuq28HgIl4KwyWmn 6ihIDoToBj36WIV6S/ZVFZ1io+Ge2vQyhd01GAkM57d65IOKnGbbiIEgr4qlBCrypEf3Itvu5q2 JALZSJ5p8vZ/HLi4ibBa7tsAnr/IfgmVIVXMCz5Pf0Ln0gdLYwGlKsXWNGWNrf+mBCyqnpbtSBs qxY5ib3jhwFejoynrfqgX8nVlGeV7Vh6ejIbhXE4WpKo0xh3i3aqZnVICJ1nMX0nd5lyjc4dvMJ L/sjd/+1B0rcPI+YWPfmmFu+MZLzQQ== X-Proofpoint-GUID: 3EGPlHkhSBc1mYEUuGNLajJxZd2r5HPj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-17_03,2025-12-16_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 clxscore=1011 bulkscore=0 lowpriorityscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512170123 Content-Type: text/plain; charset="utf-8" When a resource table is loaded by an external entity such as U-boot or OP-TEE, we do not necessarily get the device address(da) but the physical address(pa). This helper performs similar translation than the rproc_da_to_va() but based on a physical address. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 46 ++++++++++++++++++++++++++++ include/linux/remoteproc.h | 1 + 2 files changed, 47 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remo= teproc_core.c index 825672100528..f7c96dbed189 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -230,6 +230,52 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, size= _t len, bool *is_iomem) } EXPORT_SYMBOL(rproc_da_to_va); =20 +/** + * rproc_pa_to_va() - lookup the kernel virtual address for a physical add= ress of a remoteproc + * memory + * + * @rproc: handle of a remote processor + * @pa: remoteproc physical address + * @len: length of the memory region @pa is pointing to + * @is_iomem: optional pointer filled in to indicate if @da is iomapped me= mory + * + * This function is a helper function similar to rproc_da_to_va() but it d= eals with physical + * addresses instead of device addresses. + * + * Return: a valid kernel address on success or NULL on failure + */ +void *rproc_pa_to_va(struct rproc *rproc, phys_addr_t pa, size_t len, bool= *is_iomem) +{ + struct rproc_mem_entry *carveout; + void *ptr =3D NULL; + + list_for_each_entry(carveout, &rproc->carveouts, node) { + int offset =3D pa - carveout->dma; + + /* Verify that carveout is allocated */ + if (!carveout->va) + continue; + + /* try next carveout if da is too small */ + if (offset < 0) + continue; + + /* try next carveout if da is too large */ + if (offset + len > carveout->len) + continue; + + ptr =3D carveout->va + offset; + + if (is_iomem) + *is_iomem =3D carveout->is_iomem; + + break; + } + + return ptr; +} +EXPORT_SYMBOL(rproc_pa_to_va); + /** * rproc_find_carveout_by_name() - lookup the carveout region by a name * @rproc: handle of a remote processor diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b4795698d8c2..8fd0d7f63c8e 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -690,6 +690,7 @@ int rproc_detach(struct rproc *rproc); int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iom= em); +void *rproc_pa_to_va(struct rproc *rproc, phys_addr_t pa, size_t len, bool= *is_iomem); =20 /* from remoteproc_coredump.c */ void rproc_coredump_cleanup(struct rproc *rproc); --=20 2.43.0 From nobody Fri Dec 19 00:38:00 2025 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 00222339701; Wed, 17 Dec 2025 15:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.182.106 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986013; cv=fail; b=gL81zGv9kBPC3XyY39M+Ew9VTboi4pZjGzgiMPBqKiwltdDZaKzMsmPEGfkrxp0gIV1Oo1/PJIp2XO3TfYxEaJ0Crs3W5lldTVcqLd08QKakWbGYQg/mEDli1RExoO3MAqB1/bvdjWtQ+vDAKfBdfISjav5mDk1HXiMhfMOnB2s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986013; c=relaxed/simple; bh=q/B5a5+AwiEnyohIHkQ1oiKCatmaaniPjV/qUY44qzk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NJ5DnPScQqNIJTAkCvXIp9boquUiD1Yfu6aeV1Q8ss9SAXyNjpSnDJifn4SiQCrZfQ9jPozgkfxIt3rdYTc2QmhBuWJ+rVi/t+GWS3CXUr5XljNMH27bEJJmNuAzr9T8j2iV2fgH3PU5JFbmUKoPU/Dn/tuboFZLPZHcGoNkFA8= ARC-Authentication-Results: i=2; 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=Jt/YGBD7; arc=fail 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="Jt/YGBD7" Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BHFaedf093090; Wed, 17 Dec 2025 16:39:59 +0100 Received: from am0pr02cu008.outbound.protection.outlook.com (mail-westeuropeazon11013068.outbound.protection.outlook.com [52.101.72.68]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4b3xb70h18-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Dec 2025 16:39:59 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=td3Y79SHaYSkvVEFoVQfQXPoHBFRNO7rM8ThYGD0H+muk6DPxqHnWUplqHFT+PDbPQKBmv18ngiWWXs7z3SPz2+aoTrrI5uX+rKJm/f031Q/ObrHuBm593oxycv/4EgRELZraW0Y+z3OFcF6VEyRkJtqNzbG7xmYsQxXc/MgCebDRAVQwCRqO2uUs0sq8FF46T31KDdZ+ZJjCp73pIjLqlH0WHE5xKFeShDjJMBYbk0T2uRE2OZPQS3+xKeH9nUsxuKVSN9dhkBPKXTdDHetEPgRfAT3LiNkxNIBlHv2lUn4YmAljfmBz1Juf2uFLfLVrG/6ZQijQLsBXx1nHnpf8g== 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=k4duBz+9fl3aeITzuFd0Rp3rbm8v1uMeBlDWmaM23ag=; b=fHlIrMQf2maM6LImvIrvpEcJ6Fh2+KNKliwMomUxpdJJ3g+rlN028v/jrAl39thKWZF9L6lXb9OEVFz8pCFyOIYIml/hsmiU78gniDcK15TjAsjUT57oLWrUzqxBdma2TmIt5A7z4Y8QmVV40Fbzkek7ZR30IIl0dTIZPkFc/Whnb2xWM+H3sy1ACo7Kg2g6VcSFgg++MPS4F7beJvktVFg+s4bo8BIUnvZ4hWnd1AKdPZDpWt6hbaJpURBM91pnoFGoNbBbuE666JCqnZ7ZeDwJ2PbyDHuh8naXD40qGUiL/92IGSOQ3F+oUMryVuQKJb1u3KsRJqBbtBhABPKeAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.60) smtp.rcpttodomain=kernel.org 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=k4duBz+9fl3aeITzuFd0Rp3rbm8v1uMeBlDWmaM23ag=; b=Jt/YGBD7e37w/yEDYaXDidv2oE7U4H1B7aA8JRFyH4E1yrYB9fYjyEbXBa5Licnjc+lcu2uNHZ4yPqsbueUSKOJ19WmiWI0TKwxCk9Nc/mDjbbI7lAYnXjE7amjqtSqZZrGe75QoMpvnb8Rw0MMps8Oh48XXO2EhSOAGhRQksRcVATJPq5NYSWtAPONW9XSRcgs9Voe0wXtV/eX6Yqnygu/N/4m5A0cJRr4tjWyHiTL533BBwvsjWBpnX//PEPjlBb2ptOCBrlNxqOVSZpJmrH6hPu/P5uZUxU4FbrGXGQVRyBtlx894HRvguqU9xhiTZkyRlODNeGJWBCNyOyWq/A== Received: from AS9PR06CA0399.eurprd06.prod.outlook.com (2603:10a6:20b:461::12) by VI1PR10MB8304.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:800:1e2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6; Wed, 17 Dec 2025 15:39:55 +0000 Received: from AM2PEPF0001C70F.eurprd05.prod.outlook.com (2603:10a6:20b:461:cafe::25) by AS9PR06CA0399.outlook.office365.com (2603:10a6:20b:461::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9412.13 via Frontend Transport; Wed, 17 Dec 2025 15:39:55 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 164.130.1.60) 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.60 as permitted sender) receiver=protection.outlook.com; client-ip=164.130.1.60; helo=smtpO365.st.com; Received: from smtpO365.st.com (164.130.1.60) by AM2PEPF0001C70F.mail.protection.outlook.com (10.167.16.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:55 +0000 Received: from STKDAG1NODE2.st.com (10.75.128.133) by smtpO365.st.com (10.250.44.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 17 Dec 2025 16:40:39 +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.17; Wed, 17 Dec 2025 16:39:54 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Sumit Garg CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v20 4/6] remoteproc: Introduce optional release_fw operation Date: Wed, 17 Dec 2025 16:39:15 +0100 Message-ID: <20251217153917.3998544-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217153917.3998544-1-arnaud.pouliquen@foss.st.com> References: <20251217153917.3998544-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: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C70F:EE_|VI1PR10MB8304:EE_ X-MS-Office365-Filtering-Correlation-Id: 653456cf-ce35-49d0-8baf-08de3d8286df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sIEj+ha2n6H70s+1QTQWNtw/P9jK294V7xsotHh+1NXSZ0+Bb6qCJFiEJCJJ?= =?us-ascii?Q?M+99XaKEqGWZc8UUl4EpEUZMA5eo7Sfgo2Vhp9FgfSHA4s5BD7o4l1tbPGFs?= =?us-ascii?Q?9PjKuXl5vUbjE7myCJ/2ZIuZSUfc2BIyqf9tBwCTikL6QMMYajk0WKzeAKKF?= =?us-ascii?Q?RFYyAJ300W1OcRp/raXKD8AgraWroQwtX/KLII7cOEvVH6qfO/1D7RxmJMJc?= =?us-ascii?Q?WMMEdNj5eB0DFJKzw3QJlaql+/47+mhJm+ZieKY+9xBDXKLhMFtOApMhPqwY?= =?us-ascii?Q?8awbMp4RHy6KQguEkenOiyaS0Lvdook1xTS+6sS0mNfkrwCyNDdcCaVz4wVM?= =?us-ascii?Q?txPsJjAQufeHErFfkZcQaeFaY0beg5g4nz4vKGdXf8R6GzNFnggzWM9dldjl?= =?us-ascii?Q?H4cBtcUEGBpN48FQbISMqiza01G9SXCv1vaCXTTF8KWxS+oW3VMSD4ll3JGx?= =?us-ascii?Q?Bpn7PwQ4e/REuuCBSeo4Heur8TwsQQVsfdWo2LBenoJmXCZfdy82ABMsFtZI?= =?us-ascii?Q?lZzHOQry1Bfl/9fKxAPQx9S/t+RDlGZoxKNxRtCGrpOyy1E15w1P2hJ2s1Ap?= =?us-ascii?Q?qUV4pWp0gCjn/P5N3S+1QluOfJWasRXmEuSAlWPordj6TaYWD2N4enq5dKdT?= =?us-ascii?Q?RWv1mPNjz/VxuwvsxUw5zCB/HzKs0wKdnG4KO0PPY+YZRWd4IuL1ggqH+5JV?= =?us-ascii?Q?Z1iA2N9HrpKt9870x0634A2jOPmb9HZOlHGlXyeAdHf6v0Upc3ablK9Jbx4Z?= =?us-ascii?Q?pu8IEu4y6dV6q7B/uks9e54NH1pntKR1CfkJJ5bWPFm22B9cMXSKqk8E+4D7?= =?us-ascii?Q?4qTLspd2d3G3gqHHaqYhyURNWploV9ZYBWlxMwK2eZnlE8j9HuUWQG2cDJba?= =?us-ascii?Q?3lKyhIGEyMLiuWZrX/dL55ocq6kiV5osYwgWhCmG81mcnGibth9hRbOfUl/P?= =?us-ascii?Q?fNXWSHotc4g+/V/8b290d5Uh2vwqFjrKfP3fL/yzpBqV/7o9I9ehkS7xyxjt?= =?us-ascii?Q?8+KAxe79j6zAnqtqLytuZa3IZ5vkg4J7b/XiQfhX3FF0vC7QtXdVCORaAn1s?= =?us-ascii?Q?c+Uo0Y0k6ulZzj6M9kJN3OX0XKrQMFt7Y3X2F3TZWsrZ/uxnewQ4TmPo3Hui?= =?us-ascii?Q?8T33gByiPTVaCA397muoQcoMvxRzb3/Y0/imxrIP5KhZJuD8Q23Xapg02b6q?= =?us-ascii?Q?HJ2ufQ6YdvwmzO9hyXretbaOYCNbtyKz3wMwXpt2SGKRKgkzex5vMPXuIYfY?= =?us-ascii?Q?AiShPgmv9HLyB0yshW1G1QS2DvfYmKgyGZGSQtrYzicA0o+YejQ3wtRlktX7?= =?us-ascii?Q?h8eeW7S76xVMgYv8ZyrXnKWGiQNRPy6hohE0w5J++Iv/lbK3cQaKyXGary0I?= =?us-ascii?Q?SFBpVmn0WxGVKGRTZMbqRO6cl+chREsyz8g0VyZ6V6vUPl/iVeS+PbBEr0DS?= =?us-ascii?Q?x93gXVcYuTjggJKiOU/1JAJka6qbfoCfbLUpmc1A04zjO/OyreKB3Gf22kJm?= =?us-ascii?Q?m5qNa8dRiqzazo/z3bnM2bcGa14KPco36Rzn0RsEqZFz3kTIYKh906Sm6f8p?= =?us-ascii?Q?OhrWqTcFKH77rjBJ3no=3D?= X-Forefront-Antispam-Report: CIP:164.130.1.60;CTRY:IT;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:smtpO365.st.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2025 15:39:55.0240 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 653456cf-ce35-49d0-8baf-08de3d8286df 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.60];Helo=[smtpO365.st.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C70F.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB8304 X-Proofpoint-GUID: aROYN-EiOB8_f2f6sYXJZdDMd0-oiKbr X-Proofpoint-ORIG-GUID: aROYN-EiOB8_f2f6sYXJZdDMd0-oiKbr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE3MDEyMyBTYWx0ZWRfX71GIaLBgk8Zu u8etNk2ry+I5sdFd7pPnlv6mDbeBHy5x60rUBGOYI4DoyFtKB9wAnVhlknuixhVh3lg+tfKpaZo wVMxYOUoaaYGmkGWhnWIuo70kVDW4cNNT3guDLXREtnhawdzQOTUYOURjwJ/+w6BVnW1luIzZ9q Sy2Vlio43sGYHD1Ad7LP3fqhAEh6n6CJMivHrBFD8X9qJAbWRpm3rhRJvh/D76xLGc7iwowPqOq H1KO3HOZ8ATQ+a+T2QlwSWoOOrif+boCReaS1lb7cgcw9+AJphmAaaP9WWc1/D0+cMyP97FuiGj zeofg7F1wvvAJ8a5y3ItWZcOsL/Gj5zRvDhVtUQyTM3iTiua8T8B4we8zH+kR0W29FdNpq3zyCa imDSphgqf3fs3wf+eE23C+HDQBZXyQ== X-Authority-Analysis: v=2.4 cv=NZfrFmD4 c=1 sm=1 tr=0 ts=6942cecf cx=c_pps a=KOiI8WV4eRqHkUZxW/2pzg==:117 a=uCuRqK4WZKO1kjFMGfU4lQ==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FOPVHIcnkjUA:10 a=wP3pNCr1ah4A:10 a=s63m1ICgrNkA:10 a=KrXZwBdWH7kA:10 a=VkNPw1HP01LnGYTKEx00:22 a=8b9GpE9nAAAA:8 a=Y25hYARbUHOvULiDmFIA:9 a=T3LWEMljR5ZiDmsYVIUa:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-17_03,2025-12-16_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 bulkscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1011 spamscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512170123 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 --- Version 19 updates: - Rewrite rproc_ops::release_fw documentation - Improve commit message Version 17 updates: - 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 f7c96dbed189..1a3d646c99ab 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.43.0 From nobody Fri Dec 19 00:38:00 2025 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 14610346E61; Wed, 17 Dec 2025 15:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.182.106 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986018; cv=fail; b=RZIkTlx7S6MbRh0iHXo6fjG4F6lM4gClY5dIpu8E0tr65o3HijVdBBq9KuC3wvvEdpULMW2GRkHMb4HFIMeiABPpEbp6OQBBi1SdgBv+xHYjypDUvg0jtXwRLWXnjUrpgk+X5W8eJ6jtW4Wcd5ZFgA6rHdIt0r4cH+xS7wUIknM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986018; c=relaxed/simple; bh=yDdAg+TDU7a5Hhp4sFEg9W9nATTd9fOMh/e/c+EBgrc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XODCaw8nO8/bmu4wT/o/GZMbDHkY5Gm2J56aqJs3fv6Jw+WiD8nloP2AMR2E9Lj4bPlkQM7gSNpc6lIunUmZiazKcZGdJhe3D5swg6BvVT8m1Tas3VdADjTmmx2XM02d8JdtGAEbt9IJ860dflvuj029DiBXqatztv6xBXgo1MU= ARC-Authentication-Results: i=2; 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=OAvHRz7A; arc=fail 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="OAvHRz7A" Received: from pps.filterd (m0369458.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BHFU83R3359382; Wed, 17 Dec 2025 16:40:02 +0100 Received: from duzpr83cu001.outbound.protection.outlook.com (mail-northeuropeazon11012052.outbound.protection.outlook.com [52.101.66.52]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4b3a3wmn8e-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Dec 2025 16:40:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hg9UNaSJSE/oA4rEOlTyWDj91tjjxosLB1P1CLOdifWH4tbQDkKFLzXbSoGl1CiIli95aqW9eOCnQZ8taDQsYKhpzRSzlDQ7bqSLAf/D7duzMmyRirHSoaMeaRSE7KSfhQTwxGhUwmJ8SvSG38xNHXBvv48aVslybcjOYcFFis+pBes47u+rKTr1ydL7drR0C15A42Yp1Xc6zraDrgxgwajxncC/CgD/uvSwtCJSodBRAdHaXtCJiq9GtBNLGh4w5bXGnsl9GE4guNy88N+IfasC4Od0KJyPPvi86M3aBK7PdAREJ+1DYHt2qu47Idjz6VMzp5G60GnHaTm6w3SCYw== 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=HdQpggkfA1lZ8WqhWCxNuVGIWifD8aKrnp/n1qL4GwQ=; b=HqZQ/AY8/Skfk0gQT9BW0VRDt9KFus4RI8JOFk+VV1V/LCOqiKc8W+v6Kee2AuRGz6P9mOyZ86R5uO4dLT/ukmu9krVp9epr/bzMUeH7VngMuBZoYA5e3fYy06nehS/zg5MOvqL4F0li83/GoNlDchmJd2OAQhz7DF5i90Md2dZ1vG0y5L2qTqupxcW+NOWG/Elzge2v87Ohl+iZI27yw0f4dT1QUxxBzcRkSuUYOOiLKKz8UpmuRVsBSSRvMe0sUJtyHpEzVIzAkb+HqxwHb/yPM0WU45hIQRMJ4HUWiKVvpjvL/6VMb1WwMxBmXzwGHD+4g/AZ6WDuCg6shJw4Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.59) smtp.rcpttodomain=kernel.org 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=HdQpggkfA1lZ8WqhWCxNuVGIWifD8aKrnp/n1qL4GwQ=; b=OAvHRz7AFX5zO8J49KNt3eX+ry5VwT6L3neX67vg4L5QEe2FRb+z7buJUbKXFNOxuYABpoGLs7hdXaKA/m70I23I7dtGpYQOlro1aZIdKJgeF3TDVntrHWSc1RQAerU2vUi8Jn3gUakZLLG+QdmHt/i40SZav1YUjAaXXWtm5wBVgHK51mTY9TvJj1KBDul5yP3Jvu+sNkSMpENfyqyHPpBQDUEaNK7Nfar/IJAcV3bjUYBNByEyCB4vn8zrMTw1x4yPFXxIbpj3z2RYWS+NzelWbhu++u2PMg6s3OUbECAcvnH3e5R3gEladqIWbQKsIn91kcAyjfBpuvJDBfKeMw== Received: from AS4P251CA0009.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::20) by AM0PR10MB3716.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:156::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6; Wed, 17 Dec 2025 15:39:56 +0000 Received: from AMS0EPF00000193.eurprd05.prod.outlook.com (2603:10a6:20b:5d2:cafe::3e) by AS4P251CA0009.outlook.office365.com (2603:10a6:20b:5d2::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9434.7 via Frontend Transport; Wed, 17 Dec 2025 15:39:56 +0000 X-MS-Exchange-Authentication-Results: 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 AMS0EPF00000193.mail.protection.outlook.com (10.167.16.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:55 +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.17; Wed, 17 Dec 2025 16:40:43 +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.17; Wed, 17 Dec 2025 16:39:55 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Sumit Garg CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v20 5/6] remoteproc: Add TEE support Date: Wed, 17 Dec 2025 16:39:16 +0100 Message-ID: <20251217153917.3998544-6-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217153917.3998544-1-arnaud.pouliquen@foss.st.com> References: <20251217153917.3998544-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: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000193:EE_|AM0PR10MB3716:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a0c8c6f-975d-4740-706a-08de3d828769 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?s4ljoKyN2dqkBKnQtUh4lFlxT9oL7QQH9wuK03hwDA5oS/fwLo3sMEQ6ZG0E?= =?us-ascii?Q?CAuoevepyJaOmnmd1O4q2bZAiaQbvE2L7QRI1GIufyTIl2FSKSzOmaQsEi+3?= =?us-ascii?Q?jhJ/cs7r3D0TGT3brEqv0t9sl1VRThyk0uCOHRTRU6Sjc4lLs/5EqpkJPkqR?= =?us-ascii?Q?OVZ4P6yjHv9MElZXHiym0QVdSvBogN8RoWzrXPykbmo04VvW4rWoRvT+qK47?= =?us-ascii?Q?q+2FW3RvPMrUMwdv6c79l4cZ/JhZ9Qvn7wRsRYlDk05506zfI7y7WOx1IyPk?= =?us-ascii?Q?2xtyziTQ3FMxXQaLTFZRl7hPpBZsjNEZy7jij9N5vX7w2FMIsZxb4ihjT8Md?= =?us-ascii?Q?OZvwAjR3pYYtxswqjZG+eUfBplHWqSSCt6hYd31EKhHN8gxquyNVP1kgby3y?= =?us-ascii?Q?7FC/M3u4dzxeBHqRAmFLLBZclpsOZ52PYfn9nIA5RQOaflPJtcPXTTmTLRWo?= =?us-ascii?Q?5nLzjUAIPawipnaVQjTbiSXcWuj+VMSCsYbxoYx0UibwzY64wwtHqkbdAHV9?= =?us-ascii?Q?JKKrVf+Y2VZVHyz8e7cOUhEJJmLg7I/d8JjXn7P9LaMPslfwksZdxc2CaqQz?= =?us-ascii?Q?z3T+WF2Z5k8NHQMPeouVrYYRnnmtc2FlkJJUmYT91HTh5yfQ/94+OZH5fshG?= =?us-ascii?Q?TpcUbgwte1oY9OBlxrorSyRd+Zqvkyrbv5fVZ1hCPU7eovmf1NZH9XUVYoYd?= =?us-ascii?Q?CO+RyCKvZIwOIy/j14PNRk4rcbEf9RI7Mn1wIn5di1qCA1O0j4XjFHi/JNrr?= =?us-ascii?Q?u7IMj5ISfo9hC6pekhXBJbNQWSmOJ68L5IWcVsGDbO9ucaj6n1t3ftJ8GvC0?= =?us-ascii?Q?s7So2Nh7GCXedafw3Av6Yk1XYV3vrqwiVtujAdhrtS/TAXqfStso65RCL/si?= =?us-ascii?Q?ccGpcoa/eEE8piEaCCagKDGJDdULKhqrqLRFYf3MexJ+GEP3FvsGu5jHsvRY?= =?us-ascii?Q?MEiHoMPwMdeS4CVR8RWGcog6/lBsqNoadeXQrBEnpUxCS+bjrXbpyCZM4Icq?= =?us-ascii?Q?9qZEVjUTru7SGothnJGf9QN0uo+Ks/UoYHplOH4KaCdVRepnbluhnokexvup?= =?us-ascii?Q?Cdtuf9etZWn9syX0g0cPXIYxrM9Iu3hY0N+kfSloMLRI4bsZY9Jm3xUmxcRq?= =?us-ascii?Q?2+KL+p/XG+vedmvwlkFZGHfbOhd9Prtf50FzuYhnMSTRroL/Z/m+f8sGHNSg?= =?us-ascii?Q?y2soDyiXKjjWE8vYgWt2eEegaydQlEB676RvLy3bUeg4DBtSQ4YRTSR2+BFn?= =?us-ascii?Q?87TmGSRZQbFBMHPbK35j36cJoueu+9+WespwsW6cboQeAX1thxVIS32Gpn8B?= =?us-ascii?Q?9FPXbiV+ni69fnZIXblreb0RrULt4hlTvBKkT6JOoZ+sqofkF0fTTUQUb9SF?= =?us-ascii?Q?NatrdnWqWkpyVYOH0JSvwKD4BlrQHg4EBwbNHScgvWQXqAfP26t94fJI5Jwe?= =?us-ascii?Q?PjFHFRDq7loJAkuuw5gsxHHcFlR08hKmngzN1oyArhuG2atiI2Nx4mSE05HZ?= =?us-ascii?Q?i2UePsHBD0nFkffQzOUGUVLnHHVWDfabdC8DhDva2qijkPdfLl+1wYNRvJlx?= =?us-ascii?Q?7HSLBkELZsfxvbB1JGs=3D?= 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)(376014)(7416014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2025 15:39:55.9185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a0c8c6f-975d-4740-706a-08de3d828769 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: AMS0EPF00000193.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB3716 X-Authority-Analysis: v=2.4 cv=HLHO14tv c=1 sm=1 tr=0 ts=6942ced2 cx=c_pps a=egrrylluWbB01yBCVLFUOA==:117 a=d6reE3nDawwanmLcZTMRXA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FOPVHIcnkjUA:10 a=wP3pNCr1ah4A:10 a=s63m1ICgrNkA:10 a=KrXZwBdWH7kA:10 a=VkNPw1HP01LnGYTKEx00:22 a=8b9GpE9nAAAA:8 a=hk3vm8IgxXVi-x7od84A:9 a=5_c7Eid8brYhT-PA:21 a=T3LWEMljR5ZiDmsYVIUa:22 X-Proofpoint-ORIG-GUID: fIDOSg3Z5iqiYu0kwY53gOA6Rd1n6axD X-Proofpoint-GUID: fIDOSg3Z5iqiYu0kwY53gOA6Rd1n6axD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE3MDEyMyBTYWx0ZWRfX9qDgBbSCSK9R h9/OrSHoX89/4+EdwTxO8GdQfM5oXKdyN3ZrH4V0gaG8KVXmIvDTRYCwYwLNGPZb26bstL7x+uu LT06kmbGNUdksDpcK8mtB+tiPMoVXyHYQ14uzfUL9jTc1A6m4vQok3dXducbHyJbfo735XBnxcO MPDBoBCTElviVBd9JTOGZInzpEJLU5y6Y2huMX7v8BI2y2gamXZ/hBK+s1dxqJdY7S+w59T7VaC pE+MQsu+faTPBHvOZLL+hAZDquUsCIbNyc8sit65pzHEJuZm0dLrK+0dc/7hoBhlFSKXOBRKL/e bfK+kYhDPkUL9dB3VDkzZgHLkdD56zF5CYCgw2Ku6qmJnCrxQYXh3KjkyXYyTMgZUzVsk18rhKp npAdToEI+MAMa8xhv7L+aOvgDvIQhw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-17_03,2025-12-16_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 phishscore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512170123 Content-Type: text/plain; charset="utf-8" Add a remoteproc TEE (Trusted Execution Environment) driver that will be probed by the TEE bus. If the associated Trusted application is supported on the secure part, this driver offers a client interface to load firmware by the secure part. This firmware could be authenticated by the secure trusted application. A specificity of the implementation is that the firmware has to be authenticated and optionally decrypted to access the resource table. Consequently, the boot sequence is: 1) rproc_parse_fw --> rproc_tee_parse_fw remoteproc TEE: - Requests the TEE application to authenticate and load the firmware in the remote processor memories. - Requests the TEE application for the address of the resource table. - Creates a copy of the resource table stored in rproc->cached_table. 2) rproc_load_segments --> rproc_tee_load_fw remoteproc TEE: - Requests the TEE application to load the firmware. Nothing is done at the TEE application as the firmware is already loaded. - In case of recovery, the TEE application has to reload the firmware. 3) rproc_tee_get_loaded_rsc_table remoteproc TEE requests the TEE application for the address of the resource table. 4) rproc_start --> rproc_tee_start - Requests the TEE application to start the remote processor. The shutdown sequence is: 5) rproc_stop --> rproc_tee_stop - Requests the TEE application to stop the remote processor. 6) rproc_tee_release_fw This function is used to request the TEE application to perform actions to return to the initial state on stop or on error during the boot sequence. Signed-off-by: Arnaud Pouliquen --- Version 20 updates: - rework probe. the remoteproc-tee now probe the remoteproc devices defined in device tree as child. - creation of rproc-service-80a4c275-0a47-4905-8285-1486a9771a08 compatib= le - use of of_find_compatible_node() to find node in DT - use of of_platform_populate() to probe remoteproc devices - remove device_link_add() as now managed by of_platform_populate) - add "auto_boot" parameter in rproc_tee_register() - rename TA_RPROC_FW_CMD_* TEE CMD in TA_RPROC_CMD_* command - use of DEFINE_MUTEX Version 19 updates: - rework/fix function headers - use memremap instead of ioremap for the resource table. - realign comments to 80 chars limit, with few exceptions for readability - replace spinlock by mutex and and protect APIs from concurrent access - add support of 64-bit address in rproc_tee_get_loaded_rsc_table() - update copyright year Version 18 updates: Fix warning: warning: EXPORT_SYMBOL() is used, but #include is missing --- drivers/remoteproc/Kconfig | 10 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/remoteproc_tee.c | 771 ++++++++++++++++++++++++++++ include/linux/remoteproc_tee.h | 89 ++++ 4 files changed, 871 insertions(+) create mode 100644 drivers/remoteproc/remoteproc_tee.c create mode 100644 include/linux/remoteproc_tee.h diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 48a0d3a69ed0..75265f3f5008 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -23,6 +23,16 @@ config REMOTEPROC_CDEV =20 It's safe to say N if you don't want to use this interface. =20 +config REMOTEPROC_TEE + bool "Remoteproc support by a TEE application" + depends on OPTEE + help + Support a remote processor that is managed by an application running in= a Trusted + Execution Environment (TEE). This application is responsible for loadin= g the remote + processor firmware image and managing its lifecycle. + + It's safe to say N if the remote processor is not managed by a TEE. + config IMX_REMOTEPROC tristate "i.MX remoteproc support" depends on ARCH_MXC diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 1c7598b8475d..a1a5201982d4 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -11,6 +11,7 @@ remoteproc-y +=3D remoteproc_sysfs.o remoteproc-y +=3D remoteproc_virtio.o remoteproc-y +=3D remoteproc_elf_loader.o obj-$(CONFIG_REMOTEPROC_CDEV) +=3D remoteproc_cdev.o +obj-$(CONFIG_REMOTEPROC_TEE) +=3D remoteproc_tee.o obj-$(CONFIG_IMX_REMOTEPROC) +=3D imx_rproc.o obj-$(CONFIG_IMX_DSP_REMOTEPROC) +=3D imx_dsp_rproc.o obj-$(CONFIG_INGENIC_VPU_RPROC) +=3D ingenic_rproc.o diff --git a/drivers/remoteproc/remoteproc_tee.c b/drivers/remoteproc/remot= eproc_tee.c new file mode 100644 index 000000000000..081420c35c88 --- /dev/null +++ b/drivers/remoteproc/remoteproc_tee.c @@ -0,0 +1,771 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) STMicroelectronics 2025 + * Author: Arnaud Pouliquen + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "remoteproc_internal.h" + +#define MAX_TEE_PARAM_ARRAY_MEMBER 4 + +/* + * Authentication and load of the firmware image in the remote processor + * memories by the TEE. After this step the firmware is installed in desti= nation + * memories, which can then be locked to prevent access by Linux. + * + * [in] params[0].value.a: remote processor identifier + * [in] params[1].memref: buffer containing a temporary copy of the sign= ed + * image to load. + */ +#define TA_RPROC_CMD_LOAD_FW 1 + +/* + * Start the remote processor by the TEE + * + * [in] params[0].value.a: remote processor identifier + */ +#define TA_RPROC_CMD_START 2 + +/* + * Stop the remote processor by the TEE + * + * [in] params[0].value.a: remote processor identifier + */ +#define TA_RPROC_CMD_STOP 3 + +/* + * Return the address of the resource table, or 0 if not found. + * + * [in] params[0].value.a: remote processor identifier + * [out] params[1].value.a: 32bit LSB resource table memory address + * [out] params[1].value.b: 32bit MSB resource table memory address + * [out] params[2].value.a: 32bit LSB resource table memory size + * [out] params[2].value.b: 32bit MSB resource table memory size + */ +#define TA_RPROC_CMD_GET_RSC_TABLE 4 + +/* + * Release remote processor firmware images and associated resources. + * This command should be used in case an error occurs between the loading= of + * the firmware images (TA_RPROC_CMD_LOAD_FW) and the starting of the remo= te + * processor (TA_RPROC_CMD_START) or after stopping the remote processor + * to release associated resources (TA_RPROC_CMD_STOP). + * + * [in] params[0].value.a: remote processor identifier + */ +#define TA_RPROC_CMD_RELEASE_FW 6 + +struct rproc_tee_context { + struct list_head rproc_list; + struct tee_context *tee_ctx; + struct device *dev; +}; + +/** + * struct rproc_tee - TEE remoteproc structure + * @node: Reference in list + * @rproc: Remoteproc reference + * @rproc_id: remote processor identifier + * @session_id: TEE session identifier + */ +struct rproc_tee { + struct list_head node; + struct rproc *rproc; + u32 rproc_id; + u32 session_id; +}; + +static struct rproc_tee_context rproc_tee_ctx; +static DEFINE_MUTEX(ctx_lock); /* Protects concurrent manipulations of the= rproc_tee_ctx*/ + +static struct rproc_tee *rproc_to_trproc(struct rproc *rproc) +{ + struct rproc_tee *trproc; + + list_for_each_entry(trproc, &rproc_tee_ctx.rproc_list, node) + if (trproc->rproc =3D=3D rproc) + return trproc; + return NULL; +} + +static void rproc_tee_prepare_args(struct rproc_tee *trproc, int cmd, + struct tee_ioctl_invoke_arg *arg, + struct tee_param *param, + unsigned int num_params) +{ + memset(arg, 0, sizeof(*arg)); + memset(param, 0, MAX_TEE_PARAM_ARRAY_MEMBER * sizeof(*param)); + + arg->func =3D cmd; + arg->session =3D trproc->session_id; + arg->num_params =3D num_params + 1; + + param[0] =3D (struct tee_param) { + .attr =3D TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT, + .u.value.a =3D trproc->rproc_id, + }; +} + +/** + * rproc_tee_release_fw() - Release the firmware for a TEE-based remote pr= ocessor + * @rproc: Pointer to the struct rproc representing the remote processor + * + * This function invokes the TA_RPROC_CMD_RELEASE_FW TEE client function to + * release the firmware. It should only be called when the remoteproc stat= e is + * RPROC_OFFLINE or RPROC_DETACHED. The function requests the TEE remotepr= oc + * application to release the firmware loaded by rproc_tee_load_fw(). + * The request is ignored if the rproc state is RPROC_DETACHED as the remo= te + * processor is still running. + */ +void rproc_tee_release_fw(struct rproc *rproc) +{ + struct tee_param param[MAX_TEE_PARAM_ARRAY_MEMBER]; + struct rproc_tee *trproc; + struct tee_ioctl_invoke_arg arg; + int ret; + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return; + + if (!rproc_tee_ctx.dev) + goto out; + + trproc =3D rproc_to_trproc(rproc); + if (!trproc) + goto out; + + /* + * If the remote processor state is RPROC_DETACHED, just ignore the + * request, as the remote processor is still running. + */ + if (rproc->state =3D=3D RPROC_DETACHED) + goto out; + + if (rproc->state !=3D RPROC_OFFLINE) { + dev_err(rproc_tee_ctx.dev, "unexpected rproc state: %d\n", rproc->state); + goto out; + } + + rproc_tee_prepare_args(trproc, TA_RPROC_CMD_RELEASE_FW, &arg, param, 0); + + ret =3D tee_client_invoke_func(rproc_tee_ctx.tee_ctx, &arg, param); + if (ret < 0 || arg.ret !=3D 0) { + dev_err(rproc_tee_ctx.dev, + "TA_RPROC_CMD_RELEASE_FW invoke failed TEE err: %#x, ret:%d\n", + arg.ret, ret); + } + +out: + mutex_unlock(&ctx_lock); +} +EXPORT_SYMBOL_GPL(rproc_tee_release_fw); + +/** + * rproc_tee_load_fw() - Load firmware from TEE application + * @rproc: Pointer to the struct rproc representing the remote processor + * @fw: Pointer to the firmware structure containing the firmware data and= size + * + * This function invokes the TA_RPROC_CMD_LOAD_FW TEE client function to l= oad + * the firmware. It registers the fw->data as a shared memory region with = the + * TEE, and request the TEE to load the firmware. This function can be cal= led + * twice during the remote processor boot, a first by rproc_tee_parse_fw()= to + * parse the resource table , and a second time by rproc_tee_load_fw(). + * The TEE application should ignores the command if the firmware + * is already loaded by rproc_tee_parse_fw(). + * + * Return: 0 on success, or an error code on failure + */ +int rproc_tee_load_fw(struct rproc *rproc, const struct firmware *fw) +{ + struct tee_param param[MAX_TEE_PARAM_ARRAY_MEMBER]; + struct rproc_tee *trproc; + struct tee_ioctl_invoke_arg arg; + struct tee_shm *fw_shm; + int ret; + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return ret; + + if (!rproc_tee_ctx.dev) { + ret =3D -ENODEV; + goto out; + } + + trproc =3D rproc_to_trproc(rproc); + if (!trproc) { + ret =3D -EINVAL; + goto out; + } + + fw_shm =3D tee_shm_register_kernel_buf(rproc_tee_ctx.tee_ctx, (void *)fw-= >data, fw->size); + if (IS_ERR(fw_shm)) { + ret =3D PTR_ERR(fw_shm); + goto out; + } + + rproc_tee_prepare_args(trproc, TA_RPROC_CMD_LOAD_FW, &arg, param, 1); + + /* Provide the address of the firmware image */ + param[1] =3D (struct tee_param) { + .attr =3D TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT, + .u.memref =3D { + .shm =3D fw_shm, + .size =3D fw->size, + .shm_offs =3D 0, + }, + }; + + ret =3D tee_client_invoke_func(rproc_tee_ctx.tee_ctx, &arg, param); + if (ret < 0 || arg.ret !=3D 0) { + dev_err(rproc_tee_ctx.dev, + "TA_RPROC_CMD_LOAD_FW invoke failed TEE err: %#x, ret:%d\n", + arg.ret, ret); + if (!ret) + ret =3D -EIO; + } + + tee_shm_free(fw_shm); + +out: + mutex_unlock(&ctx_lock); + return ret; +} +EXPORT_SYMBOL_GPL(rproc_tee_load_fw); + +static int rproc_tee_get_loaded_rsc_table(struct rproc *rproc, phys_addr_t= *rsc_pa, + size_t *table_sz) +{ + struct tee_param param[MAX_TEE_PARAM_ARRAY_MEMBER]; + struct rproc_tee *trproc; + struct tee_ioctl_invoke_arg arg; + int ret; + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return ret; + + if (!rproc_tee_ctx.dev) { + ret =3D -ENODEV; + goto out; + } + + trproc =3D rproc_to_trproc(rproc); + if (!trproc) { + ret =3D -EINVAL; + goto out; + } + + rproc_tee_prepare_args(trproc, TA_RPROC_CMD_GET_RSC_TABLE, &arg, param, 2= ); + + param[1].attr =3D TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT; + param[2].attr =3D TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT; + + ret =3D tee_client_invoke_func(rproc_tee_ctx.tee_ctx, &arg, param); + if (ret < 0 || arg.ret !=3D 0) { + dev_err(rproc_tee_ctx.dev, + "TA_RPROC_CMD_GET_RSC_TABLE invoke failed TEE err: %#x, ret:%d\n", + arg.ret, ret); + ret =3D -EIO; + goto out; + } + + *table_sz =3D param[2].u.value.a; + if (sizeof(phys_addr_t) =3D=3D sizeof(u64)) + *table_sz |=3D param[2].u.value.b << 32; + + if (*table_sz) { + *rsc_pa =3D param[1].u.value.a; + if (sizeof(phys_addr_t) =3D=3D sizeof(u64)) + *rsc_pa |=3D param[1].u.value.b << 32; + } else { + *rsc_pa =3D 0; + } + +out: + mutex_unlock(&ctx_lock); + return ret; +} + +/** + * rproc_tee_parse_fw() - Get the resource table from TEE application + * @rproc: Pointer to the struct rproc representing the remote processor + * @fw: Pointer to the firmware structure containing the firmware data and= size + * + * This function retrieves the loaded resource table and creates a cached_= table + * copy. Since the firmware image is signed and potentially encrypted, the + * firmware must be loaded first to access the loaded resource table. + * + * Return: 0 on success, or an error code on failure + */ +int rproc_tee_parse_fw(struct rproc *rproc, const struct firmware *fw) +{ + phys_addr_t rsc_table; + void *rsc_va; + size_t table_sz; + int ret; + + if (!rproc) + return -EINVAL; + + /* We need first to Load the firmware, to be able to get the resource tab= le. */ + ret =3D rproc_tee_load_fw(rproc, fw); + if (ret) + return ret; + + ret =3D rproc_tee_get_loaded_rsc_table(rproc, &rsc_table, &table_sz); + if (ret) + goto release_fw; + + /* + * We assume here that the memory mapping is the same between the TEE + * and Linux kernel contexts. Else a new TEE remoteproc service could be + * needed to get a copy of the resource table. + */ + rsc_va =3D memremap(rsc_table, table_sz, MEMREMAP_WC); + if (!rsc_va) { + dev_err(rproc_tee_ctx.dev, "Unable to map memory region: %pa+%zx\n", + &rsc_table, table_sz); + ret =3D -ENOMEM; + goto release_fw; + } + + /* + * Create a copy of the resource table to have the same behavior as the + * ELF loader. This cached table will be used by the remoteproc core + * after the remoteproc stops to free resources and for crash recovery + * to reapply the settings. + * The cached table will be freed by the remoteproc core. + */ + rproc->cached_table =3D kmemdup(rsc_va, table_sz, GFP_KERNEL); + memunmap(rsc_va); + + if (!rproc->cached_table) { + ret =3D -ENOMEM; + goto release_fw; + } + + rproc->table_ptr =3D rproc->cached_table; + rproc->table_sz =3D table_sz; + + return 0; + +release_fw: + rproc_tee_release_fw(rproc); + return ret; +} +EXPORT_SYMBOL_GPL(rproc_tee_parse_fw); + +/** + * rproc_tee_find_loaded_rsc_table() - Find the loaded resource table load= ed by + * the TEE application + * @rproc: Pointer to the struct rproc representing the remote processor + * @fw: Pointer to the firmware structure containing the firmware data and= size + * + * This function retrieves the physical address and size of the resource t= able + * loaded by the TEE application. + * + * Return: pointer to the resource table if found, or NULL if not found or= size + * is 0 + */ +struct resource_table *rproc_tee_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw) +{ + phys_addr_t rsc_table; + size_t table_sz; + int ret; + + ret =3D rproc_tee_get_loaded_rsc_table(rproc, &rsc_table, &table_sz); + if (ret) + return NULL; + + rproc->table_sz =3D table_sz; + if (!table_sz) + return NULL; + + /* + * At this step the memory area that contains the resource table should + * have been registered by the remote proc platform driver and allocated + * by rproc_alloc_registered_carveouts(). + */ + return rproc_pa_to_va(rproc, rsc_table, table_sz, NULL); +} +EXPORT_SYMBOL_GPL(rproc_tee_find_loaded_rsc_table); + +/** + * rproc_tee_start() - Request the TEE application to start the remote pro= cessor + * @rproc: Pointer to the struct rproc representing the remote processor + * + * This function invokes the TA_RPROC_CMD_START command to start the remote + * processor. + * + * Return: Returns 0 on success, -EINVAL or -EIO on failure + */ +int rproc_tee_start(struct rproc *rproc) +{ + struct tee_param param[MAX_TEE_PARAM_ARRAY_MEMBER]; + struct rproc_tee *trproc; + struct tee_ioctl_invoke_arg arg; + int ret; + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return ret; + + if (!rproc_tee_ctx.dev) { + ret =3D -ENODEV; + goto out; + } + + trproc =3D rproc_to_trproc(rproc); + if (!trproc) { + ret =3D -EINVAL; + goto out; + } + + rproc_tee_prepare_args(trproc, TA_RPROC_CMD_START, &arg, param, 0); + + ret =3D tee_client_invoke_func(rproc_tee_ctx.tee_ctx, &arg, param); + if (ret < 0 || arg.ret !=3D 0) { + dev_err(rproc_tee_ctx.dev, + "TA_RPROC_CMD_START invoke failed TEE err: %#x, ret:%d\n", arg.ret, ret= ); + if (!ret) + ret =3D -EIO; + } + +out: + mutex_unlock(&ctx_lock); + return ret; +} +EXPORT_SYMBOL_GPL(rproc_tee_start); + +/** + * rproc_tee_stop() - Request the TEE application to start the remote proc= essor + * @rproc: Pointer to the struct rproc representing the remote processor + * + * This function invokes the TA_RPROC_CMD_STOP command to stop the remote + * processor. + * + * Return: Returns 0 on success, -EINVAL or -EIO on failure + */ +int rproc_tee_stop(struct rproc *rproc) +{ + struct tee_param param[MAX_TEE_PARAM_ARRAY_MEMBER]; + struct rproc_tee *trproc; + struct tee_ioctl_invoke_arg arg; + int ret; + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return ret; + + if (!rproc_tee_ctx.dev) { + ret =3D -ENODEV; + goto out; + } + + trproc =3D rproc_to_trproc(rproc); + if (!trproc) { + ret =3D -EINVAL; + goto out; + } + + rproc_tee_prepare_args(trproc, TA_RPROC_CMD_STOP, &arg, param, 0); + + ret =3D tee_client_invoke_func(rproc_tee_ctx.tee_ctx, &arg, param); + if (ret < 0 || arg.ret !=3D 0) { + dev_err(rproc_tee_ctx.dev, + "TA_RPROC_CMD_STOP invoke failed TEE err: %#x, ret:%d\n", arg.ret, ret); + if (!ret) + ret =3D -EIO; + } + +out: + mutex_unlock(&ctx_lock); + return ret; +} +EXPORT_SYMBOL_GPL(rproc_tee_stop); + +static const struct rproc_ops rproc_tee_default_ops =3D { + .start =3D rproc_tee_start, + .stop =3D rproc_tee_stop, + .load =3D rproc_tee_load_fw, + .parse_fw =3D rproc_tee_parse_fw, + .find_loaded_rsc_table =3D rproc_tee_find_loaded_rsc_table, + .release_fw =3D rproc_tee_release_fw, +}; + +static const struct tee_client_device_id rproc_tee_id_table[] =3D { + {UUID_INIT(0x80a4c275, 0x0a47, 0x4905, 0x82, 0x85, 0x14, 0x86, 0xa9, 0x77= , 0x1a, 0x08)}, + { /* sentinel */ } +}; + +/** + * rproc_tee_register() - Register a remote processor controlled by the TE= E application. + * @dev: Pointer to client rproc device + * @rproc: Pointer to the struct rproc representing the remote processor + * @rproc_id: ID of the remote processor + * @auto_boot: flag to indicate if remote processor should be auto-started + * + * This function registers a remote processor that will be managed by a TEE + * application, by opening a session with the TEE client. + * + * Return: Returns 0 on success, or an error code on failure + */ +int rproc_tee_register(struct device *dev, struct rproc **rproc, + unsigned int rproc_id, bool auto_boot) +{ + struct tee_param param[MAX_TEE_PARAM_ARRAY_MEMBER]; + struct tee_ioctl_open_session_arg sess_arg; + struct device_node *np =3D dev->of_node; + struct tee_client_device *tee_device; + struct rproc *new_rproc; + struct rproc_tee *trproc; + const char *fw_name; + int ret; + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return ret; + + if (!rproc_tee_ctx.dev) { + ret =3D -ENODEV; + goto out; + } + + trproc =3D kzalloc(sizeof(*trproc), GFP_KERNEL); + if (!trproc) { + ret =3D -ENOMEM; + goto out; + } + + /* Look for an optional firmware name */ + ret =3D rproc_of_parse_firmware(dev, 0, &fw_name); + if (ret < 0 && ret !=3D -EINVAL) + goto free_tproc; + + new_rproc =3D rproc_alloc(dev, np->name, &rproc_tee_default_ops, + fw_name, sizeof(*trproc)); + if (!new_rproc) { + ret =3D -ENOMEM; + goto free_tproc; + } + + tee_device =3D to_tee_client_device(rproc_tee_ctx.dev); + memset(&sess_arg, 0, sizeof(sess_arg)); + + memcpy(sess_arg.uuid, tee_device->id.uuid.b, TEE_IOCTL_UUID_LEN); + + sess_arg.clnt_login =3D TEE_IOCTL_LOGIN_REE_KERNEL; + sess_arg.num_params =3D 1; + + param[0] =3D (struct tee_param) { + .attr =3D TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT, + .u.value.a =3D rproc_id, + }; + + ret =3D tee_client_open_session(rproc_tee_ctx.tee_ctx, &sess_arg, param); + if (ret < 0 || sess_arg.ret !=3D 0) { + dev_err(dev, "tee_client_open_session failed, err: %#x\n", sess_arg.ret); + ret =3D -EINVAL; + goto free_rproc; + } + + trproc->rproc_id =3D rproc_id; + trproc->session_id =3D sess_arg.session; + new_rproc->auto_boot =3D auto_boot; + + ret =3D rproc_add(new_rproc); + if (ret) + goto close_tee; + + trproc->rproc =3D new_rproc; + *rproc =3D new_rproc; + + list_add_tail(&trproc->node, &rproc_tee_ctx.rproc_list); + + mutex_unlock(&ctx_lock); + + return 0; + +close_tee: + if (tee_client_close_session(rproc_tee_ctx.tee_ctx, trproc->session_id)) + dev_err(rproc_tee_ctx.dev, "tee_client_close_session failed\n"); +free_rproc: + rproc_free(new_rproc); +free_tproc: + kfree(trproc); +out: + mutex_unlock(&ctx_lock); + return ret; +} +EXPORT_SYMBOL_GPL(rproc_tee_register); + +/** + * rproc_tee_unregister - Unregister a remote processor controlled by the = TEE + * application. + * @dev: Pointer to client rproc device + * @rproc: Pointer to the struct rproc representing the remote processor + * + * This function unregisters a remote processor previously registered by t= he + * rproc_tee_register() function. + * + * Return: Returns 0 on success, or an error code on failure + */ +int rproc_tee_unregister(struct device *dev, struct rproc *rproc) +{ + struct rproc_tee *trproc; + int ret; + + if (!rproc_tee_ctx.dev) { + ret =3D -ENODEV; + return ret; + } + + trproc =3D rproc_to_trproc(rproc); + if (!trproc) { + ret =3D -EINVAL; + return ret; + } + + rproc_del(rproc); + rproc_free(rproc); + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + return ret; + + ret =3D tee_client_close_session(rproc_tee_ctx.tee_ctx, trproc->session_i= d); + if (ret < 0) + dev_err(rproc_tee_ctx.dev, "tee_client_close_session failed, err: %#x\n"= , ret); + list_del(&trproc->node); + kfree(trproc); + mutex_unlock(&ctx_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(rproc_tee_unregister); + +static int rproc_tee_ctx_match(struct tee_ioctl_version_data *ver, const v= oid *data) +{ + /* Today we support only the OP-TEE, could be extend to other tees */ + return (ver->impl_id =3D=3D TEE_IMPL_ID_OPTEE); +} + +static const struct of_device_id remoteproc_tee_of_match[] =3D { + { .compatible =3D "rproc-service-80a4c275-0a47-4905-8285-1486a9771a08" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, remoteproc_tee_of_match); + +static int rproc_tee_probe(struct device *dev) +{ + struct tee_context *tee_ctx; + struct device_node *np; + int ret; + + pr_err("%s %d", __func__, __LINE__); + np =3D of_find_compatible_node(NULL, NULL, + remoteproc_tee_of_match[0].compatible); + if (!np) { + dev_err(dev, "Device node not found\n"); + return -ENODEV; + } + + /* Open context with TEE driver */ + tee_ctx =3D tee_client_open_context(NULL, rproc_tee_ctx_match, NULL, NULL= ); + if (IS_ERR(tee_ctx)) { + ret =3D PTR_ERR(tee_ctx); + goto put_node; + } + + ret =3D mutex_lock_interruptible(&ctx_lock); + if (ret) + goto close_ctx; + + rproc_tee_ctx.dev =3D dev; + rproc_tee_ctx.tee_ctx =3D tee_ctx; + INIT_LIST_HEAD(&rproc_tee_ctx.rproc_list); + + mutex_unlock(&ctx_lock); + + ret =3D device_add_of_node(dev, np); + if (ret) + goto clean_ctx; + + ret =3D of_platform_populate(np, NULL, NULL, dev); + if (ret) { + dev_err(dev, "cannot populate node (%d)\n", ret); + goto clean_ctx; + } + + return 0; + +clean_ctx: + mutex_lock(&ctx_lock); + rproc_tee_ctx.dev =3D NULL; + rproc_tee_ctx.tee_ctx =3D NULL; + mutex_unlock(&ctx_lock); + +close_ctx: + tee_client_close_context(tee_ctx); + +put_node: + of_node_put(np); + return ret; +} + +static int rproc_tee_remove(struct device *dev) +{ + of_platform_depopulate(dev); + + device_remove_of_node(dev); + + mutex_lock(&ctx_lock); + tee_client_close_context(rproc_tee_ctx.tee_ctx); + rproc_tee_ctx.dev =3D NULL; + rproc_tee_ctx.tee_ctx =3D NULL; + mutex_unlock(&ctx_lock); + + return 0; +} + +MODULE_DEVICE_TABLE(tee, rproc_tee_id_table); + +static struct tee_client_driver rproc_tee_fw_driver =3D { + .id_table =3D rproc_tee_id_table, + .driver =3D { + .name =3D KBUILD_MODNAME, + .bus =3D &tee_bus_type, + .probe =3D rproc_tee_probe, + .remove =3D rproc_tee_remove, + }, +}; + +static int __init rproc_tee_fw_mod_init(void) +{ + return driver_register(&rproc_tee_fw_driver.driver); +} + +static void __exit rproc_tee_fw_mod_exit(void) +{ + driver_unregister(&rproc_tee_fw_driver.driver); +} + +module_init(rproc_tee_fw_mod_init); +module_exit(rproc_tee_fw_mod_exit); + +MODULE_DESCRIPTION("remote processor TEE module"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/remoteproc_tee.h b/include/linux/remoteproc_tee.h new file mode 100644 index 000000000000..33150cff7a5a --- /dev/null +++ b/include/linux/remoteproc_tee.h @@ -0,0 +1,89 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright(c) 2025 STMicroelectronics + */ + +#ifndef REMOTEPROC_TEE_H +#define REMOTEPROC_TEE_H + +#include +#include +#include + +#if IS_ENABLED(CONFIG_REMOTEPROC_TEE) + +int rproc_tee_register(struct device *dev, struct rproc **rproc, + unsigned int rproc_id, bool auto_boot); +int rproc_tee_unregister(struct device *dev, struct rproc *rproc); +int rproc_tee_parse_fw(struct rproc *rproc, const struct firmware *fw); +int rproc_tee_load_fw(struct rproc *rproc, const struct firmware *fw); +void rproc_tee_release_fw(struct rproc *rproc); +struct resource_table *rproc_tee_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw); +int rproc_tee_start(struct rproc *rproc); +int rproc_tee_stop(struct rproc *rproc); +int rproc_tee_pa_to_da(struct rproc *rproc, phys_addr_t pa, size_t size, u= 64 *da); +#else + +static inline int rproc_tee_register(struct device *dev, struct rproc **rp= roc, + unsigned int rproc_id, bool auto_boot) +{ + return -ENODEV; +} + +static inline int rproc_tee_parse_fw(struct rproc *rproc, const struct fir= mware *fw) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + +static inline int rproc_tee_unregister(struct device *dev, struct rproc *r= proc) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + +static inline int rproc_tee_load_fw(struct rproc *rproc, const struct firm= ware *fw) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + +static inline int rproc_tee_start(struct rproc *rproc) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + +static inline int rproc_tee_stop(struct rproc *rproc) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + +static inline void rproc_tee_release_fw(struct rproc *rproc) +{ + /* This shouldn't be possible */ + WARN_ON(1); +} + +static inline struct resource_table * +rproc_tee_find_loaded_rsc_table(struct rproc *rproc, const struct firmware= *fw) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return NULL; +} +#endif /* CONFIG_REMOTEPROC_TEE */ +#endif /* REMOTEPROC_TEE_H */ --=20 2.43.0 From nobody Fri Dec 19 00:38:00 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 DEA64349B0A; Wed, 17 Dec 2025 15:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=91.207.212.93 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986018; cv=fail; b=uNMsj1NAL/RZvntaSIOvTgF66BZMJvfRS1fVx401nOavnEYfAxYr4NlzGenrLZ5cUEDTZ6PoW5v602EvXTbm/H0YzYOVmCH3zUBw6WJXitzrwYxXGzoeHA4X/2n6OvFXSrMng0sZ2T+g/fEmzz/LYT4fzSBTf61Z3iFD+JYGL4I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986018; c=relaxed/simple; bh=vHypet3OsUDKc8wYztXlLuKmXmzDmKgHdU6VmbIKzhI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=biYzSoUj4KcY5/2JakrGU9h7ws7nbIOMfvShgx6JnUVNrsyqqPcFYmsV6qQ5yNizuAtGcNb1te02mu+63o4jHkGnWTMnGFmdby7mkVdXHD2Qs96iP6DCsl9N9Iep1l7EhfrsMsap/KPYXhpZ8pkE3xdIcoOvOB8QoZLNycPB8Cw= ARC-Authentication-Results: i=2; 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=KVkoZDgY; arc=fail 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="KVkoZDgY" Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BHFVkmE502440; Wed, 17 Dec 2025 16:40:04 +0100 Received: from osppr02cu001.outbound.protection.outlook.com (mail-norwayeastazon11013016.outbound.protection.outlook.com [40.107.159.16]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4b3de1m1mu-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Dec 2025 16:40:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rovbFgVNa1S7fa4L7lEx1DfBdzNA8O9IjYPVftJ/LD1f5ZinAgszPvCeAQ0wJGT7PhfUvi0yqivdMFQ5lVndHjVjP70hafdsD9UavolvlhBsLUjcuGbBes0Fcn2FqntK9Z54pjn0D1LwQnteSPMYqsSUZf64+GRNQAF2BAFwCMHY3qTSy9G/wLwrNJIo+oGHB5ZQhicfgkMcZYwdeZsHcfgOGrpqR/8xmr9ZB2keJ6h9t8GJPoyXnbHWyyxfiglgeqpRr6uKzFqqOkjPZN53mglmQZzV7X6AnjzxDZr8Lvn66NuetAuRIYgsLi9i9QFdzj03v8HwB+37Fl1G22rNuw== 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=UnpB+93P84UT6wXamM8gI1nKYcNDnu8iksv6Z0wXyYo=; b=xWLXtb4zpaMW62CgyHDo35fIIn0IMB8+qY7cp17MARdGEGzAyXCyNL/NmrDDpBEFm6AKcX5U7iTPcRwdIdQadXMYKG54SzBcjev0AeAJUg0RRbtOgLHLjrE5YwSpEHXvLXLQDijGOFDsr9/TW8dVW43IGBUy6jGlVtVkrfxACGFdkhuTTmrTh+Qd8f6UdxM4ID/fa5MK8vTf1UINVWZn5tiaIS65gjeHnhBlupLO3uW3vAcgBBXHzp8qhNPHgaOtZYUnfAZsy/QOvxqLWS/X9CmSAdjJuOuV8hFLWBRmiGFixdj710+eUNg6UUZEPLJQ1l6uoO6/OS93btQmsLvNVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.59) smtp.rcpttodomain=kernel.org 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=UnpB+93P84UT6wXamM8gI1nKYcNDnu8iksv6Z0wXyYo=; b=KVkoZDgYDA8oGb7jtrYB8K4oURRdEboo7iOXrr4qDNJRjaaNbHGF4AU8v6KrEVq5mTsscnbYOB0JAI/+7RuB87e3knE+JuL5CBVt6d7i2AzbnbfoGwJDPqC5gZ+Nh6fyCIbfKF/Q2AyBtnp7AsVZd0n8EzLj0ySk748wMB6Pto/lCBYkEmgyqm9ur6YaO1oJ4AFS/MUpmMTsVoqQC1ZLSYzkjjS63SEWmZDUKjJ/HLmOkdZdRKpppw6k4DYIQsybMSa+zCYDLC2bn1nVcOBisppKkMcNXB/FNfVQfYtGCpq40ql+GBnFjqme4ibXkj4YycTrHJLY7GvNZHll/vxUBw== Received: from AS4P251CA0004.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::6) by PRAPR10MB5445.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:291::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6; Wed, 17 Dec 2025 15:39:58 +0000 Received: from AMS0EPF00000193.eurprd05.prod.outlook.com (2603:10a6:20b:5d2:cafe::95) by AS4P251CA0004.outlook.office365.com (2603:10a6:20b:5d2::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:55 +0000 X-MS-Exchange-Authentication-Results: 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 AMS0EPF00000193.mail.protection.outlook.com (10.167.16.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9434.6 via Frontend Transport; Wed, 17 Dec 2025 15:39:58 +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.17; Wed, 17 Dec 2025 16:40:44 +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.17; Wed, 17 Dec 2025 16:39:55 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Sumit Garg CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v20 6/6] remoteproc: stm32: Add TEE-controlled STM32 driver Date: Wed, 17 Dec 2025 16:39:17 +0100 Message-ID: <20251217153917.3998544-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217153917.3998544-1-arnaud.pouliquen@foss.st.com> References: <20251217153917.3998544-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: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000193:EE_|PRAPR10MB5445:EE_ X-MS-Office365-Filtering-Correlation-Id: 81ffbc92-e1f8-4af9-2068-08de3d828914 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?pPMbLjz0ET8W7RadJjV860USfVmkMbclJ+FHD9M19SYmNF4YnaLqSVWPG8H0?= =?us-ascii?Q?fKBgXa2RQXg31XKg/lJYNFBGZA36Us4zu+jwT1TdsMTiNQXb2mbqYhNevbvt?= =?us-ascii?Q?W+e+LppJHE0xwF6LbXy8m2AVf2mczQtdbGavWQmdCaRUk2wClOX2FRgUc/QD?= =?us-ascii?Q?LuTSnVzAX6mlPXwUV22aupmsvMurO8/lVL66KfKcmISVu6A9cSX3BYX78Ryr?= =?us-ascii?Q?YM/QJMBaezV447e+zSDVnw3349E0LyyhkYbvIdICUCB6o4c2b/wV5s/aVPDt?= =?us-ascii?Q?Mx76rBfeU4YSzFIbSH8uaW7M0WwkAQHqzETKAljKLNUG0aiu4P7hI+9Evt9f?= =?us-ascii?Q?mid55cJQs8srFhaH8l9DsJ3wGo41/YKl3pMgXeP5lzZzTOjKVZfhNt1M/sYZ?= =?us-ascii?Q?GeMcf0rZrjX0WP8nsFlXwJjorjABjgUg8c/sN2bKSDpKwr+d+Sh8DHxqpmZS?= =?us-ascii?Q?AVhUfdJIyXgrKJOQmlwylh2wZQzSFY1wn24XKOshLEnmLHdyzxVpaPp3pFsM?= =?us-ascii?Q?arKXs0N0OAcvrTr8KoBwVVsMpXTvUx5gBEZw7jb/RYSW2cChnbVeHPWBlWkO?= =?us-ascii?Q?1JU+PTpg0C8fMIYd8F/UfG7QdAzfD2+F72+3Cg/I34ombPx6+MoKVwf1vrZS?= =?us-ascii?Q?iN0KFtkB/VTxjbuFzkb1gOty8qGgAlXaYuN4kmCla5cTz0r/tYKMqDJ6e/ce?= =?us-ascii?Q?qthl8lalbqvGOzNwU7h3MSmc+RUlp5Qton1KCi2jnoN0uwdckBJ0Tlx1XwQv?= =?us-ascii?Q?5/yT18MyLsU+SloYORd3s2xGpAf2Amt1MqUf2lb2KDyMKbeOm9T0RDPk/XEC?= =?us-ascii?Q?sQUZ9narPXdx+EcVQU6AOMkRT5fI0DHRxj8BbbyZRgUPqS4lcsiHCmWcg1ZH?= =?us-ascii?Q?RFZrca8bltexhrYPDGQz4Qo4uHEqe18fz104+jCooTLXcRWhBHFX4NMpVrtF?= =?us-ascii?Q?20+jUmOM2Eh9nrFfoIhEq2FgSaWlwPgzjNXciIQZvTr/UDtTeTQzmIEaMy2H?= =?us-ascii?Q?W8+uDnrKbrvx/LHEprkwsUlZ3jtNriJDiW39EI1ah6HTUg7V6OJQwAajDbad?= =?us-ascii?Q?PAU3YbQQRM0tqfbVAOHLOwDyIJRWbVxctrMKOoPiosrPrD0XzQS3MC2UOgA0?= =?us-ascii?Q?c1N3SNdV7l8WaQP4KfpRslO7+1QGZ8TxcRC7U77AXSqZu88td3ngzhZ/zQqO?= =?us-ascii?Q?tmgeEAOAhdjno6CpOQr8jy5jcR0omvOMOGqpdIbdRwRdmd42Gq7Z1ex2ycx9?= =?us-ascii?Q?Y7qdun1SLNPGyir1cGT+WiMcFasTuzVIaqVXAVXI24px2Fb1giU0tdGtKf2m?= =?us-ascii?Q?qjAyui+3pNO+HolysVdxg/Hc0Tf5PQl3UV1UYHbGfy70RTSCNfzQYd3PuedV?= =?us-ascii?Q?gcqEZSj43dgu5FeZoVuj6cHuj1lQZzhq75KXgNF6jDyfWJ5EPJmcSp2Cte9f?= =?us-ascii?Q?Zdhn7LClIaxeKNmDlICQGiR6FW//ZpP7B6yTU85bfGpzygSnGFFCSCMsf4iN?= =?us-ascii?Q?iAff2p7NuWgC6cPOSgvMFGEvuW1eVeA85W83O82BzPFmg26/qUe7DExqDOzT?= =?us-ascii?Q?OcKA/CQWraEKu543zyo=3D?= 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)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2025 15:39:58.7279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81ffbc92-e1f8-4af9-2068-08de3d828914 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: AMS0EPF00000193.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAPR10MB5445 X-Authority-Analysis: v=2.4 cv=JeOxbEKV c=1 sm=1 tr=0 ts=6942ced3 cx=c_pps a=H6LALYfxwt1dZiozdb8jwQ==:117 a=d6reE3nDawwanmLcZTMRXA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=FOPVHIcnkjUA:10 a=wP3pNCr1ah4A:10 a=s63m1ICgrNkA:10 a=KrXZwBdWH7kA:10 a=VkNPw1HP01LnGYTKEx00:22 a=8b9GpE9nAAAA:8 a=Hs7IVT9660pjhmUSbEkA:9 a=T3LWEMljR5ZiDmsYVIUa:22 X-Proofpoint-GUID: aOLsqU67KMLcRz4r-okv2wSXMBEMW-gR X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE3MDEyMyBTYWx0ZWRfX/eSKE19fzkXt VHkSLwl+ig5qhZ3VP3MrF595fUg+5yFAKCCUex+9Z0d+AYZCTNYZrgNFWVapj7jzMurIr296uOK ZKqRwt9Lx1UtGFYt9FPsbQDWVlZAdVj7uaCLZ+tA3glja6BIK8/CxseCR5zT1IVKYES2BSCNrhl FBY+FWvEhu30dF+mx73HgxJtmKEa76lJoPadnmrQLWwrqyRejdvqxCYjmd4VAahJ4ZlPInLdwDq 34IA5lYj3CjnlRyViOU7mjNxrItFLsLw4+tGhGYJ/O+9loXbPCYA7yy9oMfwVtCVwE5DRx90ZPs L0NfA84izLRn5NJNdPh+ktSV8piwhuno9SkY2PVapxQJj8EPw++QznNG8urU7MaBm4/lnGunJAq 9jA77plq7MivajR4z130nsYXkJBB5w== X-Proofpoint-ORIG-GUID: aOLsqU67KMLcRz4r-okv2wSXMBEMW-gR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-17_03,2025-12-16_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512170123 Content-Type: text/plain; charset="utf-8" Add a remoteproc platform driver for the STM32MP15 Cortex-M4 core controlled via a TEE Trusted Application. The driver integrates with the generic TEE remoteproc layer (rproc_tee_*) to delegate firmware authentication, loading and start/stop operations to the TEE, while handling STM32-specific platform resources on the Linux side: - Translation between physical and device addresses using SoC-specific DMA ranges. - Registration of reserved-memory carveouts from "memory-region" phandles (including vdev vrings and buffers). - Mailbox-based virtio queue kicks and a shutdown channel using the IPCC mailbox controller. - Optional watchdog interrupt for crash reporting and wakeup. This enables secure boot and runtime isolation of the M4 firmware while still using the standard remoteproc and rpmsg frameworks on STM32MP15. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/Makefile | 2 +- drivers/remoteproc/stm32_rproc_tee.c | 526 +++++++++++++++++++++++++++ 2 files changed, 527 insertions(+), 1 deletion(-) create mode 100644 drivers/remoteproc/stm32_rproc_tee.c diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index a1a5201982d4..80f0965bac95 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -36,7 +36,7 @@ qcom_wcnss_pil-y +=3D qcom_wcnss_iris.o obj-$(CONFIG_RCAR_REMOTEPROC) +=3D rcar_rproc.o obj-$(CONFIG_ST_REMOTEPROC) +=3D st_remoteproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) +=3D st_slim_rproc.o -obj-$(CONFIG_STM32_RPROC) +=3D stm32_rproc.o +obj-$(CONFIG_STM32_RPROC) +=3D stm32_rproc.o stm32_rproc_tee.o obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) +=3D ti_k3_dsp_remoteproc.o ti_k3_commo= n.o obj-$(CONFIG_TI_K3_M4_REMOTEPROC) +=3D ti_k3_m4_remoteproc.o ti_k3_common.o obj-$(CONFIG_TI_K3_R5_REMOTEPROC) +=3D ti_k3_r5_remoteproc.o ti_k3_common.o diff --git a/drivers/remoteproc/stm32_rproc_tee.c b/drivers/remoteproc/stm3= 2_rproc_tee.c new file mode 100644 index 000000000000..1d492698265b --- /dev/null +++ b/drivers/remoteproc/stm32_rproc_tee.c @@ -0,0 +1,526 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025, STMicroelectronics - All Rights Reserved + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "remoteproc_internal.h" + +#define MBOX_NB_VQ 2 +#define MBOX_NB_MBX 3 + +#define STM32_MBX_VQ0 "vq0" +#define STM32_MBX_VQ0_ID 0 +#define STM32_MBX_VQ1 "vq1" +#define STM32_MBX_VQ1_ID 1 +#define STM32_MBX_SHUTDOWN "shutdown" + +struct stm32_rproc_tee_mem { + char name[20]; + void __iomem *cpu_addr; + phys_addr_t phy_addr; + u32 dev_addr; + size_t size; +}; + +struct stm32_rproc_tee_dma_ranges { + u32 dev_addr; + u32 phy_addr; + u32 size; +}; + +struct stm32_mbox { + const unsigned char name[10]; + struct mbox_chan *chan; + struct mbox_client client; + struct work_struct vq_work; + int vq_id; +}; + +struct stm32_rproc_tee { + int wdg_irq; + const struct stm32_rproc_tee_dma_ranges *ranges; + struct stm32_mbox mb[MBOX_NB_MBX]; + struct workqueue_struct *workqueue; +}; + +static const struct stm32_rproc_tee_dma_ranges stm32mp15_m4_dma_ranges[] = =3D { + /* RETRAM address translation */ + { .dev_addr =3D 0x0, .phy_addr =3D 0x38000000, .size =3D 0x10000 }, + {/* sentinel */} +}; + +static int stm32_rproc_tee_pa_to_da(struct rproc *rproc, phys_addr_t pa, + size_t size, u64 *da) +{ + struct stm32_rproc_tee *ddata =3D rproc->priv; + const struct stm32_rproc_tee_dma_ranges *range; + struct device *dev =3D rproc->dev.parent; + + for (range =3D ddata->ranges; range->phy_addr; range++) { + if (pa < range->phy_addr || + pa >=3D range->phy_addr + range->size) + continue; + if (pa + size > range->phy_addr + range->size) { + dev_err(dev, "range too small for %pa+0x%zx\n", &pa, size); + return -EINVAL; + } + *da =3D pa - range->phy_addr + range->dev_addr; + dev_dbg(dev, "pa %pa to da %llx\n", &pa, *da); + return 0; + } + + *da =3D pa; + + return 0; +} + +static int stm32_rproc_tee_mem_alloc(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + struct device *dev =3D rproc->dev.parent; + void *va; + + dev_dbg(dev, "map memory: %pad+%zx\n", &mem->dma, mem->len); + va =3D (__force void *)ioremap_wc(mem->dma, mem->len); + if (IS_ERR_OR_NULL(va)) { + dev_err(dev, "Unable to map memory region: %pad+0x%zx\n", + &mem->dma, mem->len); + return -ENOMEM; + } + + /* Update memory entry va */ + mem->va =3D va; + + return 0; +} + +static int stm32_rproc_tee_mem_release(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma); + iounmap((__force __iomem void *)mem->va); + + return 0; +} + +static int stm32_rproc_tee_mbox_idx(struct rproc *rproc, const unsigned ch= ar *name) +{ + struct stm32_rproc_tee *ddata =3D rproc->priv; + int i; + + for (i =3D 0; i < ARRAY_SIZE(ddata->mb); i++) { + if (!strncmp(ddata->mb[i].name, name, strlen(name))) + return i; + } + dev_err(&rproc->dev, "mailbox %s not found\n", name); + + return -EINVAL; +} + +static void stm32_rproc_tee_request_shutdown(struct rproc *rproc) +{ + struct stm32_rproc_tee *ddata =3D rproc->priv; + int err, idx; + + /* Request shutdown of the remote processor */ + if (rproc->state !=3D RPROC_OFFLINE && rproc->state !=3D RPROC_CRASHED) { + idx =3D stm32_rproc_tee_mbox_idx(rproc, STM32_MBX_SHUTDOWN); + if (idx >=3D 0 && ddata->mb[idx].chan) { + err =3D mbox_send_message(ddata->mb[idx].chan, "detach"); + if (err < 0) + dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n"); + } + } +} + +static int stm32_rproc_tee_stop(struct rproc *rproc) +{ + stm32_rproc_tee_request_shutdown(rproc); + + return rproc_tee_stop(rproc); +} + +static int stm32_rproc_tee_prepare(struct rproc *rproc) +{ + struct device *dev =3D rproc->dev.parent; + struct device_node *np =3D dev->of_node; + struct rproc_mem_entry *mem; + int index =3D 0, mr =3D 0; + u64 da; + + /* Register associated reserved memory regions */ + while (1) { + struct resource res; + int ret; + + ret =3D of_reserved_mem_region_to_resource(np, mr++, &res); + if (ret) + return 0; + + if (stm32_rproc_tee_pa_to_da(rproc, res.start, + resource_size(&res), &da) < 0) { + dev_err(dev, "memory region not valid %pR\n", &res); + return -EINVAL; + } + + /* No need to map vdev buffer */ + if (strstarts(res.name, "vdev0buffer")) { + /* Register reserved memory for vdev buffer alloc */ + mem =3D rproc_of_resm_mem_entry_init(dev, index, + resource_size(&res), + res.start, + "vdev0buffer"); + } else { + /* Register memory region */ + mem =3D rproc_mem_entry_init(dev, NULL, + (dma_addr_t)res.start, + resource_size(&res), da, + stm32_rproc_tee_mem_alloc, + stm32_rproc_tee_mem_release, + "%.*s", + (int)(strchrnul(res.name, '@') - res.name), + res.name); + if (mem) + rproc_coredump_add_segment(rproc, da, + resource_size(&res)); + } + + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + index++; + } + + return 0; +} + +static irqreturn_t stm32_rproc_tee_wdg(int irq, void *data) +{ + struct platform_device *pdev =3D data; + struct rproc *rproc =3D platform_get_drvdata(pdev); + + rproc_report_crash(rproc, RPROC_WATCHDOG); + + return IRQ_HANDLED; +} + +static void stm32_rproc_tee_mb_vq_work(struct work_struct *work) +{ + struct stm32_mbox *mb =3D container_of(work, struct stm32_mbox, vq_work); + struct rproc *rproc =3D dev_get_drvdata(mb->client.dev); + + mutex_lock(&rproc->lock); + + if (rproc->state !=3D RPROC_RUNNING && rproc->state !=3D RPROC_ATTACHED) + goto unlock_mutex; + + if (rproc_vq_interrupt(rproc, mb->vq_id) =3D=3D IRQ_NONE) + dev_dbg(&rproc->dev, "no message found in vq%d\n", mb->vq_id); + +unlock_mutex: + mutex_unlock(&rproc->lock); +} + +static void stm32_rproc_tee_mb_callback(struct mbox_client *cl, void *data) +{ + struct rproc *rproc =3D dev_get_drvdata(cl->dev); + struct stm32_mbox *mb =3D container_of(cl, struct stm32_mbox, client); + struct stm32_rproc_tee *ddata =3D rproc->priv; + + queue_work(ddata->workqueue, &mb->vq_work); +} + +static void stm32_rproc_tee_free_mbox(struct rproc *rproc) +{ + struct stm32_rproc_tee *ddata =3D rproc->priv; + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(ddata->mb); i++) { + if (ddata->mb[i].chan) + mbox_free_channel(ddata->mb[i].chan); + ddata->mb[i].chan =3D NULL; + } +} + +static const struct stm32_mbox stm32_rproc_tee_mbox[MBOX_NB_MBX] =3D { + { + .name =3D STM32_MBX_VQ0, + .vq_id =3D STM32_MBX_VQ0_ID, + .client =3D { + .rx_callback =3D stm32_rproc_tee_mb_callback, + .tx_block =3D false, + }, + }, + { + .name =3D STM32_MBX_VQ1, + .vq_id =3D STM32_MBX_VQ1_ID, + .client =3D { + .rx_callback =3D stm32_rproc_tee_mb_callback, + .tx_block =3D false, + }, + }, + { + .name =3D STM32_MBX_SHUTDOWN, + .vq_id =3D -1, + .client =3D { + .tx_block =3D true, + .tx_done =3D NULL, + .tx_tout =3D 500, /* 500 ms time out */ + }, + }, +}; + +static int stm32_rproc_tee_request_mbox(struct rproc *rproc) +{ + struct stm32_rproc_tee *ddata =3D rproc->priv; + struct device *dev =3D &rproc->dev; + unsigned int i; + int j; + const unsigned char *name; + struct mbox_client *cl; + + /* Initialise mailbox structure table */ + memcpy(ddata->mb, stm32_rproc_tee_mbox, sizeof(stm32_rproc_tee_mbox)); + + for (i =3D 0; i < MBOX_NB_MBX; i++) { + name =3D ddata->mb[i].name; + + cl =3D &ddata->mb[i].client; + cl->dev =3D dev->parent; + + ddata->mb[i].chan =3D mbox_request_channel_byname(cl, name); + if (IS_ERR(ddata->mb[i].chan)) { + if (PTR_ERR(ddata->mb[i].chan) =3D=3D -EPROBE_DEFER) { + dev_err_probe(dev->parent, + PTR_ERR(ddata->mb[i].chan), + "failed to request mailbox %s\n", + name); + goto err_probe; + } + dev_info(dev, "mailbox %s mbox not used\n", name); + ddata->mb[i].chan =3D NULL; + } + if (ddata->mb[i].vq_id >=3D 0) { + INIT_WORK(&ddata->mb[i].vq_work, + stm32_rproc_tee_mb_vq_work); + } + } + + return 0; + +err_probe: + for (j =3D i - 1; j >=3D 0; j--) + if (ddata->mb[j].chan) { + mbox_free_channel(ddata->mb[j].chan); + ddata->mb[j].chan =3D NULL; + } + return -EPROBE_DEFER; +} + +static void stm32_rproc_tee_kick(struct rproc *rproc, int vqid) +{ + struct stm32_rproc_tee *ddata =3D rproc->priv; + unsigned int i; + int err; + + if (WARN_ON(vqid >=3D MBOX_NB_VQ)) + return; + + for (i =3D 0; i < MBOX_NB_MBX; i++) { + if (vqid !=3D ddata->mb[i].vq_id) + continue; + if (!ddata->mb[i].chan) + return; + err =3D mbox_send_message(ddata->mb[i].chan, "kick"); + if (err < 0) + dev_err(&rproc->dev, "%s: failed (%s, err:%d)\n", + __func__, ddata->mb[i].name, err); + return; + } +} + +static const struct of_device_id stm32_rproc_tee_match[] =3D { + { + .compatible =3D "st,stm32mp15-m4-tee", + .data =3D &stm32mp15_m4_dma_ranges, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, stm32_rproc_tee_match); + +static int stm32_rproc_tee_parse_dt(struct platform_device *pdev, + struct stm32_rproc_tee *ddata, + bool *auto_boot) +{ + struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; + int err, irq; + + irq =3D platform_get_irq_optional(pdev, 0); + if (irq =3D=3D -EPROBE_DEFER) + return irq; + + if (irq > 0) { + err =3D devm_request_irq(dev, irq, stm32_rproc_tee_wdg, 0, + dev_name(dev), pdev); + if (err) + return dev_err_probe(dev, err, + "failed to request wdg irq\n"); + + ddata->wdg_irq =3D irq; + + if (of_property_read_bool(np, "wakeup-source")) { + device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, irq); + } + + dev_info(dev, "wdg irq registered\n"); + } + + *auto_boot =3D of_property_read_bool(np, "st,auto-boot"); + + return 0; +} + +static int stm32_rproc_tee_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; + struct stm32_rproc_tee *ddata; + struct rproc *rproc; + bool auto_boot; + u32 proc_id; + int ret; + + ret =3D dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); + if (ret) + return ret; + + ret =3D of_property_read_u32(np, "reg", &proc_id); + if (ret) { + dev_err(dev, "invalid reg on %pOF\n", np); + return ret; + } + + ddata =3D devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + ret =3D stm32_rproc_tee_parse_dt(pdev, ddata, &auto_boot); + if (ret) + return ret; + + ret =3D rproc_tee_register(dev, &rproc, proc_id, auto_boot); + if (ret) + return dev_err_probe(dev, ret, "signed firmware not supported by TEE\n"); + + rproc->ops->prepare =3D stm32_rproc_tee_prepare; + rproc->ops->stop =3D stm32_rproc_tee_stop; + rproc->ops->kick =3D stm32_rproc_tee_kick; + + ddata =3D rproc->priv; + + ddata->ranges =3D device_get_match_data(&pdev->dev); + + rproc->has_iommu =3D false; + ddata->workqueue =3D create_workqueue(dev_name(dev)); + if (!ddata->workqueue) { + dev_err(dev, "cannot create workqueue\n"); + ret =3D -ENOMEM; + goto free_resources; + } + + platform_set_drvdata(pdev, rproc); + + ret =3D stm32_rproc_tee_request_mbox(rproc); + if (ret) + goto free_wkq; + + return 0; + +free_wkq: + destroy_workqueue(ddata->workqueue); +free_resources: + rproc_resource_cleanup(rproc); + if (device_may_wakeup(dev)) { + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); + } + rproc_tee_unregister(dev, rproc); + + return ret; +} + +static void stm32_rproc_tee_remove(struct platform_device *pdev) +{ + struct rproc *rproc =3D platform_get_drvdata(pdev); + struct stm32_rproc_tee *ddata =3D rproc->priv; + struct device *dev =3D &pdev->dev; + + stm32_rproc_tee_free_mbox(rproc); + destroy_workqueue(ddata->workqueue); + + if (device_may_wakeup(dev)) { + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); + } + + rproc_tee_unregister(dev, rproc); +} + +static int stm32_rproc_tee_suspend(struct device *dev) +{ + struct rproc *rproc =3D dev_get_drvdata(dev); + struct stm32_rproc_tee *ddata =3D rproc->priv; + + if (device_may_wakeup(dev)) + return enable_irq_wake(ddata->wdg_irq); + + return 0; +} + +static int stm32_rproc_tee_resume(struct device *dev) +{ + struct rproc *rproc =3D dev_get_drvdata(dev); + struct stm32_rproc_tee *ddata =3D rproc->priv; + + if (device_may_wakeup(dev)) + return disable_irq_wake(ddata->wdg_irq); + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(stm32_rproc_tee_pm_ops, + stm32_rproc_tee_suspend, stm32_rproc_tee_resume); + +static struct platform_driver stm32_rproc_tee_driver =3D { + .probe =3D stm32_rproc_tee_probe, + .remove =3D stm32_rproc_tee_remove, + .driver =3D { + .name =3D "stm32-rproc-tee", + .pm =3D pm_ptr(&stm32_rproc_tee_pm_ops), + .of_match_table =3D stm32_rproc_tee_match, + }, +}; +module_platform_driver(stm32_rproc_tee_driver); + +MODULE_DESCRIPTION("STM32 Remote Processor TEE Control Driver"); +MODULE_AUTHOR("Arnaud Pouliquen "); +MODULE_LICENSE("GPL"); + --=20 2.43.0