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: 13813514 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012030.outbound.protection.outlook.com [52.101.66.30]) (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 5ABA715B0FA; Thu, 26 Sep 2024 16:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369271; cv=fail; b=gMe9uAH16ZGZRtfWVGajN0K20qNCPF8qZ+4aBh45GdnqxkFBVVeQek6PVIEpelqqYTtG49JAut9NRbPGC39nta9pyZzH8fHtSoyzr+/yajbfEjAmJVgL9UFCQ3JvjTu+wtBQrw7fRJvMjVVXbc7x34RL1dV/+VqWHc0khVjUXfU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369271; c=relaxed/simple; bh=9ldyp6HrhRbm9ZHIGYVTyAdfKVy/p8x2cPRL2TPnOiE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=d1IBs9jkCXIS5HN4E2k7ezEuIytnUmp11fLbpbACHnMZrx/1CLEdUhDeW/kKA3D+FG+kcY6TrB3TpPVkPZ0f420Vn5biC/ibXZGVQhaAmQZ/S5m4bi5FYPmuPvEDUtJv75bA989bb8z9KhGmGQ4qrPb6sEZNY+zwiA4lUzM2New= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Ps7NyoBJ; arc=fail smtp.client-ip=52.101.66.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ps7NyoBJ" 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) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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+niZ8MJ72HNxTiNYN8H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h7U7oOaL1o3SOhnFQ?= =?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 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; }; From patchwork Thu Sep 26 16:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13813515 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013002.outbound.protection.outlook.com [52.101.67.2]) (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 21A1B15CD60; Thu, 26 Sep 2024 16:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.2 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369276; cv=fail; b=sfLIl1/1/FTvqqJpeWZFP5a/syhXa60pLyeHOeh/qBPKV7GOBQpY0fk51/X2VVAWGSJyTB/rhrVNXa91CMYkbHTGeU1rTJTwqn0xUFla6YfjuP881/zTOVzbceEeYYJQ+LlHh9tj1F4jVjm4TBaF6WYi5v+zISDp9MlmsawT/DA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369276; c=relaxed/simple; bh=9UjixEiIWjU2Rw1R//IY4okKQq5e+4Lm/9kG3kM4QOQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=RHoJZ/ad0jxUxGisaHzEMyb9M60vuTdp/kIwcMvwx97fK4g69T+mjsR4wlxusk7WsNvXc9ZDPAl7xBvL29fGlRx5r1QMohIX66iMT4tusFooCXtlkw4EndYm27UMb1hxxwnCKjY8QykdA5B9T7xFMMsku2strwVKO/z8VPfmGBY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=dINAPUZV; arc=fail smtp.client-ip=52.101.67.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="dINAPUZV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YX3YkgoLnrL4/vDW0eMDcIQ0PUvwwa6WdoTswSv7HXzGfWeWx00Wcm+yX6CZ2/hcQkZuTWPzBA1hzJYjwwk21/PI5tCPtikXadlNSMUCuoSCB9IXgTD3tfsGa8Rs0OWQdGAYGPN0LgObawCiR2o5gIn7GSBndSGYMozFgOMOzzB4cysIH6L8vymuWaSTJxmGXPZbk5UNJscp26Niud90pIgYrvx//acv2v7HANPxDWbYvf3m/5fpa6ur125Wuma6wDCv/cJrNfW0r5e59GFmYVsJg1UYyWh1UF8M+F6oDu/hLEo1Is0Pn/VThfxHVZ0Jk7VQMA5ZLrYjA5L09uYu3g== 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=aUBWLRM4foMjxqfM+aG3qnhroBHRstX4Wda+VTgndrI=; b=H7kNMMAn6of/VkC4Gt1miqhZo/0CHRGiMay3xwT6eHBtIaWFFQsBo7hNViHMi8JeRsBCgL0Vxxh39Vttiyi6Wyaq1Y3dXb5HQfS+kZWxX4wO8Jf0Sa4heCIbCppYslpuHUYs6hWQ0b1xLFR0iGI1bze//RxKO9RICPLQETWGSGqHrPtbtYhJGpnfxRKX8I7JTM5vCI+de5PIAZWDPPuLLMuupvLHT0xyw0MWcwSdLlR8nD09zyfmGpvAO9lBVfUFcwzGaBHSDizxoNlJxB/KQMSotGjP4nSZYHjaAEWDW74JshRZ4jo5NzhLjm5pyql+Nl6FDyWlodpzFJDMd0yN2g== 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=aUBWLRM4foMjxqfM+aG3qnhroBHRstX4Wda+VTgndrI=; b=dINAPUZVZAg8jJLagqhjnJ9iSUKoASqrgN9KbVlRBHU4iJu/Yo5XgVw3PcixttcVCcNoikBeABGsSZEx3RfGR2BWQutadizOeFCImUZntSQmHrI2uY+OC6klvK4IMozPhFHZto+kQ2llq9T8httyaTqG5lI63s1Qs222HESRanGfG/e4vjlgKrqaDdOdhV/Cwe/JsAN3kLFHivV+aidFM42Q52rLZv3AKKhvcDu71CgzXgKyd61FmA8ysMd9MubV3Y9tkKiclwbIzrAjWUD/RiQCEHF4xx7L1jQ8cPp0FZ6dJZGTTFHntyTtubVi3cc2QBV4UjDpg9AH1Y5rXveDkg== 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:47 +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:47 +0000 From: Frank Li Date: Thu, 26 Sep 2024 12:47:14 -0400 Subject: [PATCH v2 2/3] PCI: dwc: Using cpu_untranslate_addr in of_range to eliminate cpu_addr_fixup() Message-Id: <20240926-pci_fixup_addr-v2-2-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=6330; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=9UjixEiIWjU2Rw1R//IY4okKQq5e+4Lm/9kG3kM4QOQ=; b=q9h9KFax1bOFqYOQT9j41i+XoLB60/QqkG3o6i3uWdyqfh4+ocMXLrofzpIpfprWxamA4TAwY r+alQ/+SJAwDNmS4W3Njt7ovEv5qmQudOSNVvuxrDiFy0mDhTRtR05s 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) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b0b3112-1ef3-4863-f5c0-08dcde4af372 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?2RRLzLXgAd/gMvAO0PbyN3rod46ncc/?= =?utf-8?q?uFmY21Vw7Vf7J36x4t8byAFQnuBNB1rlxraIBc/LCjvaWrc6J66RxDqFwL+XWdqX6?= =?utf-8?q?A19UgdxL6PIY9bcsOgUhPY41+n2sOUorXKwrx3tQNO683r7kUzMpL5YQ9mpwdzDTT?= =?utf-8?q?kucVn1GgU3H/AGHRO7XdVGk0WFMwlc40rve/Io0UdKpsa9zV6gb9CRwgXqORfuJSU?= =?utf-8?q?pB4z5jfgPKIuXTLXzoy5hKLTgQ8OBnSWiqq33UZcwAbxb7o7tfnLLb3ryT0vHlSEo?= =?utf-8?q?V2HPTVELTUkaSO4I1u40rP5toPpR0E3ikWOpvcPxlocNqSfEQFHCAe3hd1Nh9+e4t?= =?utf-8?q?Fkw42r24b3PSSN3caJK87DfwJLHEuchxijTgImQdjuI6XtWsbtC2yLijEOG6e/T5A?= =?utf-8?q?Pz/+r3e130yv7yvDEn/Cr/RXPBp5uozB3NHjlT2GRTir2st3+0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Kg2cSvO8?= =?utf-8?q?aVBDk8sa+JqYy41bBKD8Uot3PQnYDv0qdw+qLpDCw0W+VEzxhHl7/HM=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?S0onaC1en3prQ7LkFQL1cMa2gEz2?= =?utf-8?q?w+zToXNBAJ30OCCZl3t65qahI4qwbmCK02BpSPMwVfUCAidYTv5Bque7YVvBUjKgQ?= =?utf-8?q?+BrkqCa/hyWWoal2toj5JuGqrQo9H1mmhWVbiGBL9xhY3bnH/DMj44Xqr9iQwaEG0?= =?utf-8?q?qxdU4cGFOQHYp3h6ZxlDt0cY3Aewv6Hz8D5p/8FG+hcFGxu3DSQTWSYKJWtNk/yIb?= =?utf-8?q?Q2gw5oY0lBsZBgBlonmDWYecJiMCi4pIU+kMkOd70l4sYE8Wjqz24oNd6WDJ9mOtY?= =?utf-8?q?Tyo5uqAk9qO4P0c5aLhFdCSyPg2lpplFg9qtJHhokWR3TKkd7uMPXW05bq8QKM36V?= =?utf-8?q?URvTskjbIPD60xIib8RoMx4ei/0O2UJK87Evm8VYYkbl3x4ebeVCh6hix6CKS+h5y?= =?utf-8?q?2gDUdsuHF9xEeuHath11ZPF3xOFUkYF7z6lY4mUD39nCppPZ7I/aZOqHvzvHSsrlU?= =?utf-8?q?ZEUYv+8JSvnTP7BSvUBpxi9iGWP5rUyfCgoQcH+rgvn8pIEDxNBq7RfOZ5owkstLW?= =?utf-8?q?BVT1PVk50otbikg3bEUdj44UpoPF9lx5TngExB0SS/VPNe1mj6DkkwRP9B52i2BDF?= =?utf-8?q?Rx+osvLZVq8cmEvbJdt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ZjjvfW9n0OFe8BUONNX+wPMDtEvO0Jj8GxcU8nUtr?= =?utf-8?q?F6ZQwU4lqmLg?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b0b3112-1ef3-4863-f5c0-08dcde4af372 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:47.4004 (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: FIQW7J5AEGVscQ4iCnuFX78Jk1gedLLPgkobYdQUl7asNhTZbzqZHr4GnObPZ+xHjh/zwIvqRMRsR98ZTY1xJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7768 cpu_untranslate_addr in struct of_range can indicate address information just ahead of PCIe controller. Most system it is the same as CPU address, but some hardware like i.MX8QXP convert it to difference address by bus fabric. See below diagram: ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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>; 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>; ... }; }; Term 'IA' here means the address just before PCIe controller. After ATU use this IA instead CPU address, cpu_addr_fixup() can be removed. Signed-off-by: Frank Li --- Change from v1 to v2 - update because patch1 change get untranslate address method. - add using_dtbus_info in case break back compatibility for exited platform. --- drivers/pci/controller/dwc/pcie-designware-host.c | 42 +++++++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 8 +++++ 2 files changed, 50 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 3e41865c72904..95b927efb5e46 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -418,6 +418,34 @@ static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp) } } +static int dw_pcie_get_untranslate_addr(struct dw_pcie *pci, resource_size_t pci_addr, + resource_size_t *i_addr) +{ + struct device *dev = pci->dev; + struct device_node *np = dev->of_node; + struct of_range_parser parser; + struct of_range range; + int ret; + + if (!pci->using_dtbus_info) { + *i_addr = pci_addr; + return 0; + } + + ret = of_range_parser_init(&parser, np); + if (ret) + return ret; + + for_each_of_pci_range(&parser, &range) { + if (pci_addr == range.bus_addr) { + *i_addr = range.cpu_untranslate_addr; + break; + } + } + + return 0; +} + int dw_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -427,6 +455,7 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) struct resource_entry *win; struct pci_host_bridge *bridge; struct resource *res; + int index; int ret; raw_spin_lock_init(&pp->lock); @@ -440,6 +469,13 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) pp->cfg0_size = resource_size(res); pp->cfg0_base = res->start; + if (pci->using_dtbus_info) { + index = of_property_match_string(np, "reg-names", "config"); + if (index < 0) + return -EINVAL; + of_property_read_reg(np, index, &pp->cfg0_base, NULL); + } + pp->va_cfg0_base = devm_pci_remap_cfg_resource(dev, res); if (IS_ERR(pp->va_cfg0_base)) return PTR_ERR(pp->va_cfg0_base); @@ -462,6 +498,9 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) pp->io_base = pci_pio_to_address(win->res->start); } + if (dw_pcie_get_untranslate_addr(pci, pp->io_bus_addr, &pp->io_base)) + return -ENODEV; + /* Set default bus ops */ bridge->ops = &dw_pcie_ops; bridge->child_ops = &dw_child_pcie_ops; @@ -733,6 +772,9 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) atu.cpu_addr = entry->res->start; atu.pci_addr = entry->res->start - entry->offset; + if (dw_pcie_get_untranslate_addr(pci, atu.pci_addr, &atu.cpu_addr)) + return -EINVAL; + /* Adjust iATU size if MSG TLP region was allocated before */ if (pp->msg_res && pp->msg_res->parent == entry->res) atu.size = resource_size(entry->res) - diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index c189781524fb8..e22d32b5a5f19 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -464,6 +464,14 @@ struct dw_pcie { struct reset_control_bulk_data core_rsts[DW_PCIE_NUM_CORE_RSTS]; struct gpio_desc *pe_rst; bool suspended; + /* + * Use device tree 'ranges' property of bus node instead using + * cpu_addr_fixup(). Some old platform dts 'ranges' in bus node may not + * reflect real hardware's behavior. In case break these platform back + * compatibility, add below flags. Set it true if dts already correct + * indicate bus fabric address convert. + */ + bool using_dtbus_info; }; #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp) From patchwork Thu Sep 26 16:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13813516 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011026.outbound.protection.outlook.com [52.101.65.26]) (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 0531E15ECD5; Thu, 26 Sep 2024 16:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.26 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369282; cv=fail; b=A+wAIe/Y0ZgfuEDARsT4o2ahWVvYYuLVrAfyn9OmKfGrE1qJNKltKFDJGinFi62Kt4BXYON7CAn30crXg7J0T1nq/yrVO0dweN/SF6Gni6RXXEyL6NKJhYo2eSvhr4itJy27cP9AF8A16qYJM0aF2xgNtDplPws+k6y/bqrlNSk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369282; c=relaxed/simple; bh=4/d0yg3ZdSKNs2s1itIqRF0QpsFqrvue8dPnBf8tBgc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=X/ClUE5IT2MM7VUFKCx+r+Kfk0cSYz06ODq8uSfT3j/lDkxw+My8HlDj/OuHktk2Dg6dAI7+PmA2tlUZKc3wCQKFcKAh0baJqdagDBy54QmHdSE/RIIuufImODGZVoNovgwoxn8OkEYn5yyBsYpIDiqSD2QlyxiKbod8VFW/jkY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Tl8R6/YS; arc=fail smtp.client-ip=52.101.65.26 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Tl8R6/YS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tisRnGIQnMEjIuOaBsQ4+JC46vxaUkiB1lVQ4YD9Qgzf1KWCIWuwLO5VlgczObOsNOSDINBnc8rKHPxPws0gD7TgkVpUd01Q7kYmto60zN/QDlDL0hbOtEiHLXp7LxKcwhreBWW8Ta0hTJb/WSSWQUSdQik3/nlr+E4zJerhF/pImBVDIyBv/LsevLtzA0EIIrXls2JJ7jMOjsYdDO7hTeVgJOP/O/5W2R6hjiZOdqgR5XAOg+fpDOxqUhCYpLLs+RyBvlcv18JLj2vfNcIGsf8nHS3VUrc5WLVuU+I0v01lFZKYBajYd2On6OfucifOhSRw6kt2jPOH2jUjPzU9sQ== 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=Y3sjUEiO0k6XvVJ5cZBVFtq9FPmyCSr88/w4nn+7UwE=; b=mp1thGO84cQe6yeI7h0eZdRVkp03v+3j/LdISUCI9Lo6CHCNHOs5noREOoKLog71SJD5hK8JVYbzS/rYgsRdL6qqbmcAfBWIsrWkFiIRtkxI6NckuVyaHGXYu0fjJsnc/z5l9+Oi+2poAEOsIaNPHD8SsMxaqlJWSxWVWqb9lSfhL1ae11vX1szgx6zOXXB1+3nVCzGIQ3Yi1ee5kH2dDHxdACaJ6hD3fR5fnjDW+8hgLcXs6EC+zM5VDkbnnqRPJ5EHbaYtaRIzSgIeSESIn6Az+zH3dn+v06S0KXjwAofTgDmlcFbcsJXZsr0y2tbDXoYX0p8XCmJlC2tOn760mQ== 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=Y3sjUEiO0k6XvVJ5cZBVFtq9FPmyCSr88/w4nn+7UwE=; b=Tl8R6/YSGywfGQqBOcE8Fp5aDj6+EaO37PyJFxZn7wk2y7eCa5hEjJkzuu3UBxko84rAENnkiVO284/td18PLzqUsz333tfWrVWKwfeHLP0YeoAPHhLMS7DRrnvJD4uR1AqPMKYkklw6tsEHqSo4stzY4vAgWQYMRKsdQd52g1K3ipdKQCXv1ZCcOZ2LQFkxvpCtnkNywL5U+j78DSSu9dvZszQHKzYlKmozBC3yWYPFLxAXsX8GteC2U/9H3ObLXHV5em9ZOM+6/Xc406zwVAL21ZDWZK3DtCsViuJTxjxmwfNHLXSJi8WkaDhMxgWLq38xT4Y5UZpjXeCy4uhxJg== 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:52 +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:52 +0000 From: Frank Li Date: Thu, 26 Sep 2024 12:47:15 -0400 Subject: [PATCH v2 3/3] PCI: imx6: Remove cpu_addr_fixup() Message-Id: <20240926-pci_fixup_addr-v2-3-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=2425; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=4/d0yg3ZdSKNs2s1itIqRF0QpsFqrvue8dPnBf8tBgc=; b=zZHDFYAhGGWKyUhoHuATdR5ysX824C1DL/YF7b+wIDIvCapIU/OuP7hI1gAbndbgQBS0rdr90 V/SaJACMKmYCkugvMdR/u5QABb252bjqTOojl5g9CgeAkBBmorFNoPx 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) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: 68cfa33e-f0db-4847-665b-08dcde4af644 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?+w18hIaXw3jBAWN6JzFPg0h2i2xkjpa?= =?utf-8?q?/9stWKekvh9i1TBfnMdACcC4C3JURubjEAmVFsjX9ew7gMFw064b8dQPo3DNwVrw9?= =?utf-8?q?udYKcCsPmekI6igG77Y9lpebuBEUMrUJAKvLmAVkgJNaR/YdenRPw37Bc5hqWx2v2?= =?utf-8?q?iplQCtRXurz7KX3wNE4Pfb76PxPuCBnqt2h0u4y7U48Bl3phX3FHct3wpu1clp8ps?= =?utf-8?q?lKmEsK29ydK2j+XIcceGxIzR0rjMWnWs/eWhitVjpH3ymVN5dAvjIxW5WAbkUUION?= =?utf-8?q?MiO+LU7XoLcfeZFEBFE/yJaJ/anEzvkZSEPMe0KGyD6dRNj2WZIRWpon0qSgJqMl1?= =?utf-8?q?eJ6M3L7ybou1Si//8sAHxeSSyyzIrXq3Ziy2/S14u5YbRwslF2/XDfwY97Bj+hrpM?= =?utf-8?q?CExstoQGCJKFXW3zElZWaQSM81erQ06KZQqT4TOXMT7Kr4qHayy/Hg/a+QORjT1o5?= =?utf-8?q?zuGzKQQskyjgwu6+LcTobJ/m9LxUHWwwFNOs5vrrfw2nOTt6u/i1YsNNmhmFnh5AT?= =?utf-8?q?k8OcPGATtD9BXZ6vVmoNAFzUYoezestNmc+1oL32WIynxdsic/thnPSUnumhHoi5X?= =?utf-8?q?3ov5VdqfS9KNG90XwC5x3zeNTSjbltuexfKsIkg8yfSKTevSheDJv2Vcx7zQXREKn?= =?utf-8?q?7hW/Km9Zfs2a9Ukl4XTgqBpeYvNcaQKzr5zuYf8WYQEMzTB0kZDT3goGML9rH8a2v?= =?utf-8?q?Du7eUUmmQmnDE8JmMBMNFtQI7pydOrH/55F2F+zoA3t15iaQI9dNeArvPD+3X2Lek?= =?utf-8?q?34zc27zfMf3zBvtrgF7mkd0R9SHx9ijU8YVGgetbP+WyOYZfM8Wtl6Vkej63e3Grs?= =?utf-8?q?KYkNxvTfAjX4CFSOtUoQXLsflpOgxaOY07ICS4W+dvAoqwQJenHzoWizrzeheeEFq?= =?utf-8?q?e3APqojJoMWOFv6NfTzxubGvKecyGUguoCwNk8obcrzzZMiycHQ8+DcBqobHal+p1?= =?utf-8?q?Zf+58bd3nDfm7jYfG5L8EelYHA9+jN9dQEq/3rVuD/j6Ft7IJl2oTeC31ho0iOdXi?= =?utf-8?q?tVGtTWzJ3XFoKpt0Uh6LXtc6AnXHLpie/WA6qXk0wYB/cZ/8/xj+YsCY++DyDFJmE?= =?utf-8?q?DSDb3Ln0UJpDCw0LA2Mc+0sSUmrZIStttnq/mbRjKKcPerAMnmwykrGixQgHCiPLC?= =?utf-8?q?k95+lMUyIrlJbBxkM2byFmOwtmC3kOTShZJVy3xPyq1HPdD7cBArEpyljIvfWtTz3?= =?utf-8?q?GO+3wWUrmn57S9GsltFtoRhdhD6LAmMGrcgm9deMDXOiC5dexUNXzuUEzXegsJQNz?= =?utf-8?q?3qNL8GeNtud4n8+CUmxE1gvYdQKKB68HDIrhAc/fKJKihh36RpeIKEXHCGyW9sD1Y?= =?utf-8?q?xlCULfzrl86CIuNG2uI2zeXMJM6WILyI4pjPI9icxg5jP1VD0xdCgg4=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?xyohMF/sTcGhWbfpLtuU8tV3LmZU?= =?utf-8?q?eiPI9uZDIw3DhhJMKeSeMKKyFRuSOrpoP5kZRI+gj+nwffQ0T3MzymlcDUDIwyeP1?= =?utf-8?q?KaqcPpR9SoRBXdK0GRT46MMrWpvva1LIIn3sTZItmRBaduBF7YJ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8?q?g0JYrXpxm3dd3rBwJpyhnOG/XkYJQpCazB0YXjIUTE+/qTCzbEq7dql7x5fxNaMcz?= =?utf-8?q?zEdLpFDCylIWTGT6Jeerq6CFhhLZ97kTcO4Nr6gaS6N/Ad8U8NLXh8bneMHqox6Ae?= =?utf-8?q?SrKjKx0cNxy2Q9HnUJMXFcM6nPeizp5Jib+E2XG9dZN7nYzQDgh8DNIPJWxewvKAr?= =?utf-8?q?AnfSTLK2BVu1ZtSvVOih+fUt/9B0/gB3z/wZM5SLr8k1jCJXg7p2W+ECx7efPI3sl?= =?utf-8?q?jup+Abwo/z/n7cCLZszgK/wF1u30M7zNO6MclJICFFh537KE6n3KsbItg+gmrqNUQ?= =?utf-8?q?gIyjThkB++/+Y4D6yfTdhEV+a3z8ythMrDxCGym/0lXb+7mmA8j+ScC2fJCstMScW?= =?utf-8?q?wcO1wgXgGWLdROApldfxLgTcJzWmVce3pEcRQC5cs93g4nPnVY63T4sNyvewLkJpx?= =?utf-8?q?pBqzHS5aj9vFw/e+n5IBCqkoOdhrMjIj6fyHvzp1J+FrWcrvGOPmARHmdmqNiAsiL?= =?utf-8?q?fyw4ZWF3iOJC?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68cfa33e-f0db-4847-665b-08dcde4af644 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:52.4273 (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: 1NUM92ugVr8PLu+XZZweApbySUOvqzuCCDKuYNpM3KH2dZR09ohflUTFB5+4rEFFsNk+oy60M5+EjAWU7vpiGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7768 Remove cpu_addr_fixup() because dwc common driver already handle address translate. Signed-off-by: Frank Li --- Change from v1 to v2 - set using_dtbus_info true --- drivers/pci/controller/dwc/pci-imx6.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 1e58c24137e7f..94f3411352bf0 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -82,7 +82,6 @@ enum imx_pcie_variants { #define IMX_PCIE_FLAG_HAS_PHY_RESET BIT(5) #define IMX_PCIE_FLAG_HAS_SERDES BIT(6) #define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7) -#define IMX_PCIE_FLAG_CPU_ADDR_FIXUP BIT(8) #define imx_check_flag(pci, val) (pci->drvdata->flags & val) @@ -1015,22 +1014,6 @@ static void imx_pcie_host_exit(struct dw_pcie_rp *pp) regulator_disable(imx_pcie->vpcie); } -static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr) -{ - struct imx_pcie *imx_pcie = to_imx_pcie(pcie); - struct dw_pcie_rp *pp = &pcie->pp; - struct resource_entry *entry; - - if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) - return cpu_addr; - - entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); - if (!entry) - return cpu_addr; - - return cpu_addr - entry->offset; -} - static const struct dw_pcie_host_ops imx_pcie_host_ops = { .init = imx_pcie_host_init, .deinit = imx_pcie_host_exit, @@ -1039,7 +1022,6 @@ static const struct dw_pcie_host_ops imx_pcie_host_ops = { static const struct dw_pcie_ops dw_pcie_ops = { .start_link = imx_pcie_start_link, .stop_link = imx_pcie_stop_link, - .cpu_addr_fixup = imx_pcie_cpu_addr_fixup, }; static void imx_pcie_ep_init(struct dw_pcie_ep *ep) @@ -1459,6 +1441,7 @@ static int imx_pcie_probe(struct platform_device *pdev) if (ret) return ret; + pci->using_dtbus_info = true; if (imx_pcie->drvdata->mode == DW_PCIE_EP_TYPE) { ret = imx_add_pcie_ep(imx_pcie, pdev); if (ret < 0) @@ -1598,8 +1581,7 @@ static const struct imx_pcie_drvdata drvdata[] = { }, [IMX8Q] = { .variant = IMX8Q, - .flags = IMX_PCIE_FLAG_HAS_PHYDRV | - IMX_PCIE_FLAG_CPU_ADDR_FIXUP, + .flags = IMX_PCIE_FLAG_HAS_PHYDRV, .clk_names = imx8q_clks, .clks_cnt = ARRAY_SIZE(imx8q_clks), },