From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.84.71 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796222922; b=a5E4U8pG7G03u3i9YwCNx6SHR/RRLScG0ETRU0FH6BRbW+ilNHEtvsH4GOdkYQIEZnAg ZfZuRFY0NiwYtAq20xFS3fnvOuJQzDzJtwX+7VmT941GnPFRByHU+tcB8rIuoyzPuP6aO q1vgS/GldkIq27ev0tzWcfOYOpf2DsDljUcU1eazELZJY/wp7elCflPKMOlwU87OgC27L BVaV9nLeOotsrqeEq0gtrajS4czm3MQF4LnNhfpzVYZGui4JeHqPXeu+4Ij1GQo4+kiO2 AeJU/Hl/c4O5j7HBn7+cbI1fl/UYMJ2zQb1b6gYnV6wB2Bddv8Q7JxnEeJOQNCHamyw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222922; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:References:In-Reply-To:To:CC: X-Mailer:X-Originating-IP:X-ClientProxiedBy:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=NKA98dJ5yezjxePZG3LzFimqX4f5Pqy1tbslB9pz4Ts=; b=ru1IIiH83GtEVfreu+dMVjWwU2InJpvDF7yt6zaSVs2bqQ2YynIbDtKsOLvRbpW4loK2 Pli8TLHeaTAMA0S9IC2t3OLWNuP1ponmQuIdWkAXVJGLstA164PdoIaA4zDZmT1o68jf6 Azcvcg3otf9OiJAvj9DH/Ka8dlRAM7ei5pONiXdn0FklokRnWIX4g/6cbcSVFURFumCAe x6P79cVXBC+EMAVQI5InL1GDFN224yF+eTDLhkSQkQJxPGUO3YAnEHhsr8aBSP/o893MS 0ne/ByE0pzDOaa/YRaFXZQPz62lISlh/rZW5vzGiQ1cC+7y6Xn1e9Ro8KPjQcvQ//ew== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=ZejEXBBW; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.84.71 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11010071.outbound.protection.outlook.com [52.101.84.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52717606A695; Wed, 2 Dec 2026 14:48:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 52717606A695 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=ZejEXBBW ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R4owdHJLBYbce4aR8Xy67qCTL9NcDzvmT/ccGvktSoN3PVqh4DWgWzPZK3Ajg3iq6c2PkQewYIGWzw/p1+4nee2g/4Pt84CiLpvwKN5e1nIIcenhbBebqDFJMe5BtK+lrX9TJJk1IpyV/3h4fmjdWUfDdv9TJh8Tgyebi+LJ4dLCSaE0M34TTVnrAHTP4t3d50WqtjSJfBacwHPbQyG0+uPaEGrBQrZUUDXIaf5SHIyYMynyHw7Eew8vBJnWHf9LTxV50pbN9OxcLEoZD8IpAWolBxW7oFn2LvPvI06qwtCSlHD13yv8murK5P6RnXya/4aA79P+gJIv3APzw6xWqg== 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=NKA98dJ5yezjxePZG3LzFimqX4f5Pqy1tbslB9pz4Ts=; b=eEvG//pu930xIrGZZtisZYe6IoKV4rqvhJMNGJFhhTE7BzjWD4KzfGuOqrdMgsTIo+jdx+rg/lUFhxuGb9xds9YSWwmeuL13f3YthmFM46YNPaGolC8uamcCp6tY/rSQOOMeZ90d+tt/7KHR/J1JKzv3JYUZK8OtrURSXEBJpHUzBanpeLEw/tT/rI6aBRk0eGtMyRcoTLMSfcyar22YUG43vkqcAXtnQ3HE9OKhCAFgiXNWY2liKTt9B8IFgfF7BvXvZSwbflwaDoRimugBdhR8WkKoEpwHlxwiPCNMziNo9xPj3I5QR9LQZu9k0AtxcqJUEuDQvXfKrJ1quZcyMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.60) smtp.rcpttodomain=pengutronix.de smtp.mailfrom=foss.st.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=foss.st.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NKA98dJ5yezjxePZG3LzFimqX4f5Pqy1tbslB9pz4Ts=; b=ZejEXBBWs4iNvz9CR+J3//fsMzSeKWOVCBC4B/d1Sqba6HESSKUwmaVLruoJbRykj0UFHIzok7E89ogz7nFYWakL0QANGDxlzML0JUdhGvgJwzNslFvN8N609cvZjl+W1no3HrwvARuPJNn+t6IChz8VHwzqbYSaeWcx7XIPl7uJ1k2Q1Hq19MdW6PrxmG7zWBjfkXarFrNpBiy46OeQ8akI8cv/3VslySO4CS+03k2Gsg1FV6kED4+EXTaqJSFl/gHjWOeQPIqxb8m2CU3gRM6CxPrbGXlkc1iHJzDP2dix/GWod0hRwkIe0bujEcH6h0Gthf5GhFBlvO+b+OQbPg== Received: from AM6PR05CA0024.eurprd05.prod.outlook.com (2603:10a6:20b:56::15) by PAXSPRMB0021.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:285::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 14:48:35 +0000 Received: from CPH1EPF0000052B.eurprd05.prod.outlook.com (2603:10a6:20b:56:cafe::38) by AM6PR05CA0024.outlook.office365.com (2603:10a6:20b:56::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Wed, 2 Dec 2026 14:48:35 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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 CPH1EPF0000052B.mail.protection.outlook.com (10.167.241.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 14:48:35 +0000 Received: from STKDAG1NODE2.st.com (10.75.128.133) by smtpO365.st.com (10.250.44.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 15:49:54 +0100 Received: from localhost (10.48.87.127) by STKDAG1NODE2.st.com (10.75.128.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 15:48:34 +0100 From: Arnaud Pouliquen Date: Wed, 2 Dec 2026 15:48:18 +0100 Subject: [PATCH v23 2/6] remoteproc: core: Introduce rproc_pa_to_va helper X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261202-rproc_tee_v23-b4-v23-2-bac8e36eb405@foss.st.com> References: <20261202-rproc_tee_v23-b4-v23-0-bac8e36eb405@foss.st.com> In-Reply-To: <20261202-rproc_tee_v23-b4-v23-0-bac8e36eb405@foss.st.com> To: Bjorn Andersson , Mathieu Poirier , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Maxime Coquelin" , Alexandre Torgue , Fabien Dessenne , Arnaud Pouliquen , Philipp Zabel CC: , , , , , "Jens Wiklander" , X-Mailer: b4 0.13.0 X-ClientProxiedBy: STKCAS1NODE1.st.com (10.75.128.134) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CPH1EPF0000052B:EE_|PAXSPRMB0021:EE_ X-MS-Office365-Filtering-Correlation-Id: 0da53656-45cd-48ad-8407-08df508357f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|1800799024|23010399003|36860700016|11063799006|6133799003|261009223027099003|18002099003|22082099003|921020|10067099003|56012099006|261102123227099003|261021121427099003|261102130727099003|261028144727099003|261026121527099003|261026140227099003|261022105027099003|261022075727099003; X-Microsoft-Antispam-Message-Info: uxa2o2Hp3DBk968kBb0cPMjJZ0m538IzBJYGXgdlh0qDD2ivvBJJhx+Fyr0pYGpzzkvcYjURkoGPlGTjJjtsKT6MT2u6k+6IaJRvYEFUXbWynNz0KRdFDMfRQtGCqAssPvzpVgvEiM6qkOwfYTf2AMnWqPBnCXKmVF00k5J+dM74r75qNFi02yovvEwG7Qpg5iwMxpkmOPI/vtMVHtoe9lorSokUbAc9mRnNX2R1gqUqfe5HyBb1TQTJVjT1wuYaAQCnOi1sNBbWFAqPp9hzvLxPfLIgxvZ4ie7RB/D2ha1uZhB+jlz69fHFjVbkw6oOYvumFCmNJcC136IMEdrZPfkUfpZcFz+ZN9dmC8EUwtFt3VeCXgH53jmwKvpm+odf+NFT2qOkaUDxID3yzfkYiNgqCLk3EUSqebasH0Hpu4M0+Brz7k25cCV7RcYnHMLvLJylo/xNTorMw+V8TnIbXRXlHKyHdwVh9BhU1TK2GjxkVLp4X4stfPY23QLUVTe3rxfF5ijXjw/R/kA+wrvnImGe/QHOlmV8KJ2qIMxBGekldqHiLVxBWHPan4paVmTIEvaxrtMjV9S9x2iXwIr6/GSQfAHn39NwbpuP0oEhJNSxjgBl03OjxZPYVjR+LyudeJTE5eXzbOxSnK3UXmDQsgUlPAPssDCBkpLFYO6awMTiF5yrA3j/FK0MQV4er8TS2QZMOw1vfWgbWm7z5LKNX4dkuSrzctWbQLgGSgDIF+ihxKVc07cEhMjdQ3SklOua 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)(82310400026)(376014)(1800799024)(23010399003)(36860700016)(11063799006)(6133799003)(261009223027099003)(18002099003)(22082099003)(921020)(10067099003)(56012099006)(261102123227099003)(261021121427099003)(261102130727099003)(261028144727099003)(261026121527099003)(261026140227099003)(261022105027099003)(261022075727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MX+jEqjWPLnsgklbyX3GUR+ZuNuNzRAA3obTcg37cj/bxklXXFO36CNxxuF+dmqpAsFP6KXAX/2IeTbMYN0rHF0LIm7CxbrhS+8IhsDS0mONIsowZbe1sEdKkNJ64KuEbJJUOZotFUQIanRZR3nH49qOV8P4fLTw4YJbSUGGV5mlABcHG1SKGWc3Vnw+caVpxzmmRigPlppBm3ueWhvc2ciHblmkOsrmjiYV1HeJ0HbB9auaF+yFyMho94tXb/mgbRtm1SC4/znj2KfUooRrq/NeCf5wtdtSLSMO+vDGZt5noe6qjOqYL1lFyFbrDO/wx5mlIz4cXRCu1wMTfm9D7ig4LQ2BnNyQ3fMO3weHmyz9lzcBLK8Ff1qPfgXw0JdZiKybHqrjvDbZi54Od2NuXYo4ov/qOQTI34Uh/F9ASwlezTIsQtty9J3MPAc/Wizj X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 14:48:35.5378 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0da53656-45cd-48ad-8407-08df508357f3 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: CPH1EPF0000052B.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXSPRMB0021 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 --- V23 updates: - use phys_addr_t for offset to avoid truncation with LPAE V22 updates: - use size_t for offset and remove its comparaison with 0 --- drivers/remoteproc/remoteproc_core.c | 50 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 1 + 2 files changed, 51 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 23f8539a99bd..e31c6b209424 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -225,6 +225,56 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) } EXPORT_SYMBOL(rproc_da_to_va); +/** + * rproc_pa_to_va() - lookup the kernel virtual address for a physical address 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 @pa is iomapped memory + * + * This function is a helper function similar to rproc_da_to_va() but it deals 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 = NULL; + phys_addr_t offset; + + list_for_each_entry(carveout, &rproc->carveouts, node) { + /* Verify that carveout is allocated */ + if (!carveout->va) + continue; + + /* try next carveout if pa is too small */ + if (pa < carveout->dma) + continue; + + offset = pa - carveout->dma; + + /* try next carveout if pa is too large */ + if (offset > carveout->len) + continue; + + if (len > carveout->len - offset) + continue; + + ptr = carveout->va + offset; + + if (is_iomem) + *is_iomem = 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 00019b1895e6..1acfd1bf25dd 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -405,6 +405,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_iomem); +void *rproc_pa_to_va(struct rproc *rproc, phys_addr_t pa, size_t len, bool *is_iomem); /* from remoteproc_coredump.c */ void rproc_coredump_cleanup(struct rproc *rproc); -- 2.43.0