From patchwork Thu Sep 26 16:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13813523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E03DECDE024 for ; Thu, 26 Sep 2024 16:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x0T16mVkKkqfYTm9px2P9XDgOfTuQA4CE/TaNDgxwlA=; b=b3TMMGBbs5GDA+eGP+GkoHrwxe 1kcf/U/EmomPahzzXM20r8pKUbh7o4RrFJpyyimq/VPNmXbOmHZ7DNicsMdTUYpW3FSIdHLwv1Iyq nTuoiHEhgVcjZ4AAErHr1l83WvQi84vO40+PKUF1o+6A7U9OoeN8/J9VCmxuGwnrhgcyG9Ek2G84c VBXb7wq2qm3FDF0mqMWNErqWsKYmjTbuP/Rn1tbq9eu+Sx+KIpQThM6h36XdPq1HUXmIU/S2wAfXx 2ryZzJdKjAxpB5sggF1KpQNHXZod50jq6LG5rJD2ORWnE2jOv1VcP8uJ5VoRX0yrMBLl6Kcl3KzjK tLaxl0mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1strh3-00000008vxT-2yZf; Thu, 26 Sep 2024 16:50:17 +0000 Received: from mail-northeuropeazlp170110001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1strem-00000008vZr-1GTu for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:47:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iAw9EVs0h750zTOtLGN0jplwkXod6/DiCVqGjlzrn0QdYFVfmq9+YWYPEoqpPb4RVPE17v13DdnwHmCZlDVIzMBl/WtshVzbuMvcZ48pmQZfdDoIQuDqAW4t8Tr2xdCwxA0ckqRs8bPiyOe6FrWHQQga51eyp0EBPGhRjDiCKZRwbChHhQqCFRO+k1ix9D4tMhOlZXkk84wFYzdaa2HPQq38P7WfDkv42F4Mz/v2+fmrCut0HozR6781blp+lae4/rnGLTNdrEc0x5lNw7oX61DbYLmMbgeECDk9EH8K0jFU8c1XlNW652ehq44SIbYih1nKzZSrW/UGx3pcJaeB+Q== 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=x0T16mVkKkqfYTm9px2P9XDgOfTuQA4CE/TaNDgxwlA=; b=VAS/1N2OPI1bMh83ckn1kdOJEws4yJ62tf6IuJYX7DfcQsYLQrnN6U8+SZoLlrvHke50HdfbF9/AFGXBK44eD/5OP3POQvUv7043mRqIcxqaBr+gS0OhQJWu3M408f+amRa7jeY2CPqz8vjcwHkMlLuGb8wcDzbofDNlQBi4lTV1Cj+Zr7TDinitduhiGD+25UzhrhyrffSwpLUV3UJXhikKfNORkbGC8h5yT0bSMixDGPjEzoPtrV7TEIiwzhdcKu0Un34yJ8j+2HIpOZ9HmdtFnHDugp+S2tI91e4ZHc9asGzwMDSUOOSYbaqrHnmdatJsJ1cP3/qYiVI2IvHS/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x0T16mVkKkqfYTm9px2P9XDgOfTuQA4CE/TaNDgxwlA=; b=Ps7NyoBJsGtEA+7nmvN3VoBUdhmOoJ3bG/VKTDucJnmFxxr4qQ6J70DpRqHdR9DR8/RYRURVrW+h/WFZTO3qEZreEd6wTN35XRCy8PaOjVqFJerw4eEL0oT79SBqqgI4URX0D3V+hXiU3D6tAxlA3iByAHXUDV5pHkWUrH/59sJQqgnAS2tuJoCVm51fLVeVBinKTm9lZykFrWo+sw2IbWe9J5nRp+vfOoL9Z5/zQs+nnt3dO1me/FCe+w57ZTR8XFQmlvKvuwam5j1Hf3SrQmbDZqqFmoGCkJ58b1kw4ogEL5yk9IX42haw8CMO8gsF9ErXaB8/+cIoqRiWCsBw0A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AS8PR04MB7768.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Thu, 26 Sep 2024 16:47:42 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7982.022; Thu, 26 Sep 2024 16:47:42 +0000 From: Frank Li Date: Thu, 26 Sep 2024 12:47:13 -0400 Subject: [PATCH v2 1/3] of: address: Add cpu_untranslate_addr to struct of_pci_range Message-Id: <20240926-pci_fixup_addr-v2-1-e4524541edf4@nxp.com> References: <20240926-pci_fixup_addr-v2-0-e4524541edf4@nxp.com> In-Reply-To: <20240926-pci_fixup_addr-v2-0-e4524541edf4@nxp.com> To: Rob Herring , Saravana Kannan , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1727369253; l=3905; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=9ldyp6HrhRbm9ZHIGYVTyAdfKVy/p8x2cPRL2TPnOiE=; b=Ri+NQMKn6WwChg/IavsYeJu9oEgesV3Jj3CUa+qyQHI/2Wj6TSB3CsoEzRgpvRd7Gb7CNxYXE LYhdcWmxpB5BS3SKKdSb40ic36t0Cdd5hiyex6UuuPUpx03DjaiHI3M X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0091.namprd05.prod.outlook.com (2603:10b6:a03:334::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: 46199f4b-7b8a-46bd-2bc1-08dcde4af09e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1ohCB4RcmNhvV0j0KwIx7YcWVZq0Eh6?= =?utf-8?q?9k196NcaTsCn4gPJWmjZ1NEMrqCuKQIAQSmlk7zljcc6UJtm/hKOLOTDzZt6UiHVj?= =?utf-8?q?ooTBD4WPcIxERS4CPZMuh4w0xqjaLg1Ms8+0+5rRUaV+SDvGyPK9E4xXeGsNaqVzM?= =?utf-8?q?5c37iLokioprPuaTgqJEud2Z0Ik4/qzmk5Tckb3VdkAorYRW57XOxU0TJDF8TOl9e?= =?utf-8?q?mFssfvim/RPXd7Nw9nrJLCsbLKlB/C8oM1gCk8gNAMp3I/NG0XAX/yP3F9fsqu3io?= =?utf-8?q?E4CqjqFVlGNH7PqA44qUs3e0cuvDXTpqzykUnwWVxeLd1s0MFZeins0ljWxzkOA+R?= =?utf-8?q?QqTjslcOIlH4whH1zATMY7rvo5PnRvCQP8OSOqG/HnkAdDrxUYTIO6YyqPC/DePnK?= =?utf-8?q?uuuzMCMvahwlyaFCkcp3QzbkYtXnClSO9hePHg6TF8HusyB5IWrOQa6UxuUKiB78Z?= =?utf-8?q?JE0rHmA4+DM81h+w+/SWvLskR4E9F/gt/eF21xy09J5o2zlN3u2VQ9RWpzfngKpKe?= =?utf-8?q?gi3pfwK1NiQz9T9jmLJkZd8KsbOwH+qZCFoGI0sIT1BeJ6OW6HvDs2Pv8XYXCLnPk?= =?utf-8?q?r7PAOTeB5yjm810TAU5mjtUC+sdY99hdkmeOuU5y58hNb0baNZmH5Kiq6QXEWm1+W?= =?utf-8?q?QAUr8J1IeNkuWzCDAvBrxAcD9SQB7ZmMzaAtQGTeBbxygCz82AhtNU2IBmu6EhC1F?= =?utf-8?q?xNNT2Ic/X5c4tMmhtCSO8XF7iczpvkcAvzqhOcZqz1of8rtIUBaIVqJZCf/1EqinX?= =?utf-8?q?zxzY4P17+Hk3S5M5ynPFf9hK0MqoILvRtfMXa5FIIDrXxcYXsOzrg2HvcDxi+/983?= =?utf-8?q?L0ja2+kIEOwkvkW0eQDg8u4acKQjbtOSTKRL8NiflOAc9HNySLRBDj5/W1TtXUvSq?= =?utf-8?q?8kemIdPFSKhDWEP5/FADBTboCOrspSnYdA1WBla0STwuY9EkP27DrrGfzd1Apidin?= =?utf-8?q?mctcQMRh/MEPL87wun14BNgMFmrHS0As9CV8OEn/9ryMahOZ0ptto31Vjb4fLxoy1?= =?utf-8?q?AqKRg/YWigrZPMtVDS4lPCw0A43dEd0pPOM/zZBIAYwqA1I0Lzt3JJJAKJKjUFO4F?= =?utf-8?q?br1mmndr/oeQNSuvSbDLhKBKDsnw2NCzSZP0yOQ7eyyo3Ybyi+UjSJCWuqcahLvzo?= =?utf-8?q?wP8S0mCBh1AEu38ZzC/42oSjgCYBXrbv6BtcqB9Mi0rBto0VHWuJ0DHQZ3xyuFRQb?= =?utf-8?q?dKYn/xgzQJ2GOj0NNcF3QEIb9DewM28v5vsVghaskwSilNDYuFjTsvpeh8rAzKbzN?= =?utf-8?q?ur+iD0pjtww5Qv2Cysyv9FyNBuEhACj75GcPc0/TSVWxnykuDprqyKYpv474GdHQk?= =?utf-8?q?rviN/iCbs3+FHlGbhOeKG7zcN8enRktLcf42wkqiRmc4QVad9TE1JjI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?uE7TCQnBw5E7kjCFHzpO8EQag7Sq?= =?utf-8?q?As8XfPyEEnw+GbY1ntSVT338J0QNOS9+niZ8MJ72HNxTiNYN8HLLQ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oOaL1o3SOhnFQ?= =?utf-8?q?XYk+eJD6lScZZR7PVOqJ6FwNEEv/lWeGEbyRXYikryIXMXXpOq3VR1BZXxODG0Sl9?= =?utf-8?q?/Ux/gPVb2Mh9Tl/8NyzEbIo17e8i2R/IPCBe/WgupP4BXeBKcrwhJjWUZ3zQwBlbQ?= =?utf-8?q?4J5+C9a2C7nOduZBAzk6SDMyNBIH8KAOvaKna2mSZ3XIX49+mMt8e5yRTurbAlW4t?= =?utf-8?q?50mhKMJumhemxcbUsHgBC8+SuGzXVGbZwiaGYMuMbTFQM5KcIG03bIOOIvRBdiGiV?= =?utf-8?q?Y6vGadk7tqeUP5OoqBPbBdmTj05dpIlpDvKrXSc0qFPq2U5VF2aq3FvQWzQNSm67w?= =?utf-8?q?60bEYsn8NGb0KF50duyQTQL1EeegNx8lKtOTy6RM7XQ7+f9OrBQ+ZES9TqaTtJ2IU?= =?utf-8?q?rekAWd9P/YHxpsoPlejkve3BYe0esw2+isxx7E8VunwXkmIACOjyPERLI3Al8Qhd9?= =?utf-8?q?BE3XVEaBIB12d64qPi/Ocx+cjoQXu0BMhySIa65vxwtGj7cIxAnmcRB5smudmPwvj?= =?utf-8?q?ubDyRByGDvDtfDA2rgf7I+cAURpsBYPtGzsBT7cWm4pG9ZSYjvvUHPoLLuN/xvRiL?= =?utf-8?q?JIzuKf6gyWFN?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46199f4b-7b8a-46bd-2bc1-08dcde4af09e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2024 16:47:42.6725 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qEVlziymjTYTVruhCUzsAOnVrgMBtz3f+9LHqeDe1Gm79T6yTEImSWIjGg3IKW6Jtluig1zKxrTXfKmrU1Ducg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7768 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_094756_368839_0849C295 X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce field 'cpu_untranslate_addr' in of_pci_range to retrieve untranslated CPU address information. This is required for hardware like i.MX8QXP to configure the PCIe controller ATU and eliminate the need for workaround address fixups in drivers. Currently, many drivers use hardcoded CPU addresses for fixups, but this information is already described in the Device Tree. With correct hardware descriptions, such fixups can be removed. ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ IA: 0x8ff0_0000 │ │ │ CPU ├───►│ BUS ├─────────────────┐ │ PCI │ └─────┘ │ │ IA: 0x8ff8_0000 │ │ │ CPU Addr │ Fabric ├─────────────┐ │ │ Controller │ 0x7000_0000 │ │ │ │ │ │ │ │ │ │ │ │ PCI Addr │ │ │ └──► CfgSpace ─┼────────────► │ ├─────────┐ │ │ │ 0 │ │ │ │ │ │ └─────────┘ │ └──────► IOSpace ─┼────────────► │ │ │ 0 │ │ │ └──────────► MemSpace ─┼────────────► IA: 0x8000_0000 │ │ 0x8000_0000 └────────────┘ bus@5f000000 { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges = <0x5f000000 0x0 0x5f000000 0x21000000>, <0x80000000 0x0 0x70000000 0x10000000>; pcieb: pcie@5f010000 { compatible = "fsl,imx8q-pcie"; reg = <0x5f010000 0x10000>, <0x8ff00000 0x80000>; reg-names = "dbi", "config"; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; bus-range = <0x00 0xff>; ranges = <0x81000000 0 0x00000000 0x8ff80000 0 0x00010000>, <0x82000000 0 0x80000000 0x80000000 0 0x0ff00000>; ... }; }; 'cpu_untranslate_addr' in of_pci_range can indicate above diagram IA address information. Signed-off-by: Frank Li Reviewed-by: Rob Herring (Arm) --- Change from v1 to v2 - add cpu_untranslate_addr in of_pci_range, instead adding new API. --- drivers/of/address.c | 2 ++ include/linux/of_address.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 286f0c161e332..f4cb82f5313cf 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -811,6 +811,8 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, else range->cpu_addr = of_translate_address(parser->node, parser->range + na); + + range->cpu_untranslate_addr = of_read_number(parser->range + na, parser->pna); range->size = of_read_number(parser->range + parser->pna + na, ns); parser->range += np; diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 26a19daf0d092..0683ce0c07f68 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -26,6 +26,7 @@ struct of_pci_range { u64 bus_addr; }; u64 cpu_addr; + u64 cpu_untranslate_addr; u64 size; u32 flags; };