From patchwork Mon Oct 28 19:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13853909 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2057.outbound.protection.outlook.com [40.107.21.57]) (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 8D42218DF77 for ; Mon, 28 Oct 2024 19:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730142379; cv=fail; b=hCMIC+PaW1SawHhRgr23JV1TCKJgBeIQLpDEcYFJ0qRhd1jLJHsTEQviHU5CqL0laQPxa2TQicTxFoQkwAxvhIEmCrEHsyv0hW/XWq8A1Ei/N8PLbBopbr6ZnwRFV3fgSEwTu/tH7cVx/V3U4piMfaoai6FR2ajc6Wby5ILFcWQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730142379; c=relaxed/simple; bh=1rSpPrZTOLMx4xcaG4Itd6ReEroEzwhMtX2XtNZo75A=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=u+/2iilRzE1elk9FkKFMDkh2dm1zOH9/yhAKh3Tr69y8Mu5wmgKYfUb/KgjEgwToAqZ1gPt5Gt/nmyIfmXq2Boz5805kmQvijkR18tRfu7uP8uQz6cRYJpruGvEbKmCx3E+tNcmHV8Pknktm2T7LAydCmgi9ugsIaCvOjZuPtFc= 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=i44CfLEA; arc=fail smtp.client-ip=40.107.21.57 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="i44CfLEA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bYdR31S7JxRhwuB2Qa+v1lkJ5lEnSOpyh+o/d4iIoKQmdj3Vxj3PMFHJ9iqEVUO+4Myl5fapCCJg6szdamK0ISgbtwIyaEjAOVkbWTWgn3DUUJ0+vANxGzCMDAf9N8f3C7y5MYRuXnnmomKW7Rs52er2kLq/c9TDycwHFS/xw22b5x7MqcXPMq1ei34lXaVcAdaXXEKRITC48lChj0PvhNhFoCFqGaSwuW2jjiJ9ac9Ne0K/DsCtukBYHTdlqQwdkJ5Rtw+tT7jrnjwSJKhz3jGyEMQ0NyjCMnLc6yVafrsn7F4QqtFXcg98NttEOP/top+zF8xXUkitq7qzFRDbfw== 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=j/JXxzlgrGYw0PU9k1GSfpOM2XBdolyCC6yjHKtj9mc=; b=U56AaNicLTW7w20oCYSoDMhA9/kzpNpJLAHudHvbTaHVTgxAp+vcjMhVB/UvHoB9ICcvzhfyWFvb+Ud0bJqWBPWbKh38N5yclpCQzY0ZEGzS4giuHRuuzwtLs/kHQul3WhMF54dtSS45aoNQBJNlujSxOg/0BEHdMV8hnaRa3WGrfGKKl7NBuApP8fqp0IfA/q7aTb/v/85mgoGDTjcr560VQ7zSG30y3ODji8MmlUKancXIlcNyMI7+zxhFZkBd31HGXO+2Vd3kd8ZM+9Y1ktpgHrJF58DgLBeQ5ZARxnA6NxOKxLfUvG0liNyQibPNihmbPFJcB52IZTRc3ubs1Q== 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=j/JXxzlgrGYw0PU9k1GSfpOM2XBdolyCC6yjHKtj9mc=; b=i44CfLEATVuAKr9NkEo5nIT8nyAN0O3131/VQOW+g+pNar4yLiviiHDj4fqxtWQT3NVTQlwTU0sQWbhRrBon4gP4MvU0GoKld3jJFHAfawcO2t/WhpPa+SB0Bm8z3QECX/4wHt6j6Ye9OnsJV1JYOAyqYB3FffytSE5p7/NiQYash93aa+tNn2mqSLaM6BdRiTRwsUrqrlu0TGWf308qRBEjAN5VWLJLVDt+qUM44ggoLCBBaxrh8DsyqkeG93KSxXa82mMe4baL3pM6ELmvr8IzfuxT7cmTdnUPyPM7qQH4IVLpdw3ynBBqly3eMiP3CVd/ccTRu4ZaLk1GCmFYqQ== 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 DBBPR04MB7946.eurprd04.prod.outlook.com (2603:10a6:10:1ec::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Mon, 28 Oct 2024 19:06:13 +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.8093.021; Mon, 28 Oct 2024 19:06:12 +0000 From: Frank Li Date: Mon, 28 Oct 2024 15:05:55 -0400 Subject: [PATCH v6 1/7] of: address: Add parent_bus_addr to struct of_pci_range Message-Id: <20241028-pci_fixup_addr-v6-1-ebebcd8fd4ff@nxp.com> References: <20241028-pci_fixup_addr-v6-0-ebebcd8fd4ff@nxp.com> In-Reply-To: <20241028-pci_fixup_addr-v6-0-ebebcd8fd4ff@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=1730142363; l=4762; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=1rSpPrZTOLMx4xcaG4Itd6ReEroEzwhMtX2XtNZo75A=; b=J6JHDGWw7+6ttmVw93GRpH/jRwLln1TzuZg5mAkybhPYDvZQ+fEG8f+9RhzC56plqOFdcImic T2IfknfXeVzDnLRpqG3P3EcsV5ohLwEU6D/ZNYt0B17KM190FvUOY4/ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR03CA0005.namprd03.prod.outlook.com (2603:10b6:a02:a8::18) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7946:EE_ X-MS-Office365-Filtering-Correlation-Id: b7335a89-7173-47e9-2c42-08dcf7839706 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HfnyrfoRGKBS0ubqgDlUIAiZ+6nt8hd?= =?utf-8?q?sVpXO/TEdLmCTttZS7gFEXCMj+AI17CTueH4bXdzcmLdmheWjZtx/GrjCSkeho/Ct?= =?utf-8?q?XHbu2rw4ug454B2kWTcpAwspbSwFGSk4YJMxwlFgHJ+TtV3z9fJl0sk9LJq+xqmEM?= =?utf-8?q?+n9f0Vk9b7iB19aP2+Yf6rHCUWAXGcL5bmOvyVbMyZfY4Queeu3O9Co1hIbf2iMME?= =?utf-8?q?AS1gFTlIq7PlIp644dcRNiwqR5NIdhY2sIfy7BCzvlAIfnNFTbNvML3RJ98uCF/h1?= =?utf-8?q?7Vy/8tWCcqo0r8pr66FfTwn+7L9TEkceaqiGVZrzRhbS3SA3UzHTg5HxXBqUQnyeF?= =?utf-8?q?KHE5ltZwXz5yasBVafebIcuP6a/zlYP5VOPwKMOS7HSn8aNzm9MD0SuJQyFUxUeqe?= =?utf-8?q?u2Vuyr+hSSgW/rFBqW9moevUJlzwOiL9tkZYgvX0bQQJCN53tgD+NE5LLCh+iRuvm?= =?utf-8?q?WngeLuBhE5yzHllQ78txI4dcgnQJoy9Z3nFdtzqL5iJLzzNSTY9KT767WRAsDnRnE?= =?utf-8?q?m4uwzX1VZaogFHNXxSGi21A/byPaDqTM/kJZhf9FVPCBqhzGLLiUclNj0K7y3gR/o?= =?utf-8?q?TjJtSDxUZsdSt7WxznkQLbLNJLQxRLjAnY/jpYgN/afMuV7LwFeQDlmo6L7Eg5XHG?= =?utf-8?q?bcEs9vY94m7C7CCgr47slA/xJKHfdbhk0DS3oj97MkX61NIv3ZoDObfvT0JvLVe+I?= =?utf-8?q?ftkSLDCr7NLFU2KJN/Eh7YLOEzGE0Kuee6fVtBRzgVKsQB2+jQ/JpWtgY4j0PqZkt?= =?utf-8?q?L+Z1RjWMcxRFQqs+qig3lGZpw+KlQWg3y5pTo9NrmiqxqGBzgzuY9ZHIh29J79q8T?= =?utf-8?q?ncKcBFkHhN+fZSAf/I1F4siYpmXjUFG0WfQj9kmpcRPAO1SjdAYwDMPMxaFLiiG/S?= =?utf-8?q?ANfPPg2JWz9OS2r9izV+LOniZvTHgXB7+iNj1SfxGIvAeqwHZ9h/0bUts3aCZwBoC?= =?utf-8?q?F3b64FSyhK9NHHUCPbQSD2ZhMIERnd5NWCB7s6bdqPLr0A+l77ySsMK0ywvXE6i3E?= =?utf-8?q?ZsQw9AEv41o3+f5QZ2vWuHk9nJ9RnQQFwNbTAklKF/Mr3bkdpQ4bFkYkpnvpNqAiT?= =?utf-8?q?9AAApQf4499yqu9iFOKP+LxccKfFKbYzlaaVSASYxBGTJLqekp5p7EGvDm5hs5bDN?= =?utf-8?q?ctRsJDSARdPdD2z0JpFFFO5+isVNOY4um2NyKTtYDwUeL3m13LxlyDRgOX0uHsFd9?= =?utf-8?q?zpCUH1IYzJiSfCFV7zC+Xt+/7ieyzTFe6yWkYkpFStlbCBBAR7COGBT6IQi3Ybnux?= =?utf-8?q?KTnWb7wW4PzwjGi+Jpt9ccibQS5FRHnZFSjcAWUzfmLtPXuQ19ifQIzP0oyrZHqqD?= =?utf-8?q?mSYgp99UliHY?= 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)(366016)(7416014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wnaxyA6YYxO1o3UFMYTokFGatIOd?= =?utf-8?q?7lGCHrur+dNgPFvncsKoDt863qB2u1eZ/90e3MR8CBoWj4tshJnI9SaaU2ZEAhqaj?= =?utf-8?q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of8pwz+yVqhc1jgRRPlrFSeUAL/Qmf8oOeQSDFRznoptsF4JfPF5FvnUH6IUHv?= =?utf-8?q?G/RngHDxywiGZqc1vcFiQz6TRMTXIJvH7EzPaliAXHrcViSkihq2kN0t04Ytvhg7s?= =?utf-8?q?tJy7MIqqOUXnjn//S2ujho4CmybzeZPeqH35xWvMjszMZM+JWVnV4QjtF2mZ1tWX9?= =?utf-8?q?bHAIlh/ud2LUOeLZ/MTP1shi7O3PdBtdMPl2vjUaZnHv8v47ticglEEtTZgd68UuP?= =?utf-8?q?/M0B21Yx/vKEI16pS7Xe/FQviW8Y+r6mwSV3mb3JakeOEE5Pk1feCtVxF59nBQGq+?= =?utf-8?q?2PsbMG15DXza5v5tqNwytHUFaS8pLf6zwv4vTNrRr7njVj/It8b2OL+FS8ySWyY5S?= =?utf-8?q?RT7kfra5wmWMXCMPwrpKw4YweVl2x/BH90M7RexHfeF2i1ENe8u0mJyQohEj6AO6S?= =?utf-8?q?NoileRhkgYKrQ21IHvRpVbkofIS1konu9QIW0HAZQZ6TNxmfcNB5WM9Bc2ZcCJzi3?= =?utf-8?q?upiqHND+BkQUvvzFpxL/q/6OB014clkapWx3tcYqy3ge3UqZVmHFVs8CHeTntbm1N?= =?utf-8?q?C3nusIImSUTY?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7335a89-7173-47e9-2c42-08dcf7839706 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 19:06:12.7368 (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: jPbyIgtpRxiIuPXYjon8GAYaJTu9MplsXJ9SzDQ6HYMWKdghiBYsKb3CdfLRghskuAAnussHAy4ILdy9nppsYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7946 Introduce field 'parent_bus_addr' in struct of_pci_range to retrieve parent bus address information. Refer to the diagram below to understand that the bus fabric in some systems (like i.MX8QXP) does not use a 1:1 address map between input and output. Currently, many controller drivers use .cpu_addr_fixup() callback hardcodes that translation in the code, e.g., "cpu_addr & CDNS_PLAT_CPU_TO_BUS_ADDR" (drivers/pci/controller/cadence/pcie-cadence-plat.c), "cpu_addr + BUS_IATU_OFFSET"(drivers/pci/controller/dwc/pcie-intel-gw.c), etc, even though those translations *should* be described via DT. The .cpu_addr_fixup() can be eliminated if DT correct reflect hardware behavior and driver use 'parent_bus_addr' in struct of_pci_range. ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ IA: 0x8ff8_0000 │ │ │ CPU ├───►│ ┌────►├─────────────────┐ │ PCI │ └─────┘ │ │ │ IA: 0x8ff0_0000 │ │ │ CPU Addr │ │ ┌─►├─────────────┐ │ │ Controller │ 0x7ff8_0000─┼───┘ │ │ │ │ │ │ │ │ │ │ │ │ │ PCI Addr 0x7ff0_0000─┼──────┘ │ │ └──► IOSpace ─┼────────────► │ │ │ │ │ 0 0x7000_0000─┼────────►├─────────┐ │ │ │ └─────────┘ │ └──────► CfgSpace ─┼────────────► BUS Fabric │ │ │ 0 │ │ │ └──────────► MemSpace ─┼────────────► IA: 0x8000_0000 │ │ 0x8000_0000 └────────────┘ bus@5f000000 { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges = <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>; ... }; }; 'parent_bus_addr' in struct of_pci_range can indicate above diagram internal address (IA) address information. Reviewed-by: Rob Herring (Arm) Signed-off-by: Frank Li --- Change from v5 to v6 -none Change from v4 to v5 - remove confused <0x5f000000 0x0 0x5f000000 0x21000000> - change address order to 7ff8_0000, 7ff0_0000, 7000_0000 - In commit message use parent bus addres Change from v3 to v4 - improve commit message by driver source code path. Change from v2 to v3 - cpu_untranslate_addr -> parent_bus_addr - Add Rob's review tag I changed commit message base on Bjorn, if you have concern about review added tag, let me know. Change from v1 to v2 - add parent_bus_addr in struct 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..1a0229ee4e0b2 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->parent_bus_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..13dd79186d02c 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 parent_bus_addr; u64 size; u32 flags; };