From patchwork Thu Mar 13 15:38:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 14015330 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 EE123C282DE for ; Thu, 13 Mar 2025 15:41:02 +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=lK5YeNREMBVecH24ZGiSIonHbvkzk+LL7nXsLemZt80=; b=4FILlDCAO2AkLaghZUNdYeXO+A QYLnsIZV4QF046zu7fJUp1MZ2HkgTnn1AnG201RfIAcHE90dbSAQhS1MvyYPCs9xEFtCXB6fNvasd T4Fa18w5fHsJgcbfp1vr3h9i/pr09iIzSq0b1sKR6qJgTvmScF71vLcPLX6bht/BLzbISYPJ9qaGN d5qv2xQ7QzFJmOQsEVm7FfK8FSbbvMI6l47ijYgYG691KFo3RtcBZgh3z0I1Z04QPexRLKpBS4rqf anQXBlfjfvgP2pnFmGJn5puX0fSXrcaJM8N2+qoUu4aLRyW3FS/1695HrRXtDk5yp2+5F/pFExhSI qlGH3RYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tskfv-0000000BgpO-3ZZK; Thu, 13 Mar 2025 15:40:47 +0000 Received: from mail-francecentralazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c20a::7] helo=PA4PR04CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tskeG-0000000BgVm-0L2d for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 15:39:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UA/pxpmt/fMMgwCQJs9WJCtD20RT4sNxyKTLFKjlIIciu/OjPKBuP0nS/biof4ueXnNwkfuLqvzyY8ewSiTW4YA4KbcuD/O6WjojOm1G0Vi5LGpR7RC7gBJMpOT92GS8MmgUAkNN7C2vvoyxLInBEETGiCi2XCSmHtgwh+BFje/wgPQbNuocOto3jEtEYLYZNpFlwNoouhEYbVpXG/3gZ0shyhaI7FBk9c5TZPqg+VQY709Du5AP5ep1TI6YC/pWMe//jeGV3kiH7YcoUMdGNsv2agDFuPYKPmdRWaFCAMljLd6nrqBTy012v0ZLU9c9hVt+9AH5ZPQelOsSLqAcSA== 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=lK5YeNREMBVecH24ZGiSIonHbvkzk+LL7nXsLemZt80=; b=LsdRqH6vXRTkaQNo+M/zZUFUFi5zSR6t0X7hl3iJQWNRQCM90Uj9DwZaHM2Rx9sAORN/A2CrA2JizkspTJvEBgsA3sXhWE/XBkO3tbVsjCcjjHIuhOjjDhr7wFwN9liBKdgWCW+FiR4bLMch5l7PRxJnfBcim5wDhtnHc2Pq8FXC1l0BYgpsVcLRhC7x6FFSXK9+HsPvPnlpxKwpjNoCyZluZI1e1gT0gHAtRxB7sujkpRwBj9PgB+yGtfa1b1x2S597IDW5cD+7NB+d0kB+7tUwntvp2yBsvLraONnOEsL4o5OB9KCbaxluo0vkRwsLu6wP+TWk1XvmUYfbHbh6wQ== 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=lK5YeNREMBVecH24ZGiSIonHbvkzk+LL7nXsLemZt80=; b=SBjkTvN02HETKv3j9tB/4WT/Do4DujJxUByAh0FeNgOreyS/w5+XuK+zSV3alew7vSzIh5+nZlU7wXL20by21aiJAyZaOUs7onQZQsY+Oo+0uqzR7034u6WBojS4NmQyvExLLfTAdGKy7VOQAVo7H7WZ1lV6bCGNHMZTpeyYaUlzMiOVj4f3jSkJapHC4k5VOtyQjOETP5gLoB7ELFgztlC4dKTuYrozmkKyNUS2T0ilmMcRkinzWr8FySdkOFEgOA9i0NeNP4go5p2sAAbykLWT1JrVinBFLtR3b9pSTSLLDiMrmSqd2vu+Pqi2K7OsdugwjFqeToMqwJLCyzHVtA== 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 AS8PR04MB8119.eurprd04.prod.outlook.com (2603:10a6:20b:3f9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.25; Thu, 13 Mar 2025 15:38:58 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%3]) with mapi id 15.20.8511.026; Thu, 13 Mar 2025 15:38:58 +0000 From: Frank Li Subject: [PATCH v11 00/11] PCI: Use device bus range info to cleanup RC Host/EP pci_fixup_addr() Date: Thu, 13 Mar 2025 11:38:36 -0400 Message-Id: <20250313-pci_fixup_addr-v11-0-01d2313502ab@nxp.com> X-B4-Tracking: v=1; b=H4sIAPz70mcC/3XSyU7DMBAA0F+pfCZoxvZ44cR/IFTFG82BJkogK qr670wqQZMajjPWm8X2WUx57PIknnZnMea5m7r+yAHiw07EQ3t8y02XOCEkSA1e6maI3b50p89 h36Y0Nq0j44oPISgtGA1j5tNrxZdXjg/d9NGPX9cGMy7Zf0vN2EBDNqFuPeaoy/PxNDzG/l0sh Wa5xqbCknHWJDVpzKnoLVYrrKDCirGDnC0okiXaLda/GAFchTVjSZkkgCEb4hbTCiNVmBjHnIh MdCQtbLFZYVl3NsvOIYeYXEm63F2YXWNfYbvsrBBSlLoEeze2u2HEGrtlbB1KS+iVdG6L/Q8mw D/G9owV60BgijG0xQg3zePVvwSY8zOmtkRPkPDGL5fLN+B6N6fSAgAA 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=1741880335; l=11419; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=bsVAvtMPXhtzXgtL6Wb6Sy7O0pN0v30cPUA3opxY/2c=; b=iPqQqSuVkro+QkCP+3xdwK0rrJvnEzWHUqQYwkC/dG69I47vFa1nX86z4xiZ/Y0H8MIUVQXW2 eQPEZthWTkqBLzzOjhF12XqP0DuLywOX7o2fe88lFG7qTUevaD6dzoK X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SA9PR13CA0038.namprd13.prod.outlook.com (2603:10b6:806:22::13) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB8119:EE_ X-MS-Office365-Filtering-Correlation-Id: 08772614-7550-46f6-a704-08dd62452be9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?9vOW17G8yZqCAlOLDjTuMJLtb3VS8Dw?= =?utf-8?q?IocbOy//68HuiY6KmMQjlb0nViwU7UMSXUMw0qZtZkQXiL0r8cFgBJOhCjSKPPZn8?= =?utf-8?q?Wnouahds2WbioXGBYTE/bt7Ol1uiRlcgOvKTWan/bgYs/bwOQoN3rd4lGLnsjnhAB?= =?utf-8?q?M+p/3T9nSKkv+zcYsSpa0c3nSM7zgLHkb86mhL2YarW2k0I+xcr01G6md9LJrWUeR?= =?utf-8?q?HnnNE94p5/N41fWg56ZZnSO0BuzLrsbadHFapEpo9TIei5xM1BSRZth6qp2VQ/wPy?= =?utf-8?q?waZJgCLQQ82QKDsVZ0Ps8um9KZraiDI6hyJRCxvt/52gVUCS3x1qE2UtMQY6z+diT?= =?utf-8?q?nFKsWiNrffRCmPiOAvXw0H16w+yXVwdYRnvRV4pmuv6gkIEaBtLySi6C2+su1cc68?= =?utf-8?q?9iMBu1wtQ7Mg0Tyd8ymCtu0VxZkIA/RwJ6U74Sy1fPXLNW9O6ZdrIEU0jRtvhSrqG?= =?utf-8?q?lY/2Nx/C393S9dnC89CR8eQA8rAnpM0Kd8Aak4KeozWiXD2Kli7U0WZOgBFx9Kute?= =?utf-8?q?2Iphq8cE5uIkfeuv+zSWktpVFPDSlv4vv0HeX/q2qBYOmX+0KjYnQyfrxH3fvz9G6?= =?utf-8?q?s2ddrQ8at3DZDchTx8bDMTsHDneJ/GqUmBalQZZAZE46GhK8yVN9LVXcngydvGM5Q?= =?utf-8?q?nCywBte4tvQa50ZpqP6JPcAzMqTsq7Xa+dFHO7cmBXRaroEKq64A9Ke5BFy56uRlM?= =?utf-8?q?VWPwTrJ+U/A1YuX7v3tbXnCCFy0NN3iT2TYrmETmHxru0FDN0fufz4SyotAFL3ZIQ?= =?utf-8?q?drkgI9JwOsVLhZYvcDeZB2eWYcHbmUegXKutIxLT++lAKRYeprKwK0QaUUUa156w9?= =?utf-8?q?/HkjEdgoRW8241fAi6fUbK5ZdR1zSNsbevwUIZnKIRxaFDXcwicqODv0uL98M+5zw?= =?utf-8?q?zI4IsRUBNamUGSLih+Y0MAr1FjIxjsiAazeg1Wrx3/9QHI/0dRvRrQOe0BZFm6NJE?= =?utf-8?q?tl77HN+vR6AAXA7ks2rF43ZEaDETJk/k5HN6gs2xt57bT/HMPtGl8use87XJNSIf6?= =?utf-8?q?mj3eIPs8MFCDcIX6nS7a89oiwQYVv9ijE9lAvyxmHKPXPJ7uI30+BoSLOlm+fuscu?= =?utf-8?q?uUYf5EDYcXbHkrNKVDLySwLWB6Qi9dhBBnxhK0/POiAc4lghrTlDRuHzChGyL0cBd?= =?utf-8?q?475q4x91CCPv7iNYrHqOxeO49njRpEGiOxiAjnzJj9XoLw6cl8GqBLB4Hlh/YFNJS?= =?utf-8?q?aRuGGyVYSvWeyiRGrsKqNLDMdlbIYPwSDXQ94KnYfpkico8cfIeyS5kQpeQReL3HT?= =?utf-8?q?7I0iDWOZDuwrMBdhpU1NYQzFTIQagnkW9OulScNL6ZBpVOwgVyt4630P9vcdWDBzu?= =?utf-8?q?cckqLJ/sPLuflK7M6T/AbpGbLIAdx0ItVw=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)(366016)(1800799024)(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?r+Opx4fUleM+4nSTEaLOk4ps+zJJ?= =?utf-8?q?E841vSj1nofJ9jtusqMa2uEsMSG4vir2tFOxh7UB/LmpPOXhICtLj6Vny9s6Vag4e?= =?utf-8?q?H3sQ1SeRGajjz9O/rajlitxPtmEy7NvTa7jyAKRSD10Z7H9bD8P7mytLB2g2X+bNT?= =?utf-8?q?AVzaNKTY8YLE0yS5crNU5ad2zZW0p59A41eIZR3ra7/wzNV3YbCuHdwmwxYStaQsm?= =?utf-8?q?WMylLMoq+e/0jU7b81eav++jf+9Zibc8IaMBrRAA1zvEW5VrfAenjaiEaXShvlNf5?= =?utf-8?q?IF95IhJnJf2XmfW4uxDF3s1pZK/WdOX/fgGOOGZLIIAwDyG4fkzlMBYjWBFKjOhgM?= =?utf-8?q?PUUUObyfNHsM4vjrdYkDsJmYG5+1LGgpQUjTlTslTJyuTllh59mXSwyfHc6Rt51VQ?= =?utf-8?q?dlbitF3vpLgrSBx6xGVCUepoe0vTfuwx30jd9UNMdI3ZnKKvgoFGJ7Or+46w543Ry?= =?utf-8?q?cY1l+w8ocBjs/X7uBlWIp2KdREiTtaFdhc/WExGkiCFeD3gQbPOBgKkdrHXaPc6YM?= =?utf-8?q?Gp9PGBSGdfNVFdvwhDWfyb5IPVBckvorLngexOC65YdSL7s19OZYTOkMHyY8bbUa/?= =?utf-8?q?5Jw/4xHwbihcwHcaVZx7m0yGSoZ8c/qdvkH87yQ58YF18CvCml+57aj9QZOf6NAsA?= =?utf-8?q?TN0TqHNvmGmpLvm1TStsRcPJnDDS9sQPhQMMKvlF2BrU6wW8jCV+n3Xj6UpN+PHIM?= =?utf-8?q?eVonVj/b9+RfFkIX/8uhRYi0I0m5XkCobDW5fA8tEBjM1QUs0M63ST41atQWzbPrB?= =?utf-8?q?Lsr51ScaPAy7Ly2JSgsj1mOoaX5NH5XKyoFqCWC6HtYHTKXZ1YUlUcj8guiB2vsYt?= =?utf-8?q?08agJRLJ9mn3FRoHx3MTnkbFRxIx+S4Y6JkZWnLcbC722WW/q1yS8aTyOHa0owoN0?= =?utf-8?q?vaeqTzCrWz5phjVFz9+KfjcRrzRL3n+ZCrbM4PpgTgzadDZXdvZlpJFEJtWN/wv2g?= =?utf-8?q?t0soGwNtEsdQDOhTUroPCwTqXnSe33XfYjmegRIDuf6wgpur5/ogwo32OlGYSJJOR?= =?utf-8?q?QU104jzEQCBSkxqlzGvXbDy9TheYD5BZtS1ZR7gJfwdB+zZ7JHMENa1CWcYotXyvx?= =?utf-8?q?Rh69p5EmyIDeqNF6lVduAjTjV2LkEV5svishYmjlr7tsELN5p6f8uBXu2hQZ0xJ4u?= =?utf-8?q?JctBhzeiIyf4Dok2PZERKh5yuxIn5Pwz/QY4g5VMKgXjjAEekWRrVchaHaGUir0Th?= =?utf-8?q?/MEArEvlgPlrNqTCf8Z1da0uvIs9P6h1v4iAyzeOLTOhuNHNmWwz6JfizIjFw0twi?= =?utf-8?q?rSqQvK/pYHSqK3NgPwvTKJPBVQwaebIcfHLS15aHHj1NIVzVWHl8oRld+eGb9E6+a?= =?utf-8?q?UQ4Tk69UCjKUYahI3x26oYCJ8IQJDMlI1rzISHUiw7xzcL0HajOlVXvdPEh8cOejI?= =?utf-8?q?lgaXUx1w0dIZTGilb8I0JCJ3CNjAgfIsH+efzGhn3U6Bx9WciDyj1jmuDkbPccb5P?= =?utf-8?q?mtr71zA8wjLroISR7uBb1io3qbC31Wiqv59CInWxzEngTIuJuOX+RCYQ=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08772614-7550-46f6-a704-08dd62452be9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2025 15:38:58.6976 (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: aTi6TD/ZpZnxaMnRBmO5FS1lat3ElxcSXGKOF8djfFi+mdRem0QKXW4L728Z/1TaZ3AjP2NOmixOKr7y40llKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8119 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_083904_265990_E4EDB507 X-CRM114-Status: UNSURE ( 5.90 ) 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 v11: - Add patch for Move devm_pci_alloc_host_bridge() to the beginning of dw_pcie_host_init() - move PCI: dwc: ep: Ensure proper iteration over outbound map windows ahead PCI: dwc: Use parent_bus_offset to avoid broken bisect for some platfrom - other detail change each patches's change log. - Link to v10: https://lore.kernel.org/r/20250310-pci_fixup_addr-v10-0-409dafc950d1@nxp.com Changes in v10: - Remove patch PCI: Add parent_bus_offset to resource_entry because it is detect by reg-names["config"] and reg-names["space_addr"]; - using Bjorn suggest method https://lore.kernel.org/linux-pci/20250307233744.440476-1-helgaas@kernel.org/ - other detail change each patches's change log. - PCI: dwc: Move cfg0 setup to dw_pcie_cfg0_setup() is not necessary, but nice clean up, so keep it. - Still keep use_parent_dt_ranges in case some platform without cpu_addr_fixup, which use fake address transation at DTB. If no one report warning for sometime, we can remove it safely. Bjoin, if you think this case is rare, you can remove it. - Link to v9: https://lore.kernel.org/r/20250128-pci_fixup_addr-v9-0-3c4bb506f665@nxp.com 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 --- Bjorn Helgaas (3): PCI: dwc: Move cfg0 setup to dw_pcie_cfg0_setup() PCI: dwc: Add helper dw_pcie_init_parent_bus_offset() PCI: dwc: Use parent_bus_offset Frank Li (8): 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: dwc: Move devm_pci_alloc_host_bridge() to the beginning of dw_pcie_host_init() 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: dwc: Print warning message when cpu_addr_fixup() exists PCI: imx6: Remove cpu_addr_fixup() drivers/pci/controller/dwc/pci-imx6.c | 18 +---- drivers/pci/controller/dwc/pcie-designware-ep.c | 21 ++++-- drivers/pci/controller/dwc/pcie-designware-host.c | 75 +++++++++++++------- drivers/pci/controller/dwc/pcie-designware.c | 85 ++++++++++++++++++----- drivers/pci/controller/dwc/pcie-designware.h | 19 ++++- 5 files changed, 146 insertions(+), 72 deletions(-) --- base-commit: 5fcc194143ce5918ea0790a16323a844c5ab9499 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li