From patchwork Tue Oct 29 16:36:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13855150 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) (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 1B7AB1D3644 for ; Tue, 29 Oct 2024 16:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730219819; cv=fail; b=oL3EPdzUMIBHKxjtHB5IlwZkThrzZsR+PUhl1xyzZhKHz8hzSvGyZs4wRMEV8rgVcYS9zQCe1fennGwj3f0Eh8aqCELK1MzyxQ+VcDKXE0M1nw5jc8+cC2E9aCKfkGyA67hH8FSEdefAw112xReqeKGPFrpO0j0D8uUE9VnaNcc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730219819; c=relaxed/simple; bh=NXPlQLd0GR2adwrv2G7c7lY2KTqdBSor+PQ9mBUtQ80=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=kWaTja9Pv2UJFfUg9A8yWWs2hFKx/J14oPc2ghFESCBdXm2p/0Sa14UBHCKiN6yz+Ef/kYwm4WjciMuvUvxpKYzUFby4eR86BA5c6xCe+VTUToXDuhYXgfYeYaZZQXrAeaugVmeyOcgwIYi2zaiIeIfP/YGhY1qFsrkirvtMjK4= 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=hH567bhz; arc=fail smtp.client-ip=40.107.20.62 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="hH567bhz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rmdVwjo3zi67xX32jAJf74p/P6OQJO4/fIfkj9/5oH+6s7/wA8B2VT+G+4oddXHau3YVxKblPpK3mR1KdI6HpjrIRfgxJZuNqR4a67FoGM4XrDkD+3geZVsWt7y2qGJAzenE4LfZSlgxQwoBJ2IieYt8h9RZIPC52Tti9yhk2WcKbDBRuPzWO+K6s/Q2TCfaMhoE+M8SLmHCfPgZvy4nYvnlHqQVJPeLRb83I/+4TnP4yL9jXeln7XMOFQMN6LdDMH3SMclsZj7ZvsXPrpMQR6f2EOoeIh6ooggbfFxWeM8pcTiLKje8GQWR8FdG2GRqQHlevQAQ1qcYhYbLR7NiVw== 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=Ud83vvAahmvbVVwLXJh+XRg0BtdbsLLBcRBvfAPBPxg=; b=JhtKn4SjY7qcaBJSh90k2axFthZ0rw41vz1bgfZNDj0PR0rtFFAfFfm82aV9ivyyNKlenYC45N/UFpkyM9yJyKR1kKOkAjRLk78zQcJAMZ5cuaUaJ8SGZSP3XrgbVfP0Z7lQfXE+M/lo98bDorpbUcDaqcVQXtjO957DZ25Ddx6lPEP1owv74FUV5VKbvgMHvvoVqkbsskC2WWO4EWKrGCsHOCdz2yQeHr1P7mvKrgSgy1H4q6pHB1WYn+MbNpRP1tJOKhXOyXSuwy4Mlcnypqaw8hkLyv4AFGBBF38AGTOsSwztE4O2AN1Af1cK66wppT5S5/Wlb7FFROzYj38/DQ== 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=Ud83vvAahmvbVVwLXJh+XRg0BtdbsLLBcRBvfAPBPxg=; b=hH567bhze7RcsZIt/dSSdLPe3536P1FolOVz0Z3tPRsUB9Peg1Kyc9XZoLDSriNKnJ8mEDx0HUEExtoGXwatifVohb5jk8v1Si/SnjbT/E+HbD1tZeQWNpalwuuXHxnbgPEqhF5lACkmk9OgIb2wznPjkBOJJabdIkmjdcuQMlSvahM6eJ0/jSkLc7OqL3S6WWLbByKh+AjxzEsolahRBueyRIPPDoKBTMfJWkY8MTir6vsyfmfndDPBrI8KYKG/ZcaSlCiFNU1G7mDcWWwGTqC1Qq91GyR8rrdZyY25rvYRDFBsYWP10PqVOoHM44N6LVkhVwsiRHApORaJviDY4A== 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 DBBPR04MB7577.eurprd04.prod.outlook.com (2603:10a6:10:206::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:36:53 +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.027; Tue, 29 Oct 2024 16:36:53 +0000 From: Frank Li Date: Tue, 29 Oct 2024 12:36:34 -0400 Subject: [PATCH v7 1/7] of: address: Add parent_bus_addr to struct of_pci_range Message-Id: <20241029-pci_fixup_addr-v7-1-8310dc24fb7c@nxp.com> References: <20241029-pci_fixup_addr-v7-0-8310dc24fb7c@nxp.com> In-Reply-To: <20241029-pci_fixup_addr-v7-0-8310dc24fb7c@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=1730219803; l=4762; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=NXPlQLd0GR2adwrv2G7c7lY2KTqdBSor+PQ9mBUtQ80=; b=neSi6t48nUqyzgiIKTUZl9yWlJkBbL7wWbrra3WS67+WJ+N01sWoD8iSDTLVwIWxL1iHAFl1A No5VXxlt/FtDeAhPpwlFiaiiRA7gh7fF0cH5iTnc+dVO0zU/+Ym0F60 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR13CA0035.namprd13.prod.outlook.com (2603:10b6:a03:180::48) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) 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_|DBBPR04MB7577:EE_ X-MS-Office365-Filtering-Correlation-Id: 433bac44-f019-4d52-a88a-08dcf837e4f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|52116014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pO/s+S+uNyEa98vqJ/K8XiduaXbWeTE?= =?utf-8?q?nqnpHbDRbqXhWDgBF9EDxIcaI8NwbwgIS1J0ombqwQvvI6IV75m6On1r6WO8V/CL+?= =?utf-8?q?uz3rVngB22Jvlqy6qsGEDnYzqxCWzOwnk0qXu8ng4cTuxxZJgzmvRtIZEP99+nFxi?= =?utf-8?q?jNi+YZk6zBbUoEqmFRHZ6UMmzXaFgAoPFTgbbl263STLHBzovJBBZAs1dmtHVTeuc?= =?utf-8?q?V8SApEBeI5ofWYYCzDjfOalw50lFWcjBGIN3Orr3i8b6huYyVv2YGsG6INCXwS5tF?= =?utf-8?q?T+QT65dyHSjyqT0gzXxVgn4JqK+QIomONAPigC61VsNQJ7XAI8OTLt2T6VNyt4yQU?= =?utf-8?q?0sOpcCmTgq9aWWpHvPxFG5QrwqhrFxyndmADyu9HrFIQD/xsagnc40v/Isr/5lVl4?= =?utf-8?q?20pZ1fwnlS/gjmx8gYduMTAdGAdd8/7SiBxi408CguhMzv6iRE/JgrWrQpEmeWVPy?= =?utf-8?q?azpEI9TTY++q6GnnKmN+WnAuQaRbCX8FkIMBsB/edO0ILN5VWw9F6LBob9VcoPj47?= =?utf-8?q?tNThpXJqEnPHIQaRtP/ytfh4GBXs+ROBrpJNXVQKILyZacoGFDrNNHdGlaNSKgHZW?= =?utf-8?q?PoaACbPFZ+HQGHA8tuwvJXyd2oR/lOVFBgiuU1YzKmLliuY2uVB12Y4wozhdrqX8m?= =?utf-8?q?vUoE2Y+SR3UhtzHDqh2s3SuhjGszX52EenU/wWIHmUHVDPX5qo4lGDSQA7ItGOo07?= =?utf-8?q?5ogloVAp8sT9S6RiTAS8eQEAY7p8b7fiR0lbVMMuJc/zdMdy6CZ8hbC92vCTYniVl?= =?utf-8?q?JBzTPvPJ3Eaumvmb5TSc6S2ykmtngE8AOq50PaGK2HRMKrS9q6ftVwSTVZjUQJC//?= =?utf-8?q?rU2N9navii/VPlnEaX6K67Tt2pbjGRCNDgDXZvEgOTd8SA1TpOI3awCVKGRIMiOmV?= =?utf-8?q?1bvc0q+DK3psLFKyGWrW2wtFndnX2GOJJLTBbd7qsaWRnczhtTfz4ysHwZCexr+Jp?= =?utf-8?q?EgcVmKapWhy9EBIYiBS3deJ1YkB6xwYAcmnU3BKR8TzyxY8uh7P5qMPFf8FI4lm+1?= =?utf-8?q?wQ2Zc8ZoXvZHrKgeLNFq4trBFW6s4NnTdIqCTbN00LAvqrl318wKLP2z9u/3jo2Wa?= =?utf-8?q?Srk0R5upyJGRl7LO5DBP4Gjp2qkO7oIEQ64IUJXNf2kFZILv5IKsz6hiT0Xbhk48r?= =?utf-8?q?xyrh9w7UAK9EvCjC8BQ/aYEjxcOyg1hR3f99bl72Y/IOKmidTNvt1v4cUi3K+2KGE?= =?utf-8?q?i3kYoRVgNqEegatlTvlOy/P6vmRiDkPwwn2Vdwnj2sZ8ofGciWLV5XP8VMo6kZ0it?= =?utf-8?q?7M2DQ8QhT/rt85S9AqlOz0c03KINvTZxC/StkJLoSNZehxn4SfKoRsuJurQle3zy9?= =?utf-8?q?usDjy57/slxR?= 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)(1800799024)(366016)(7416014)(52116014)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?aSBIYJxQ4ck18pt66AdwFADwn+nR?= =?utf-8?q?kwnv3g/ZE7ERIzTW/P/Nxa7r7ylxb7qnpe9MeKyFXaF8kYp/2+5jpM9U+TqgWePJO?= =?utf-8?q?Qqnadf/5hF6Wfn5CW28xROhI81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TNplJndSqxQfRQTlOENsDPxGOJN50Dd9k?= =?utf-8?q?UTt2hddmP1/HD8p3hXL+KR/qTCrEAUms03Qa6I0ftzA0oZPs62YZYsi3UZfC7VEUy?= =?utf-8?q?NTxce4Fwvkfn5BteEVKT0UG2SSVIr2MxjQaI9LSWQDkHASZr/0rZk0dpeEFCoZJfH?= =?utf-8?q?Z/Pr+8nFg3HdZZR7Ren/0KskkAjV4x4CC56221cWnkyQ4dOnzsfqt1uY6LjZXVUHB?= =?utf-8?q?UYRFJH68UbTZTF/ZZkq2eskmjMnzWO34hJ0pw/7yfzDHFQwY2ULsLShsh9b7G1ANx?= =?utf-8?q?OOuob8y7OJKQcgdZdeCqO+/uNdsNQZWZ4F+NpdTSoRH8QTxsEEdx/OJHjLjyYOovl?= =?utf-8?q?2c5fOd4j/SOnWv7t90NX5rsFFLUWi+MGDDp9y26LHyTyxIs++uc/v6G/1EFs27cn1?= =?utf-8?q?dlDlVl0XOARWy0yrTFPJglT5yHrYEo+PCIla0bw/ureb89J5Kj3xW+8b2i0VsQktW?= =?utf-8?q?U0MHrpI4pbyxGMiKGyzu7cFovlBFc1K1PLFHKApxL+4w/uLvfyYD4rS/m2mjfkvKK?= =?utf-8?q?GxYCQizC6ik8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 433bac44-f019-4d52-a88a-08dcf837e4f5 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:36:53.1386 (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: 0wm6A7BX+57kAHkj7vLw7G0mMiq1ztUOn2MHp4rbUdsFxTVjL+o+Nh1EVxNqPl40dulaMt0sMWfC9i+Nueiydg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7577 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 Acked-by: Manivannan Sadhasivam --- Change from v5 to v7 -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; };