From patchwork Tue Jan 28 22:07:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13953235 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 53938C0218A for ; Tue, 28 Jan 2025 22:11:31 +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: Content-Transfer-Encoding:Content-Type:Message-Id:Date:Subject:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=dCKQlEJpo07jU5EJjFnfLwPZs6tuTxamS8VyFtNvFOo=; b=EcgfzF5smTmWNa5RJ/VEDJivRZ MvavPbsuCuUDrPgoFo3hBkTe7JE4zkR7msXEWt4/hWVPXOkr4pLZ1vh/kxFhO/Hml1RAEhciQ+bEa 93gzKdCPXr/x4Nlxo8tC31ACgBPTmR2AsyTCUZ28KvXxSXyuuoQuEqVlWIDLgzlkpGNt09YUNr3GI XxCQVdwJ70Tpd5K6p//0oNmsn5EISzElvmeO2W2bxajIEHu1HWgT7PcAnlz0ssC3snABdHmFdmK50 37Rc9XFfxVRhcY6od5ir+lq9wMIlL+8vQ4qXyk8jgyYDeKpt9XEtOAKuDYXdnBOQNaLaeuNzQKS57 ciuKgXSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tctng-00000005uBc-3zSi; Tue, 28 Jan 2025 22:11:16 +0000 Received: from mail-westeuropeazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c201::3] helo=AS8PR04CU009.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tctl2-00000005tXI-17OS for linux-arm-kernel@lists.infradead.org; Tue, 28 Jan 2025 22:08:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uqG9d19yj/K8m1Y2m/W6VyiNqi/8Cc/IKJqFsfACYgX9/vbB03B67Kt3BXZeey5xVr4II4UKPE+7ZSEquynihmhanB+7kyKjFtgd6Ozjkn6QQY8FALxjELUKPDERLysokwPwVu4mqbG5xKuXdBw3WAXxCYLB80XI+PrEvN/XlIPJKR88lL3bN3RCvxWmnCYSDbNUfSFYZ+uMRaoifeTXAT3vMBjMD2GCBUs1Z4VFpEHuzArAjc1y1te0ONk6RN0ro47lBUOP3J8Vx7eOnhgk6kwvyHFs3uOrSKnO3mDlSmWrWr/EaT6QML6pjernpukk46FusVADn5hhFr1qm6VnPQ== 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=dCKQlEJpo07jU5EJjFnfLwPZs6tuTxamS8VyFtNvFOo=; b=LX1ygmzWPtNMJ/f4Q/mgcKGzn9UM/sKTgSR4UCISqNNusYuSXXZ/X6yMQRUxIF45zgho8hu8iLFim876QdUvBSsSeAwEN4FXd5aQmzUfDvn2fdqLVIxaRYLl8HQm7brA/mj+tpETkfamWunZzVx7Ij7diaUWQpmRjL83estUTZdlmmorgyUx36H1eET0WUsTWY0Lnw5KLRrP4Arxh4IZKgznAFgsG84zEoVdLkHwLI+BMnTSLchqPyFlrqZ0inMyLoo537h1NOZoHAm0olcHsYJISIYSmbLwSlDgrS0Zwrt2ICxpOz+VkKnhM5XcZNYbl12fw7fh4dwM5CBTHI/7iw== 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=dCKQlEJpo07jU5EJjFnfLwPZs6tuTxamS8VyFtNvFOo=; b=OCtLSXagppTlK1NixDrohuEs7Il1EesBE3Zu87awi3vsx7MUfwgmbGf0t+nQv8kqQie+spg30JBxVwmqGkCGNSK9bgi/MF7eBH1Snkj0yob49FISvZmZwFQovepyQjEYoWcTll/j+gDr8F856YA/0JpTGtxeE827R03GPmGpy7UoDGIMJCrF3KA69OCZTP2BMebPZR2NKaikmFJwfvgeSn+HwvwD3ZdSQR06h7SCkCOfHix7ENYyKQ5nczlKN351S6FaFga23Flm1qI89PT5DGvdplaKUKJru5u0Rn7w5mCH535U+cQ16UFq28R/VOA8plWw8a1JRXK9mb98AeKhtw== 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 AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.18; Tue, 28 Jan 2025 22:08: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%5]) with mapi id 15.20.8377.021; Tue, 28 Jan 2025 22:08:24 +0000 From: Frank Li Subject: [PATCH v9 0/7] PCI: dwc: opitimaze RC Host/EP pci_fixup_addr() Date: Tue, 28 Jan 2025 17:07:33 -0500 Message-Id: <20250128-pci_fixup_addr-v9-0-3c4bb506f665@nxp.com> X-B4-Tracking: v=1; b=H4sIACVVmWcC/3XQQW7DIBAF0KtErOsKhhnAXfUeVRUZGBoWjS27t VJFvntxFo0d1OUHvc8MVzHxmHkSL4erGHnOU+7PJbRPBxFO3fmDmxxLFiABZQvYDCEfU758D8c uxrHpHBmXWu+9RlHQMHK5vRW+vZd8ytNXP/7c+me1nv5bNatGNmSjwq5VHDC9ni/Dc+g/xVo0w xabCkPBjARIqDgm3GO9wVpWWBfsJLOVmiAFu8f4h5WUrsJYMBATSGnI+rDHtMGKKkwFB45EJjg CK/fYbDDUL5t1Z88+RJcipocPs1vcVtiuO2slYwBM3j6M7e5YqRq7dWz0qSPVanDujpdl+QV7L SwFVQIAAA== 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, Niklas Cassel , Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1738102098; l=10225; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=a06cLjebRMq7iVPAnU7NaTP56h6NgomTtXaHUCU61ck=; b=WhuK03KvdPNB3OnChJxT90PK3fbE4w06akDL2LQLSJUnAPC+YM3//NtQsGFkvx9KEkQdoVgBy dKuApUHNTTXDEGilPbfO114NnuFfDT4ACRLy872LzqlLrBocc7XO59E X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0130.namprd03.prod.outlook.com (2603:10b6:a03:33c::15) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8555:EE_ X-MS-Office365-Filtering-Correlation-Id: 76cc1474-a4fe-491d-836b-08dd3fe848bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?L0svzdDhfXyudMbA1LnS+XyGdLtND6r?= =?utf-8?q?H8muRao1k7/e9fLs5CNwTFv7UCPNkUpN846ldSOtQku2xcZxIs4qHw/WLdMaXGDrU?= =?utf-8?q?McrFwM+nKrbIxqrCan3RIz2l0xjRWfZHPlXTv8I/bSLHjW+KDOU7UAkbLr8ps5Qz+?= =?utf-8?q?a8M/VqBEfLmp686uJH3fSjm1hvOmLA9MsSh5uZUmNfeBWEZ7cnRYrukfRKxZCvytX?= =?utf-8?q?uxjMQ2WEpL1B2emUiC0f2zYMJu7LjMrrVidCb0LyrnQdR2gp45FqyABRxwTNFHj+R?= =?utf-8?q?IhrKxkQ5KgG5CJgw0xwP9YrtH1r4edyDGblrOING76JxA5KkR7z67Xu2pkhZPeQMm?= =?utf-8?q?4QRRRgwAmkQSiO8Be+ncmgPIngjRkFVZasX+V7A24z1S1ajLaSoHQNTJWhEIz071L?= =?utf-8?q?lL1oQyha2VyS3PcbLboafO1SWCW7ezyb1dbXg6CKsz+gzxoNqAjXbhB+8N/HFGh5C?= =?utf-8?q?/iEAyqapXUjJnQ9FEw7BBxwgH/yFiSQUt41Q2rYPvXreswaU+1SJ8Wc2QmewJS47o?= =?utf-8?q?7c/dp9WtMWC1263y/qYVbwZlGsrYfarFgndYkrp8X4erIEdOTaWMbUqi9QS+VAdIB?= =?utf-8?q?/bwj4T2j3pOgd5hkwT8+Xh2u+JzjxCnhQ5b06AxTPucvrji++4wIupLdOzzMVeVwh?= =?utf-8?q?cgpRIqcSYcgCvRXuJGUETcNCra31pwMHXVs4XNxhrJh0Rs0KYggrF5XYKL0je/5ul?= =?utf-8?q?XEVUCmIdjq259XmmT+FadZqUd8DQPMswFx3dov3DQwaUKOo7luA3D0YVotSRgrAiL?= =?utf-8?q?/XbEopYB+5wQjGV1y/hLuxBcQlFOnSecdJ7kTDc4w5FBkZIWd+PCUQbFfF7ZhPEh6?= =?utf-8?q?bvUlD29sNgaDf7H0XslhaRET38Y3+wPc9DMW5ZeoOJDILS6mQpJjdNuW/gZ8AI58k?= =?utf-8?q?fXd9s21KPZoXK7Qnq+6p6t41kGWYpPNdedUNO4ubzQ5mM2h0HtIknuW/KtwMKCX8A?= =?utf-8?q?0ibq/5VRhcbUQ+iRNfsqHkNUVI8jpuknw9UVCfBE9XHB3bcXzIjm/u9GF0t5P1F40?= =?utf-8?q?NLZEQKDxhpFkJx0taknqyMIjiGyBARW6PZ016Vl4I612/Z2KZ58RK9N5x+wekqWRO?= =?utf-8?q?XJHTyMhVJhOEbwHeh+AP6XYeXtsCvnMiUdmvZh3icGQYBIdIypbSdMOczNES22kKp?= =?utf-8?q?BA4qBAdiDs4oMcGYL3APkTVRoo6EdgRxjKZ2XG7YMLqso3W81YHYdYXCZfpB+cbYm?= =?utf-8?q?CyzjZ4txvZrWa9EbwDrSttaHrBl31CZh3hPA3kFbX5oQtpk3ZDQNPpX+GhwtWR0eb?= =?utf-8?q?3Wc6vYDRsvZEEYft8J3VGTRnDEYmktwI4gxRWb6J2WAaOiIQSUF/GOBMdfaWMKb7/?= =?utf-8?q?21q1Ffzsr4vqM9DYg0+2vr8pjxPcQFHsMA=3D=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)(1800799024)(366016)(7416014)(376014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?H0eI+7zgrQJDZjUp058MX/rSP9ok?= =?utf-8?q?CxrG4b0w2n7mDlZwaFyraoi3T+lUz3BYwMhO5bpj0nSv3AlW2zPOUyA+iRb8onQ83?= =?utf-8?q?vc5mnWtwgr0MkCuFE6WU6vur1bvBVwoO2u+kVlFyE/ATM6G7t56XpLluUNSSwViLu?= =?utf-8?q?USh+ou8myacGsXssAon7EzEYAmlUtKyIcRO6n/6xdG3sZsgn+5iTOy9hBFTtfQ8rH?= =?utf-8?q?6k9C5dRriMqWzV3v3LM8esG0GDApouk9GV97N9+ieDxWAOnF4ZL7Bb6+4ExBnKPhc?= =?utf-8?q?bjZG70SUEpJEO0lrGx8jEDYZ7aMP5tcvcPS+szceNXaYEGvH++dSZtGqc3qqGt9sS?= =?utf-8?q?a7iV0OeiAmF00Ve2Fwu7qEScCR3iCMa08W16JvBK0ZouKMMD1mDGfT5c5x5aEaaMb?= =?utf-8?q?Od4WeMACWvquOy/O4vsZ8dWnhBA/k8nZXCRZEoCCZC/w4y5kHqb8TziGhLubtvSOn?= =?utf-8?q?l2qa+igT8Zu0E04YJAXPfvXZJWYriVDxVRL0Nm8TvcxIfcpK4Mj+F6uCrrs61K2LW?= =?utf-8?q?KpLqkxhjW3gQqZMBNT3KR0xSeaJYDF7HUY85X8sih3xOQqa3SkEZ7NmVctOD/O9/y?= =?utf-8?q?iecnQG35QFD5AopBTdjmWhv4r+cSXb5gWQGagw92jpfaOkNySALYzk0Rjwa3Pedh0?= =?utf-8?q?QR90C1ykwOmCHL8gPrnyJOmLdtOLCzZrFdHUYCGVIY4GcVk3/y8/wR8n+9rGx/IXp?= =?utf-8?q?Cz0SUrpa7JdnWhIRNfDuRIVhlIZfMg5Rp59We9ggdJZTpuwISG6dX6qr4X7pGedrR?= =?utf-8?q?ZKZLpRiQBPjLQRubmStj5+YTdm8BURDt5CsMs9J2mhWwXR1ipFPL45xONx6wwtoMy?= =?utf-8?q?wf+1t7KRoO2KLk495WPPlzcl1UzNBDsuHIgkJNOTgm/0HcytLAY7eSOQVYpUJZHmO?= =?utf-8?q?br1IdhAIbpI/ttpdxYEsye3rMkLE47dDS+OUMxPpHQBxc98Q0bn9xHm0c9wz3diu3?= =?utf-8?q?O8BWUIbI955Xsj+vc627rlMqdoMCF5pQs7o9ToLycGtD1Uxap9IR4jbXiojtwdIbp?= =?utf-8?q?FCVnF50jSaFzFP3y/nTYCkBg8N7CAT8s1oEs8nPrgmm201uKp4tMvzHtanaE+RywS?= =?utf-8?q?MHs+So0ga9tKtFZI4ONPe1D0TGyhpeGHixtSkYGpAqk/5vC/gsAMTAzuWAZhRyWda?= =?utf-8?q?I5/qMgiIK/CkoIvL8HPVA3uWS06/BrjZ2+DD8221q/A1uD5KTONFfMmQbq117h3zF?= =?utf-8?q?dH55yUR1gJmghWw1f21v6LXZaDCFnwBTJLtLGkRtFVG+4FF9M+mlHJfDMDk8B2hVi?= =?utf-8?q?cWUbbLNHJpwLwC1UjSTd0DnMv8NxjEsRrEUv7MlTZ0s+gobSKWZjyDT+Mcf+j1TH5?= =?utf-8?q?PGRcOHPFYMdWxTnCd8izni+njGkMSpeB6vqz3LrKUBx949UCcq2P08L50mnWDgeDm?= =?utf-8?q?yftOUA5LlfdNo3aL+YgxN9e539q7HVVq9JRQg+IN4mcS8f49ybkZQJBjx2SuoJYdh?= =?utf-8?q?9pLo4CB1Z9YNcrui8Err+ubUgJlAxGCNzIZX6mUJVcn1F+CgkKYGrRW2laRzTGXTg?= =?utf-8?q?N3cTC2HmhTt+?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76cc1474-a4fe-491d-836b-08dd3fe848bf X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2025 22:08:24.3228 (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: 9Q9GV9+NHq7K/bxbS452SCkLFnGGvK55qSyCgutHeBVSMqBbdgUFWxSx5xjkaaMftI+rK7ixrkWrCNBLWrvsgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8555 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250128_140832_459815_8C9A9C24 X-CRM114-Status: UNSURE ( 6.20 ) X-CRM114-Notice: Please train this message. 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 == RC side: ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 └────────────┘ Current dwc implimemnt, pci_fixup_addr() call back is needed when bus fabric convert cpu address before send to PCIe controller. 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>; ... }; }; Device tree already can descript all address translate. Some hardware driver implement fixup function by mask some bits of cpu address. Last pci-imx6.c are little bit better by fetch memory resource's offset to do fixup. static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr) { ... entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); return cpu_addr - entry->offset; } But it is not good by using IORESOURCE_MEM to fix up io/cfg address map although address translate is the same as IORESOURCE_MEM. This patches to fetch untranslate range information for PCIe controller (pcie@5f010000: ranges). So current config ATU without cpu_fixup_addr(). == EP side: Endpoint ┌───────────────────────────────────────────────┐ │ pcie-ep@5f010000 │ │ ┌────────────────┐│ │ │ Endpoint ││ │ │ PCIe ││ │ │ Controller ││ │ bus@5f000000 │ ││ │ ┌──────────┐ │ ││ │ │ │ Outbound Transfer ││ │┌─────┐ │ Bus ┼─────►│ ATU ──────────┬┬─────► ││ │ │ Fabric │Bus │ ││PCI Addr ││ CPU ├───►│ │Addr │ ││0xA000_0000 ││ │CPU │ │0x8000_0000 ││ │└─────┘Addr└──────────┘ │ ││ │ 0x7000_0000 └────────────────┘│ └───────────────────────────────────────────────┘ bus@5f000000 { compatible = "simple-bus"; ranges = <0x80000000 0x0 0x70000000 0x10000000>; pcie-ep@5f010000 { reg = <0x5f010000 0x00010000>, <0x80000000 0x10000000>; reg-names = "dbi", "addr_space"; ... ^^^^ }; ... }; Add `bus_addr_base` to configure the outbound window address for CPU write. The BUS fabric generally passes the same address to the PCIe EP controller, but some BUS fabrics convert the address before sending it to the PCIe EP controller. Above diagram, CPU write data to outbound windows address 0x7000_0000, Bus fabric convert it to 0x8000_0000. ATU should use BUS address 0x8000_0000 as input address and convert to PCI address 0xA000_0000. Previously, `cpu_addr_fixup()` was used to handle address conversion. Now, the device tree provides this information. The both pave the road to eliminate ugle cpu_fixup_addr() callback function. Signed-off-by: Frank Li --- Changes in v9: - There are some change in patches, if need drop review-tags, let me known. - DTS part: https://lore.kernel.org/imx/20250128211559.1582598-2-Frank.Li@nxp.com/T/#u - Keep "use_parent_dt_ranges" flags because need below combine logic cpu_addr_fixup use_parent_dt_ranges NULL X No difference. !NULL true Use device tree parent_address informaion [1] !NULL false Keep use lagency method [2] Generally DTS is in different maintainer tree. It need two steps to cleanup cpu_address_fixup() to avoid function block. 1. Update dts, which reflect the correct bus fabric behavior. 2. set "use_parent_dt_ranges" to true, then remove "cpu_address_fixup()" callback in platform driver. Bjorn's comments in https://lore.kernel.org/imx/20250123190900.GA650360@bhelgaas/ > After all cpu_address_fixup() removed, we can remove use_parent_dt_ranges > in one clean up patches. > > ... > dw_pcie_rd_other_conf > dw_pcie_wr_other_conf > dw_pcie_prog_outbound_atu() only called if pp->cfg0_io_shared, > after an ECAM map via dw_pcie_other_conf_map_bus() and subsequent > successful access; atu.cpu_addr came from pp->io_base, set by > dw_pcie_host_init() from pci_pio_to_address(), which I'm pretty > sure returns a CPU address. io_base is parent_bus_address > So this still looks wrong to me. In addition, I think doing the > ATU setup in *_map() and restore in *rd/wr_other_conf() is ugly > and looks unreliable. .... > dw_pcie_pme_turn_off > atu.cpu_addr came from pp.msg_res, set by > dw_pcie_host_request_msg_tlp_res() to a CPU address at the end of > the first MMIO bridge window. This one also looks wrong to me. Fixed at this version. - Link to v8: https://lore.kernel.org/r/20241119-pci_fixup_addr-v8-0-c4bfa5193288@nxp.com Changes in v8: - Add mani's review tages - use rename use_dt_ranges to use_parent_dt_ranges - Add dev_warn_once to reminder to fix their dt file and remove cpu_fixup_addr() callback. - rename dw_pcie_get_untranslate_addr() to dw_pcie_get_parent_addr() - Link to v7: https://lore.kernel.org/r/20241029-pci_fixup_addr-v7-0-8310dc24fb7c@nxp.com Changes in v7: - fix | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202410291546.kvgEWJv7-lkp@intel.com/ - Link to v6: https://lore.kernel.org/r/20241028-pci_fixup_addr-v6-0-ebebcd8fd4ff@nxp.com Changes in v6: - merge RC and EP to one thread! - Link to v5: https://lore.kernel.org/r/20241015-pci_fixup_addr-v5-0-ced556c85270@nxp.com Changes in v5: - update address order in diagram patches. - remove confused 0x5f00_0000 range - update patch1's commit message. - Link to v4: https://lore.kernel.org/r/20241008-pci_fixup_addr-v4-0-25e5200657bc@nxp.com Changes in v4: - Improve commit message by add driver source code path. - Link to v3: https://lore.kernel.org/r/20240930-pci_fixup_addr-v3-0-80ee70352fc7@nxp.com Changes in v3: - see each patch - Link to v2: https://lore.kernel.org/r/20240926-pci_fixup_addr-v2-0-e4524541edf4@nxp.com Changes in v2: - see each patch - Link to v1: https://lore.kernel.org/r/20240924-pci_fixup_addr-v1-0-57d14a91ec4f@nxp.com --- Frank Li (7): PCI: dwc: Use resource start as iomap() input in dw_pcie_pme_turn_off() PCI: dwc: Rename cpu_addr to parent_bus_addr for ATU configuration PCI: Add parent_bus_offset to resource_entry PCI: dwc: Use devicetree 'ranges' property to get rid of cpu_addr_fixup() callback PCI: dwc: ep: Add parent_bus_addr for outbound window PCI: dwc: ep: Ensure proper iteration over outbound map windows PCI: imx6: Remove cpu_addr_fixup() drivers/pci/bus.c | 11 +++++- drivers/pci/controller/dwc/pci-imx6.c | 18 +-------- drivers/pci/controller/dwc/pcie-designware-ep.c | 29 +++++++++++--- drivers/pci/controller/dwc/pcie-designware-host.c | 46 +++++++++++++++++++---- drivers/pci/controller/dwc/pcie-designware.c | 43 ++++++++++++--------- drivers/pci/controller/dwc/pcie-designware.h | 11 +++++- drivers/pci/of.c | 12 +++++- include/linux/pci.h | 2 + include/linux/resource_ext.h | 1 + 9 files changed, 121 insertions(+), 52 deletions(-) --- base-commit: 5fcc194143ce5918ea0790a16323a844c5ab9499 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li