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: 13816859 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011050.outbound.protection.outlook.com [52.101.70.50]) (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 1BC27192B88; Mon, 30 Sep 2024 18:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721923; cv=fail; b=Exc6Z59Zs1sFxTSKVBW4ECCzLQg2ZTBwresscVYzCxpJfLprbYcV4ZVR4IdBJiua//aOx8LOmgDA1ct4noT7gCtWKe/6T4+AFltq1VEpNPF77R4dEm4yV9AbYx+vD2h+EmmJ9KFbDEKynSAjnGe9TgERbr+RF/J4hzIlzu/gT5k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721923; c=relaxed/simple; bh=MJ/EpQBArZ7D4L3xDn4c6F2C8fdgSVJoocAwFLKtG24=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=WJQvWYzRZiW7Jg6+ekKsm9AODqs2oLTOujLyoYXmVdpukVst95soZL/YSBqY4fTpi68LRYOTRPoILCbTpNHfUnzjFdRieEWLfWouyctTgEobQLdouLrTvD0jCJx4o1gxmtXCUyMAqCd2uvIeKSLLJS/COMXu79+FBKkS1qXyd6k= 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.70.50 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: linux-pci@vger.kernel.org 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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4RjR50iWyGFaut1?= =?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; }; From patchwork Mon Sep 30 18:44:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13816860 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011028.outbound.protection.outlook.com [52.101.65.28]) (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 1AD8E199E8D; Mon, 30 Sep 2024 18:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721930; cv=fail; b=J3wW8tqoIYZ/g/uqFikeat2KonWBCHdsDoSVrPht3R+oRRQv4+2279DWRvdXuK5tGmawsSvIQgK24jL4ltO8/SDOJaA8v8soR+Cf0UXP/7dJe9DYprqecE9VLagQaeEVAS1Q4aiL3LEFo56GMOCJdGeEEOqUaGtruqoNg4I/gmo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721930; c=relaxed/simple; bh=hI15LqP3AkTCXzkB5QbZfHvwe/ApYrNlpYXxxSVfXtM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=IQt+e8pNdYmsl+ndprRdZm9CSNMqOwrCvw8kdcP1i+R4pDQ/GB2Vh4OEQqJYtIpkVRKbrVw5BzwXK1mjWjOhrPjNx2VAKhHiPFKXV6pbEAlq8QNR+xB3qEqb+T9/StpGOhTFQAV2e0IgXBLRD2f3gK2MwN6vpdJvd6WAyMdyQO4= 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=ggRUIkzW; arc=fail smtp.client-ip=52.101.65.28 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="ggRUIkzW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CGxBA9/MAo6sA3G9b3TtXHXXrCSF7VXXh28fnBqPkwsGf7iKzz2zSaGL+QoUMw6l/mvtvsGDGTiJmZlw1dR0jM1WRAdvU7iuz2Bi3rtot+bLxmAuRBEmJcVjOfkKkWYHlIX3Oiuv9fWZXDOi42TYd5dSTrOW7xGSY0hsEBENBPr7Hvqq2vyx/SBapCvobfCzjbTj6vZ/9Az/6mr/NXDEDyOdlx2y5cBUbbhF5Qm5s4LCmUrKeSFgFZmg82GRwcsI+lWysHcJLKIJqckvUjb93tvIqo+yh2vN6VmWHuCu83y9B3bei7yugWexCxHpaZ5hnZDhNXFPaXmpp6JUi0g7CQ== 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=9waaWlkQ/3u3rRCj848z/MRqONKDyAao24e0lG78Okw=; b=uaEBOs5y+D8YhdmQAVCFI+5iPaZUWRbsTuaiQAVi5wI6ZeRa++HOsNAzScGLhK5GGNy/BBBzE3xcm2ngdVQu+2p6eNPz+GAeHZ39LrnSiQLtrb4wKqyIDk42szEBfQxX3DpCvYNBE/7mMtAYt0IKjfNEuJIbFX8RCzFGZf3RvWdoZPbIUUNFPcSCjEDQSZRadV5ew7sUbvmXzG/65NonDYSXho56BCVxWD64qZGmMPqaDZYtRehYKjnwgUWqQUDS5/EI+idfTdBcfH224P2xP025nMf/4GYSHU4rWQvGIMfXy3cFav+WiUhWDQFFbtvHRP2TF/K0bTfPcs8rqlzE4g== 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=9waaWlkQ/3u3rRCj848z/MRqONKDyAao24e0lG78Okw=; b=ggRUIkzWlhtOYyFcVAyuaH5C70mtRy0IZXy7ThyAH49O52fujf4wxL+gDg8TR7PmU0TQQfYU/FJIWyvxxkb3XJhHo7sUguI7v+98KfcBnJWceTNofdDdnYcyi6PIpwE05niUScnZWdFleQNnyygskkgqNmH79HqpOqIdD1LXarBabhXX1lK6RBWLOJiDM4F+sNwyVGexEm9iY4k10P7O2cuE1MXBx/tnQeUFTaU4cBuPSGJHIxt/SBEPJyoejcpjGL0Ceh2n20gmPmIpEs/6Y2Bf2cZtALbKbavFGzEaULgQrKUMWOD5Lz63kXhVuNfQP8kl2jkbZRX45Z+0s+RIPw== 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:24 +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:24 +0000 From: Frank Li Date: Mon, 30 Sep 2024 14:44:54 -0400 Subject: [PATCH v3 2/3] PCI: dwc: Using parent_bus_addr in of_range to eliminate cpu_addr_fixup() Message-Id: <20240930-pci_fixup_addr-v3-2-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=6460; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=hI15LqP3AkTCXzkB5QbZfHvwe/ApYrNlpYXxxSVfXtM=; b=KYcComt04ELSSMbGyOZXCNf75nWPSNyzGdPwWCwZ3q8rWYUoCuxwJ0qBr4+QO+6EoIgJnBFZL KfAWCbHVX+/Bgl3O2KbRP3yATCqGqSvXvLEv8qjfEC14ZtvKUhcQVT0 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: linux-pci@vger.kernel.org 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: 33adeebd-4dc2-4e41-e1d1-08dce1800b28 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?92vjwMVDk4geJJ/gIHWAL1mfLSXr1ts?= =?utf-8?q?m9troaiOWsG+FkxLcs5GEoGznFiafd0gC2zqAenG/2TSpUQ/1oOuLb5noTFZ5IgMd?= =?utf-8?q?KlV8qePfk2VgJbDX0Suba/6tl3KjsawtODKD8CSxm2EjLmgREDZqh/uuoTtBm01JJ?= =?utf-8?q?EMLqJwW5upKFfOeoxUr8eZ/3A4FLm+goq4bvniVyVE7PyXtqgOH+fCpIOyAlcy045?= =?utf-8?q?gcSu2Ufpr3HYEstKfiPl5dzN975VObF0cmjLFkrw7RFlIch+AsPi0bEWhlMZGG1is?= =?ut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/d4CG1i8+jDXeBovlnVSkBFX/al2zIVE69yglqBFWKuwaeNpW38mFJ/cKgh3M?= =?utf-8?q?A1ntV3L01L94kLoutDdYwOwxtahFM9i1cpGryjHdWsRTlB3tHaO1+n+yRygCbWCRg?= =?utf-8?q?PFWShSomwn9lpwIYbRAVBdv6Xsk5a/NzkoNefQIU2L5ZMWYa8onI1McAMNm/mgzgs?= =?utf-8?q?j+M6dVLiabaJGAgoEoWXM3QDj4Jxvyl8/gnAkOLu7E7Bp66zLg3+jHo=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?L/Lq6SX69BZ36RTg64oYkfyWPyhj?= =?utf-8?q?/seRjcE6KkJUflQf37KISA0ErmI+K+AlWaZtC979X5AEtXudg8uoPrIVc6hY/L/nH?= =?utf-8?q?AvxYFFsE1pM7uKJv+6D2/6R/T2YuEnpD/+njNFRBqJoJDYDW0TM5JH+0cdwJk/q+5?= =?utf-8?q?4ySLpLhqP7OUsTMc6yVhTosC7gctKgApmof3lJKwFaNuGcGmVkz1y5np//s0cHew/?= =?utf-8?q?ptZsP6/+5twNBVmgErZMpRku3TsGVX1WlF12PFNyprPI028Zh6Zqqng4l8/AI8cT9?= =?utf-8?q?/npdk27na2LQhMnwdcIl0FNwwJn9cjXMQcqqnDvN2+Fx3iEB1PoqjlhfD+pKBHBCF?= =?utf-8?q?QQur8ZR2dfZuSS6SKAmBIkvkagSOR/9yxx2M22JLkfd2ZI69b3zmXuUUjZtOZOpA0?= =?utf-8?q?Fqai2unk5mFBxJ530mfLvQbg3uNNpA0Ihd99PE/tlI0W3y9LD42cbD5A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?= =?utf-8?q?IjQ57PJ+hF2aDWQkICT0rb3AJmvtopU6gIQ/FyLM3uup0srEmqMaq2UjEdo+Kp8SF?= =?utf-8?q?qPsioriQKe4B4yt/Z1JIs5HM7vGHNlG/fHvflLxnKKeDO0+zy15ecL4sHeqfqO62s?= =?utf-8?q?N3YEyheOlWnT3JplO+7d8QyLKZlXlDL5gPnKO5urlzrOp2Sq5DkKQOyE=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33adeebd-4dc2-4e41-e1d1-08dce1800b28 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:24.0190 (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: rSdeKrzWxAYIywvxsABH3KK8fHVSM/bgbf3GEl7GGEZ1bdTsrD9K6E7DDGriMzfVx7vly0HsmMM/Ui+GTTibgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9884 parent_bus_addr in struct of_range can indicate address information just ahead of PCIe controller. Most system's bus fabric use 1:1 map between input and output address. but some hardware like i.MX8QXP doesn't use 1:1 map. See below diagram: ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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>; ... }; }; Term internal address (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 v2 to v3 - %s/cpu_untranslate_addr/parent_bus_addr/g - update diagram. - improve commit message. 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..823ff42c2e2c9 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.parent_bus_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 Mon Sep 30 18:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13816861 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011047.outbound.protection.outlook.com [52.101.65.47]) (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 64089199FAB; Mon, 30 Sep 2024 18:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721934; cv=fail; b=Fx2hpSzT9pyhDUbM01RI4SYAO5hxuwidHwexg921GTl0pJERzdddCiDiuHj4QkN520QAx5+0v1WadAAStpWJHZ9EezgvPpwB681J3RozI0dpO/XD843+ybK2VCURz0w4rNqxlSOfATbC6M8WsAprymp4llNCwH+kkdgAmZfP1yU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721934; c=relaxed/simple; bh=+dGq6PoUYPMOCSby2xfGUtVL0PAj0jtC7NzcyMHa4wQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=NkE2N3MesfJfa+ZVXWkgM4+k0k58D9cORvCbG6NdoLZMyVP+S5XuHI9My/D3yy5FjEs/2pwg2epmv420Gkj+90qLCuBI6H5SBzQrMvsCBj2ko3UaaoRJaXgS1lRmVByCvlb5bJIE2Xc0/9EcBzvRxhmSXOhZstchfHVVsq7eDLU= 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=VQuAH77V; arc=fail smtp.client-ip=52.101.65.47 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="VQuAH77V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AXbvaF+4Uh63JSCNYi3KmComFDi7E6KvkX3LTc6Y5O5tWvtddnCbirGFXDKKIqj7VLXd9tpmh5LlK0UUKInjcl9tlL1b6RqNFoAu0miM0t0fiG+L3b3mZOV6PBO1jZIixNKKEnA4L77NGwvRVu7tEKFwOhEhotgKeI8BZNH/TYSWVwAoft8MUcE6/2IBN6nhgn1ME9FLrlgc27NAiAtXFXx1d55ipNrC0HKeShb0NpibamyXUpivssxxpbeEsqvKqSCTtdbEf0ngl5/Art02Q+S5log+3rAzBwTwnTmblJLz8TmhEMyqdrMCk+UDALkMDeakESZcmscKqQN+RB039A== 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=jMQxrTJTrKyb9jA1AVXWB4dHgbjb8wTaLWpeKSZmB9M=; b=pLR6etYQxczZ5C0FOR78gTlCknLjTL7LrJXhWXz2HCUO3PadACLtX08t9dLn4IItW7UzBqXo5QqobfE8k41dUjorRjtg6/giSE6f/5tSL7SV1I44OozUCcc8rwCuGrDGtBTIzPv2vV2UNTwA9Iizto74xdY45eumI25upUmvCPkTZENfIecGRN1OkOk5mimlDPQ1CiGXA6IcyhXwGemejzJP6l90DO2oD6sLdCcctxCEhjGU/DZmA9LkJqEi08sy7y7qGpznFrt5fRzb0oxPNe26YQVn9TWx0xdxK9sxT78xcejJPS6yOrjfOeDgATAGwpVJbKI8kHcJWNJn06HXeA== 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=jMQxrTJTrKyb9jA1AVXWB4dHgbjb8wTaLWpeKSZmB9M=; b=VQuAH77Vo8P8JNQesLmz9qAOf0MQR3r7ODICFcODfCEu9SfrIohb9z3OD5QSRKq0AzXdoaTW2/IgpeskEqjMSJST5xSBYhWGXFZBRAQ2gQISquIAa+kHywAEFvhvgFUhRglnOFtukYkuf4C9E3L4E0W1z6hwlSlxJ7Jpb+/ZBWY6rj37xgGtrtayweVF8kGuIU+fHG+PSeIbs0qz9WU7fTYx2Q0e8NhURCedtIh+Dr4jluNcoHSxkekrzUyKCDCYq89KASx8kVK1TjfqT9RW/G8iOk19bmxTy28ZzGjCDPVAihhiV2fH60lLIRd0dej4oukXwI1ltM4yawrJHpvqcw== 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:28 +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:28 +0000 From: Frank Li Date: Mon, 30 Sep 2024 14:44:55 -0400 Subject: [PATCH v3 3/3] PCI: imx6: Remove cpu_addr_fixup() Message-Id: <20240930-pci_fixup_addr-v3-3-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=2455; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=+dGq6PoUYPMOCSby2xfGUtVL0PAj0jtC7NzcyMHa4wQ=; b=pUws7vapk2FukVNjbBvFBoUpU21J6bsa+N8lQC1LnWs4Ds9ggp/MqO9ouRJKR7h27+1Xr8eg3 6Uhk0S7Q8znCS/w1ZYfnc53aVjsgoOcFEtGBr5ozJrIvafMeNpT9UCz 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: linux-pci@vger.kernel.org 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: 3dca980b-2c80-4fb9-6761-08dce1800ded 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?AfeskvDf5HhbvenqtZmE88caxg6Y9wQ?= =?utf-8?q?GtWFfU+zt0GYn4QJzTj3o8fCzwt8Z+kHLYpOAoX115Ypeyj8xWflCGmxCEV0H9AvH?= =?utf-8?q?nQ2bo9I4NNj6ODeSV3v0IUv7khMVK4JLUNUpJmLb1TtXyUR3AZ4evMprmJzlRYOQA?= =?utf-8?q?nKbFeQJRtZHEb8na/TbIZDLXfNJZUSa8z7bIV+lmfATb/mzogfaaVCKf4EyKEpbu5?= =?utf-8?q?rT8LW537ZMMb0yXx+RYFfrpsRytNsie7VXEM2dDw430TmVeLvHgGEUw9rnOS0myc/?= =?utf-8?q?jtnMoXY6p/2mda9Npl2VIEdWmlU4sMCkxpCajqI7xl27mt/cKhMvpra6I7N7ftvrS?= =?utf-8?q?mkx6B6QKdN0ZkKK70n+x6jbo4ds+rrJaLwFgafNQcFhcksH8FFkikodqqI1cneA1X?= =?utf-8?q?2HSXPCsT+a4vM23YEJM+WahoTiAh6kJRKveA68ZnLJhXcz59qYZU4LuWsWDJ0tRKr?= =?utf-8?q?nEj3z+gS8YeOsib7M6sAveyPYDI19AXfX6hsx7JcMu63aXOPLP1tzlMwTkwTscIy1?= =?utf-8?q?5nw8one9+nLOod5zpfEO2k26eeKVozDRsQ2feYrYGwowG7GlytpenKIN8roL9v4BT?= =?utf-8?q?gDlWikrdLcJmtPjRiDdKmFKkfuTs61Bu4OZn4QV4YKxN8Ja/L+4LA0lBATfIZ+uhk?= =?utf-8?q?qeMR6OMd/XQ05TVBCWlhTVEqWK3/ibWUQc7d5yCOdJSdID9yFLbbUufXu2xVXISqw?= =?utf-8?q?rK+IeN+8+khLQ+MK/GViKTwJtbpfgRlFi0d1osgyRtHoPdf9kFoW4a0yh133moX4D?= =?utf-8?q?aKurtM95k3PMbffjkd3jOdjeio/bVH+cl43McQRpOvQEzrX0eQTB91lH2e9QOi/pD?= =?utf-8?q?kaMh0ZdB6ObgAGBZYx20HoW2Vlw3d67664AXcYAq3wSc+x+SbiigvbRpU1Yvn+cHV?= =?utf-8?q?FUJ3Vi+hW9FSeuWcV0WaviCp9eEdp8QuoVmgJLxHREOZmuvZA49v494LlaeopTTf5?= =?utf-8?q?hnRclYXjwSsa8jwCz2xWiJdnxp9jYcM8JiMmZepz4SEvaIDCDCbZU3cG0yFp5N2Ml?= =?utf-8?q?z0yU0cGHM3OBCAsYtjoVMiTnT3QUx2h26b2O84JO9YLRCZMmvn1iavyTJHPSDV+au?= =?utf-8?q?z6tz0NGZA78Z6eOYfy15FyGxN7qCH1GwjkYRvTVkJDY3NeF30YbehJNS4cwOcuXav?= =?utf-8?q?izs+tLX+fwyazPV3ZloT11TjjyoPRqaKf4t6Y0hJ8k0tTiSSqPR6gS7UJk25T7KoL?= =?utf-8?q?mORX14O5Tzv5xFXUt6hdQjBh7cvX7xo1mU8FJSG182WZI4uyNZSZMX1+O5zNWMtpW?= =?utf-8?q?BvAGaELuVxb/IP0mlt/vNcvkAZBHzcclh0vyghsf+kWgULxtMLNKwfVZgILlMDFyX?= =?utf-8?q?KS4dGL3ILp3C4jeBXgcY6tDl/Ix0WTv5ap+3zj/FfJuOGDwxbjrtAwU=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?48xDhlowfFOZ5bnPJDUJx4sDJAuF?= =?utf-8?q?SiEf1fW3Ah0VBvXf+xRh5D09wE1jsRZtvTpANm4xYivlFJp3fw3NxqVz8z3T1at5N?= =?utf-8?q?Cytksb9PilASHcKl3jW9rkvMAPG4vtNpPmuVvZA0tP9gqzNHqnnw9MgDVMr1oC1AA?= =?utf-8?q?6GQWCWiWD3f3q8wJoBDlx9hPxaME5kzg0oEgjCgMQCsJ729kUzVqsZSKa5zCBToKc?= =?utf-8?q?Xgs1ezCh+qn7PX+VFSBbJ4m1IVnETI5JKwlb2hOXNYowrLCJYZbWpmZuk5rI9+XZl?= =?utf-8?q?FSqD3GtU3VWL4WEksgSlFAJczpecHIgoqcvN8vGVDkLLCSgCglfb0y4LwbDJydqBj?= =?utf-8?q?UJ59bomLA/RVbnJkdMx0XpoE9uTc+xay11nS3LgauSU70XBXVMoqYNbQ677Nd6dpf?= =?utf-8?q?j82X9qiSaPMHHorHCMtUy0gQXhIheTd1m2+Uv3fxkG2AHVw+u7gGZq5Lmub6TjK6T?= =?utf-8?q?+Qs8sT+5FCrGUTkYoSuZsYWXN6+QtCcxEqYshn82YprTga46/HFMOo5vDLugr44kL?= =?utf-8?q?PJDPrO6+tyuZ4FKSRq9RDxagulyyRiMAWq6hwwHnRz4ixC70rw3Q103rOxTajMHG3?= =?utf-8?q?nzioQARLxcCrlszCgNqfQtT62OqS5+OLFd5Zislra4oLozLIhq8N6q1y3w1TAv8KO?= =?utf-8?q?Mt9QvKjaGpThoo+HxaklOG6z6D6AKUIxp+RDCWRXRT+KkEdNDDiWFwgkVpYXQrOwg?= =?utf-8?q?TC3ayFy0lssuqCmq067ZzgNfiav8M6/E8e8Ykqv1bhFhf7JkuYQxbPOAfBG+0Sz2/?= =?utf-8?q?7pPtsit2wRrZM3356+amEokEAsB4U+l6bsbSsCh6QiV5eY/bx12V/ku/18GGa/x+4?= =?utf-8?q?5q1/QAyOt5to+8oi0Y/RV16FUrduePrJyPADrtEympFW+jzDyF9G+RIyYVh3Fu2Ai?= =?utf-8?q?bmw6l2vIOqEwQ825tpbeUPEHHdRQSQvQNRsam6CQAExS6pN0TGWuUfXfNik7F+YSe?= =?utf-8?q?AQqoWm9mbx4yiX8dkwdhZYAiUxbgS2mNcbh4d9Xsv0yubHZSgtemHuxFocWhCOC8n?= =?utf-8?q?RvavogG5U+4le9ta0o4kT89gsbOPttU/YL5UqYyihl1bTEuWuxhKGvqm8hMmH6RZG?= =?utf-8?q?NlRM1wanQgdLnyQqQDbYI+RtUdPrnisgVISEit86imNjsExHiz/gwL7NDU3oAlLXM?= =?utf-8?q?wKcbbNIU306n3jefJv5V3DN9jExNn6EeQRpz9hjAglg0AHz5NIOWnIpRAnu1WIw+v?= =?utf-8?q?M2qB8hHKzP+t7AF6E9S/eOS27POiAa5KsZCd0uhIUq57lIQWR6eqxH1R+6UJTuANt?= =?utf-8?q?nzwBNv890N5r5JyKHTZrfMHTq90ueq8XVtAMDuPiZc383ykphrTXy7nyVnhvzbFII?= =?utf-8?q?JGC7+hTeDN0gg0yQ93z+VDCy+T7B60EoKEvGXL1y2VqDcWOc33al5KeWQIXv04SX8?= =?utf-8?q?YKSw46OiidouIM4EIKpJZiqtim+a7oCNMNpPi/NWtL2v31fS8KyanZz9SNpk8cdY1?= =?utf-8?q?Yx1J4rNPrfyi1IVzDfa2V2fo6+CD2zFBKIY+0iCcvfKwK4R+I+EuxfFc=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3dca980b-2c80-4fb9-6761-08dce1800ded 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:28.6513 (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: l7mbLDPhPTHcjMWaS0Mosh37Uj0kCbVR3Wy9o4htAuUgwKz2rifkgXLELDmYlZGDIbF80FbuUOELuvZWaZwPqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9884 Remove cpu_addr_fixup() because dwc common driver already handle address translate. Signed-off-by: Frank Li --- Change from v2 to v3 - none 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), },