From patchwork Tue Nov 19 19:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13880494 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 5DC43D6C287 for ; Tue, 19 Nov 2024 19:46:51 +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=xbHBynal3pF/RegJFlo7IroGpXvPbJAYX+a27w56dGQ=; b=PY2IbA4c7XjIVF5ycxv/TzRLzh zNVurzahEobY7JkX8LAcv0K+7TI1jjsYBAsgwC/1TbPR/5iGYPGgDJoGiYnVcnxQyD8oYnH7EdScF yIa9/2FfOqBBx+roJpIsPGRLqMOL/1RXGeG8jPO94mQMINPTP1fitr4rzOmm+ul+Tjz0RJ8+Z+roL 2TlAIqRvA4jbbRUl8gtzQeDZvh/1SfCgLd6CcxU3fSO88UTrhpCuiVJSentzaV0Ma0lqiWtgUpobS D48P4jckrKbPow5Pdf4iCfuDnxQX2RQwcSvzyKxSPNnHYKOI4W8/iumVdU+F0wIXuT8d75I+1oyKI /CbclrhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDUBJ-0000000DZuo-1fAX; Tue, 19 Nov 2024 19:46:37 +0000 Received: from mail-db8eur05on20630.outbound.protection.outlook.com ([2a01:111:f403:2614::630] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDU9T-0000000DZQ5-3xDz for linux-arm-kernel@lists.infradead.org; Tue, 19 Nov 2024 19:44:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pRmzvwnZUT8O+vyPmjpVFs09Bs9HE7Vvctgl4+vjQjtL/lr8iDdc8+/53MDiIY4p4T7AxpyJwA4E2WycDcrMjbC+Me973H7OQG+aaQjAzX0qhmt7sBGw3XJKZ4gTZRxclHryQ3eHIyxvjhBkHwO85WWwzbwWHrc2Zpq/wD0sGFFOKX03s9iNYySRwUwMUK+drIFjXNvTh3oXIMv1PQFuBzS1RvnmkWNjyjUjCxfE8IhRMRjU4Z6ttbxVM8oWqxR8nhn0SdrdiLYCTDljq6jckpxW9svtpp5WxyY/Sac81q4+CE/xZoyFWLoMGIn5UuAu/kBfLEM9F9ptC/31SH/SgA== 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=xbHBynal3pF/RegJFlo7IroGpXvPbJAYX+a27w56dGQ=; b=XLPpPn+REQDj1VmvNnnRodJLWQLLomflFJOzUT8BkWaA/uF/gB4FuvJqmHbu0JTcjRK/pcpbVgT9/+kHm43CVGEFZfk8IfoZwzvcWXXAlUSLiBCIe0wCYQ1gEPAJXEPiGJFtbcQaqiq5nC17cMgJuF7Dgo4Op+Szv5t8lUYXc23W+3LCcZXpAGGWEhs1/Dp6FqkvGcmBkz9VojKDBzGQUa6HTxOatiZjPrNAJQwWgZdLlk4RNY2nEdOpgkPKjIBR165SRwBeEWO9kvAUTy6+nNtM1ph/CNTJml74RUMcrwERbItLiQ3A5wTcjZ2EuaDU7U2GFyLU5M9Yt44omsmPKw== 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=xbHBynal3pF/RegJFlo7IroGpXvPbJAYX+a27w56dGQ=; b=d6GB91o9boo2gFLzpuaCFvPvZ6HJVnCGruBwjnUbABYHkSspL7SlmGoQC0W4vMIYP88R4O9NnYLvZGgjLMrDdse1hbHrCsCl6/fjpvGhwn/AAdDezBpehVIPeD+iN3A8FjAHiyKTdPfNGpIxncTktqQ9bAigbmxJt1Yr79v9sYK3zYINzB8+5Jvtt2iN6gDtVZXNb9ADtIgdWl4AAAeYq74zXrwvjyaxbIrQrnCb0m+tgMv1SSepLOUDDwVSIANtRRUbot1J5zJND0dKP+5lnrO5awljPwVEa8szUXMI1Fn5hlk9WFWoUnIyRXYz2IdETyLC8+2yOw6TTzk4F7TaEg== 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 GVXPR04MB11068.eurprd04.prod.outlook.com (2603:10a6:150:215::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 19:44:38 +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.8158.021; Tue, 19 Nov 2024 19:44:38 +0000 From: Frank Li Date: Tue, 19 Nov 2024 14:44:19 -0500 Subject: [PATCH v8 1/7] of: address: Add parent_bus_addr to struct of_pci_range Message-Id: <20241119-pci_fixup_addr-v8-1-c4bfa5193288@nxp.com> References: <20241119-pci_fixup_addr-v8-0-c4bfa5193288@nxp.com> In-Reply-To: <20241119-pci_fixup_addr-v8-0-c4bfa5193288@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=1732045469; l=4876; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=qjpUcIbnkk/T4kjU5qqs7K3xKeASfuBpjDR59WiM6kE=; b=iO4hrat6JoC6X9ncQ2MPC4tB19yUm0v3tRRt1J3qno05fE/u5aLA7nr42Ka7xwfmMHmVTaLIP P/T24/1OxQfA0ABYFLq2EzOx7gpVAW8Wn5iRPR1VUVEXC5VfpgqvnqH X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0009.namprd05.prod.outlook.com (2603:10b6:a03:33b::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|GVXPR04MB11068:EE_ X-MS-Office365-Filtering-Correlation-Id: 0354921e-19d6-4ec2-4389-08dd08d29a94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?s2+f/rMtxfObBvt4zPJ4G42f70R8qkX?= =?utf-8?q?08Yw8RXeA6WGEpswEun3rAqLYRMuV8bULj9D++VaVXStgQ9lgtsp3cvCyxY6Jd7Mp?= =?utf-8?q?pUQzhh6YfWEsGWxcPdP1JIbsv4/78rR0vrwkEMJyv+qc9nzhIqItFFLTrzQTi6KOr?= =?utf-8?q?boLYYvCnk/0Lfbs0CEnYmPwKFQP1wILHf86Rl8VmjxxcIOajjnF5toQcK4MJyP1O4?= =?utf-8?q?+YYp1nZw/PSas/8h+ajjwwxD/zg8+WDuiDk6PvTxVSodq9NfF3JscwH/ueHw6UQjv?= =?utf-8?q?rUZTm9qEszXdvoCBr5QywCRz8TE2EA+FFInoj9Pf8Gmo+R4jciMT3uWvagEKfiHG+?= =?utf-8?q?nV+7+YI56jK00QIV/W7EUHvriob1YThQTFLNDDUlfY9RNAD5ghc1CUFPEJVVqc4Jv?= =?utf-8?q?166L5trn32fx2iVMVP7C9YH22kGndHzfkpJcwzCZICqHYrLGqtq2Rk68qWHroZZcH?= =?utf-8?q?Qe0cyhgcC0m4CLrnJbclXN35oHmkRgeMmBI2t7X1sv06lgIvXzUJIrnuaRU4uEPST?= =?utf-8?q?SEIlhev21C+UWsrkHkpd7KljTLVEfZLnGBrI8Lm9lyf7S/9TmhIikbOihUSC1So0x?= =?utf-8?q?sEnE3hQ9yMhv/3P5jojR7aWdynRU+9iExadn+AxUXMpKcKCauJH+9YQvnW/WOVuJu?= =?utf-8?q?/RHukklbUJH3kSrS0n4q4/CdMVPLJq94rnqAeZjO3JPRpDHDr2PyCOeJu+jiusWm/?= =?utf-8?q?1lOOqhy9Wp2n//Gfso6GZTBiGFHD3V8O0atrTcmLvkQaT8cPvYieNjWe+86ZK9/mG?= =?utf-8?q?De6t66e1v/kk53pK32Zv9ne+AX2utfQAl2hiEay2BpdOa3QmpU17yZG51q5bff46k?= =?utf-8?q?wdGTi6XtgrsUMMsTaNQlEh/qLz70oydi4qzXtxPrMVi5zMSiX3o0Dk1e2Wfd3NY3z?= =?utf-8?q?iuOwY/e3JFfgYbDP6sOSM97bfIXWU7+AHy4uUWjx5foHQ2+wQtgin9G4FiWogzD4R?= =?utf-8?q?XGOea6HQIRMOPNIoWgfCmnGdasi89naM6rj8L94o+nI+a7fJdIHP5294B6Kab0CRV?= =?utf-8?q?NFE9B/6w60H9Khg5PXxll0d+RIrVy10QJqDU5gQ9wpj81wEfMOccfoNn3JstDmMPt?= =?utf-8?q?B6h8ki3sS6K4uFpJ0/feZradOREl0cKaeHTNrF+dOyZbZvi987DwrXWKwpeDigGUX?= =?utf-8?q?EFbI5y+1q5LW6ag0A7ESIv5Z/9YMdSB3P260S08Y2wGtsu7fA0hcemHVLHFwx2jFG?= =?utf-8?q?VjL+5810w/fxMdbEEFAtzFpcSGi1z3FkTV4XgD1hXlNCdn4yy3m7nmz0uDPwXztew?= =?utf-8?q?rgOxAdVnjHBV9xa16+bfayYHYlfm7mK27dgeP1cJnTmFfd3UDyQdS6tnNceU3iQ9D?= =?utf-8?q?ZA14VSWfsD1h?= 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)(52116014)(376014)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yE1bCG7mtAtijTBSENmtbUjqH+7d?= =?utf-8?q?ua3reUY9rdy1NmVz2kGgiA/6c7VI84Txuxz8skOBAiOQsq/+wVB3e9A3WMUsO1ZO1?= =?utf-8?q?mSaGChHDj+LaafOlDSOzB5i7ukO9dKvL2x4EhJ1xb9Thyq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ofM9w5sPKeD94juuZ2onbQEnKpsb3M8iI?= =?utf-8?q?l4+yksi+1sfOn0FrynVZgQ+fSuQrczkbyS1uMh5MmvfTEeBvf9/NrGjGuReSifWKh?= =?utf-8?q?KCOCfAaymgBe0beWXSs/LoRxfUDIEOkAp67xv74R59/W7nX4SKfAem3YiowyIsWGE?= =?utf-8?q?w+ss7J1N/raqael39NirO4TaWsGp3Ua0gbBewLBbRQJOixcBsCg6CnT6iPUdTR91j?= =?utf-8?q?YjUrBY5lGwHlLb02XmnNKPSvIUjvul4miH3tQjxx9z8Qhf6TbghuwS+6HX1auxjnM?= =?utf-8?q?HfJGDwfOy+SJDpWltCoRdskSqgDJ/eOawGBm1urfamURD50YI0IgpaQ8JeACm8hE4?= =?utf-8?q?egoAxuK5L49j3/VcLtVQq9kHKZsCSHSVoacWqrPhNA8IXZA9wPAGK3ZVfjZFeiMyl?= =?utf-8?q?I9XC0SZ1lh+mC275TjyRD2qsMEtOajJdj1U1z1UAIfHgRz0MIoYPEIFQj5A9Gzt9h?= =?utf-8?q?IgVKfBKIT0kbW/RKHS+/Vu5fjAWuKnhIohiPCxa8B2OOYUhADlvz9EpRzMBQwtJKQ?= =?utf-8?q?gm3gsh4mk+K0?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0354921e-19d6-4ec2-4389-08dd08d29a94 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 19:44:38.7371 (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: sCr5miW0KnDWxaWOvy5hhUShmXcjiPz5YxbSPrOpyKLOHW89ClONC+YYev0g+bb/TIQbX143S5f/0b9MITRPBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11068 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241119_114443_982790_216431BF X-CRM114-Status: GOOD ( 12.98 ) 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 '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) Acked-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- change from v7 to v8 - add mani's ACK tag 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; };