From patchwork Mon Sep 30 18:44:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13816864 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012035.outbound.protection.outlook.com [52.101.66.35]) (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 93603824A3 for ; Mon, 30 Sep 2024 18:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721926; cv=fail; b=IhQsVnswyvjaBbaQgBSQFwBL2mvBjkjFGRIdxjRKjTmuP94adL4a3K5OSBiyijV9WoMDcheeU1w4laOOr2p/IfbmSO0qyUBej79obXiEHHK48VyCktHqYsc2urPi8vAe1QTHvsJ9DfXvmuL8G2M2tUoMKNsPMNabttmDMhYBjzM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721926; c=relaxed/simple; bh=MJ/EpQBArZ7D4L3xDn4c6F2C8fdgSVJoocAwFLKtG24=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=U9jeB3FRLjY+CKFyzXvf3be/Lr28XqfRcl0PfOVC6u5oz5HUAuZikPhBkK9ddqC4FyJCpduZkD1phnlSBJLVRIqjxPvxQpO2U4cAHWopbhi+IOyd0Z0dOihlHweTqJ5cgQ4lnPAdx8Q5X18GGaClKeKsD17yicelswrwOEdf7jA= 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=bYba2D6+; arc=fail smtp.client-ip=52.101.66.35 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="bYba2D6+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EFsxzpjoEcuNeTNp5Q8ebjK9MLUHWXDr4fVtk0u6nmBXBcmuWkCEWmCU8ny3dQtKnfzJGm9aWUHhj1T3emIqCR9Ksi82BVKv0hITxOa+U/7LB/aKdJ7PIC8qQq1AyCgOwWuAgJtKg+Xz7aMJtKKj4FZl0ctNDHY/D0BJqk04OZx82OzVsjZ5ivOt4S3n1EI44Vj0tOF4pjagyCe4piYYKq/pkRJP11JYB0l2dS9ch3yHIQGdhsGeU7z9lOXIu7tPsMJ0lr0NBvAcjbA2d6zboMDZJYow3yuDiIXvRDCfPlLIwBdtBbif1Wu55dqNoKKRTFy6TK4VP1YT7zVTq6JmRg== 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=uegrPoJkOOTCjxRwuT+0ynal28Fn3rOY8mZJoLKu+ds=; b=YEZ5iC7EnjMXcVgIepghlqV66e6HODCeETCRbIFXtGk2Y1/od9vqRdkmo1J+UDM3AL2KeSy7IxVEyNsUKuOPx0spaPiexWkvDoUZOCnHfaO7oR3WdmuFut/f1yp/soz8GHqee1kc2kGzTDtHYFjcyjkl+hko3q5vtYTty1Hbfxwfsmwx3suyUOyqO5GYTzetxEXGFA+Q4F5+p/Cwe17RpR8/BMCNXTy1rDFNBNM0H8wpV2FZXzalnOv2nPJK5MeiPg5zlYQo55fALW8p63+18QcMpn9Nn+/qsFa5nLX0AXGAwtiXTVuTfV3daTrVtLD3tbAndG0hAk/DgbcpEu7hQg== 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=uegrPoJkOOTCjxRwuT+0ynal28Fn3rOY8mZJoLKu+ds=; b=bYba2D6+lB8f7dz9k2mczapv5ZvPYJPsx2n8Jq2b59NIB8gK5GR923qQiPbdUWzsVLLmUaUsA8shFYUlBQQQNjmHxec8DKLPLq5ARuT7S/dBWfKKeiGdXNzuzY/EpGglsIHklc3wginPpP9jtiOCiKhfknUduuLbg4FBvrKvLH/twaMQCvWB5feJ01LujvfGRVVmSt7GKtR/u75aXkAguo1PKFNTl+Vl5EcmCBqesDOfb/rUMvWrxErEOXVMm87PoYRcEDuKBGEBTNEV1djZ4ILzPZ3ZlY0Q/0RRu4MMVxTOhpnj58733cXGjIdJ/6g/mfgUuLbECWWg/J1Td6kFEQ== 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 VI1PR04MB9884.eurprd04.prod.outlook.com (2603:10a6:800:1d0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 18:45:19 +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.8005.024; Mon, 30 Sep 2024 18:45:19 +0000 From: Frank Li Date: Mon, 30 Sep 2024 14:44:53 -0400 Subject: [PATCH v3 1/3] of: address: Add parent_bus_addr to struct of_pci_range Message-Id: <20240930-pci_fixup_addr-v3-1-80ee70352fc7@nxp.com> References: <20240930-pci_fixup_addr-v3-0-80ee70352fc7@nxp.com> In-Reply-To: <20240930-pci_fixup_addr-v3-0-80ee70352fc7@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=1727721910; l=4395; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=MJ/EpQBArZ7D4L3xDn4c6F2C8fdgSVJoocAwFLKtG24=; b=N9wt+sjsYH0aNxUchyB2/qwmvNKReH4fMw6NrS5h7gtG8h1pnr7Yjh5fl8mYeK6oRfXDGmgxA ukzU91nT7rHBhOZmTlErkJB1cq48pr7hidjVbn2cAaivKRtCzjBts1A X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0P220CA0020.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::26) 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_|VI1PR04MB9884:EE_ X-MS-Office365-Filtering-Correlation-Id: 2dabdd97-73ca-4b92-512e-08dce180086b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?9jnrZLPt9dGs1juoJ14yGKaQbABYp1Q?= =?utf-8?q?0tOZMR0AZ64+LISb2++TYxKDnkMS1fK49FIQc6LKWmHf3DGaD0VLSn7X/FDRvmLGL?= =?utf-8?q?yeLQ4HpX/BNLL1+SVdezKlvXMgJ2jojsoGt7Q80Nu5GqEUBmN4XMmrfx5GfazsQMT?= =?utf-8?q?/IOtJ8jdpHvN8UVQx9pmkavap0afQG8xku80yym5O/G/HXeZsePXjiiOFfwmr3rvA?= =?utf-8?q?kPVcSR/od2BJDNuitsv990X5G1MX6paDVl8nZFhhVmblrQpRiw3+1D5OJb6geDMO7?= =?utf-8?q?kt8M3/taHlHiMyS7Et6EMgGtiYGgCygoRZo6z2UXAGmUpWjJumcE3yudhw3p7yjOk?= =?utf-8?q?OuDMacEA3Y5q6rYiZAvQrU3ORdxw7DFsO6mtxFR8gd32mvIbUMqt7LgV9KM0VCR14?= =?utf-8?q?sH/pGtlDc7OxEK98mjf/H02vM8EfKFewS1DCQL+AZMSTyq1l6JDg6/yTesCUXxlqd?= =?utf-8?q?KW4JcIRHPxX4hZwxs9RbORqV+GuH+929o8ZST4wuWM5w+yKK50HRNmlPOkbtLQ7fe?= =?utf-8?q?ajLJnMglRQEAKgv/igZflwRbcz2+V0RqfImBR+46cJx/ooa6i8C1Pj6AQ3mZ+QqfS?= =?utf-8?q?X8nz2eeYO1MySsaobWVYZwkIZW7xjVKYakRx7w0s/BwEypBEzbzlgfUcqNfawdIOn?= =?utf-8?q?pYqst1boprZQOkBmznnTKHurTGw9hbMCvLM2SrTxk/gOeIB7QXv8cPAk5z4+5pFz3?= =?utf-8?q?bB/t3IXQ4Ia+rNJBKKjYuFt/aNlrbkUBu/szryQqhjMvnRDXIolFTcxblPR63QD/k?= =?utf-8?q?NkdNy+/zS/T3Z0pLTCgvtDpQsX3nDnsTxhJLmhVVXnLw9XDFgVIAD3Om3WxcbWRe8?= =?utf-8?q?U9ZA+nxt2CIXbN1KVlEnxUh2ckNfsViln36G8WeeG8+Gwq6jJUPDzy9KYd3QBXEY5?= =?utf-8?q?etKfIwFrcbytwbpHV4bpZzd+vyRzS62Yo419+LnSoCDFo/Zj/Ad074OD1WE3NGDWq?= =?utf-8?q?s7I5unTBC2uRoWz9MtjM/kxosiMFrHn25k2frDiHUCg8ItuHfCFP/+qJuIvLAGhFU?= =?utf-8?q?9FdQ1ZaQFt1U4AYfQxYbAUA5yrqtMpzPJgrXOe0dIu4i4oj9lYAE/sSO7qhhBtQmq?= =?utf-8?q?WXd7BFvBkkP0INdOnEYNLf4EH8Cgm9w+8Ff1xhTdgHyrqne42YRfdX1Zzw0UtAwqj?= =?utf-8?q?o7GKaphpWf3ztMiO2IPmk4lJbxzvZYeqtcBUm7ibKtIJvO86Dl41AK6D0PCHGrdCy?= =?utf-8?q?Nb9GUxaKKYQqYRZ8mqBizSkXU10Pdabs1H0TtNjRISnFQhQKieU7WiAFyjOV/Jd/s?= =?utf-8?q?nRIeuRHao+7QVissasfUqnJAV9PrarTY3vu1awrP0gphwhA8C+V/6xPtijORJiMJl?= =?utf-8?q?Em2gG8NrOSbUpje7cGQ6IfI3KP9HsyzIAZ6XLktO32cN2NcY3bkonng=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)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sUlXhPP/hv0DbuH57z8GQ2e7EPX7?= =?utf-8?q?bU5JBD4Bw2vP4QmRay0Ox96mQq+aU5ncRf+h3Fw1iFWzD8BYEcnd/+4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R50iWyGFaut1?= =?utf-8?q?9WYr3P2eWv9S44Mm+sIfv6gyn7UPLWmeSo2V09eD+72Ac1hkhL+kB8bOPcGqhIqET?= =?utf-8?q?EtYNAqoLmMgo9xhiZAr/iBnmOAevpy8Y6lH12AmsxuGK2RfaUddq+BOYz2SAecMzN?= =?utf-8?q?CH1zaWonRzpzpIYyyx/gVe0ozLquB+K6+qZxYoQwI4ATlNWcjG6w8OAG8KfPBaw2f?= =?utf-8?q?yfBaD8VmZl7X66YeRXHbNGXwi/tQwASxHHQV+ki3eTPJSnvZVjfhYCDsNC8YJwdiY?= =?utf-8?q?rchHLl8S94d7SiCPQ2ro3lQjsL90WeSsQWH0iqnDd0v3SaP9KJ8WhebOdQhbniJuG?= =?utf-8?q?fzI1TPMrMBO1yE8k93R3UTuB7szW6CRRUkdrlcA4AHWhUYNo64DJfXPRAC/x3HdhB?= =?utf-8?q?6C+Tv0zdUVR+wNiZArHornzbrYQXGwu7rK6zfV4zCmC94eLBNTXThiOabvK9PPokT?= =?utf-8?q?EFqZo2ea486tSGBs7KDgGzfQ6Iuvw34Q90FhyN1t4GTo93WjVp9yEIc93M/UeT0hW?= =?utf-8?q?faj3q/sgP0F/gFUet0uNC+OnPhFnOX/wMr8MHlnAcbcLlztlQJH1TG9A=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2dabdd97-73ca-4b92-512e-08dce180086b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 18:45:19.4168 (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: gwao/uJ4BIH3qcpSmX4lFk1IMBsEenvsjvsRPb/Rhp4V5vHXqdAyUSeOVsRs26mqqRQP2Ai957M3prrTpLp5yw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9884 Introduce field 'parent_bus_addr' in of_pci_range to retrieve untranslated CPU 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 drivers use .cpu_addr_fixup() callback hardcodes that translation in the code, e.g., "cpu_addr & CDNS_PLAT_CPU_TO_BUS_ADDR", "cpu_addr + BUS_IATU_OFFSET", 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 of_pci_range. ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ IA: 0x8ff0_0000 │ │ │ CPU ├───►│ ┌────►├─────────────────┐ │ PCI │ └─────┘ │ │ │ IA: 0x8ff8_0000 │ │ │ CPU Addr │ │ ┌─►├─────────────┐ │ │ Controller │ 0x7ff0_0000─┼───┘ │ │ │ │ │ │ │ │ │ │ │ │ │ PCI Addr 0x7ff8_0000─┼──────┘ │ │ └──► CfgSpace ─┼────────────► │ │ │ │ │ 0 0x7000_0000─┼────────►├─────────┐ │ │ │ └─────────┘ │ └──────► IOSpace ─┼────────────► BUS Fabric │ │ │ 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>; ... }; }; 'parent_bus_addr' in of_pci_range can indicate above diagram internal address (IA) address information. Reviewed-by: Rob Herring (Arm) Signed-off-by: Frank Li --- 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 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; };