From patchwork Mon Mar 10 20:16:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 14010641 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 4828AC28B30 for ; Mon, 10 Mar 2025 20:23:38 +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=n4ZxVERpLvmkqGZ7PjYCz4nQIvKyVijJa/+tDJTgiIs=; b=SzqT7FnkBYI5qvwOPyqw8fUeUY uWIrlmM/Krd6zLr5SVuPr6Qd8CyaJrE7FaquqIQfxdkX3BV0zSz8v4If6qWYiaIcsIHLo+YE1lzEP aQUI+ZPihEk703V+pfs6+om0IGLdfGxKnrkPu6h/jdAE2OQCXfgyOZ1aSZ4xlMZaRqCMofxb2eiLJ S+J2hcBerSBpEFFz0UhaHczpc9X9GjFBIR2lzzFO6Rt/9fpBVnRNXTzT0FP/2ts8IvTnX5XkqsYFq k0RbjxOJ1CMK4L5DE9vxewwShoNgU+sYAyxKfmVW9zZ/4859hL2EQ2fNiAvIs+gNroILPnYJzNYDF Us0njbKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1trjeo-00000003rsY-0mmR; Mon, 10 Mar 2025 20:23:26 +0000 Received: from mail-vi1eur05on20624.outbound.protection.outlook.com ([2a01:111:f403:2613::624] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1trjYz-00000003qRu-0PSI for linux-arm-kernel@lists.infradead.org; Mon, 10 Mar 2025 20:17:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xTTCydPAyancnASEZAdX96zAVk3RW+iPkUyZkwFUnD2OLeSVDczsfvNBVNPjeW0PL4rXkgZb5JysnVVN8uSjPjms12PNdcQZ1MjFSw+fHR/DQzszUHHnRq+MHrgaUWFzECya+oEYHPdGxmTdgYu+xodHSV2q0Jr3aoSGY+IEfqJ3zQPJuMg4KOIQ682vdyvcWbiy99NvWhgTY47Xq0/NSQY/EGVpoDlc6TuE1SqBq6LvpBRGXwMCWw5/PbPV+ZTzLAOslj19BP1FtEj/fYundUXHTULW1gHwZ8E0EYqanv36sXF9mySiG4VFgeVRvqoj09ScXW8ytBbvZXthVkW37Q== 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=n4ZxVERpLvmkqGZ7PjYCz4nQIvKyVijJa/+tDJTgiIs=; b=vthuJ99dwJjFYR2Oj85TbxjFpr7yg460gD19ipPOBXpNTdyfFLlYh2nNasFzh8IDQvYnG0c2oeyPYEi8Hs0jg8apbkVnRGv65mj2oMUS9W/gDuXUVfpIFrl19nWkywOHy3B4S1EZjOij/86oSbvAVp8yYlAaOSKdTtJt0mrhAEnSiuNegiCB3LKCoFB4WPg8RXm7XkWlrp3qrt0aFahq+AI7A+hYo6KrkoiCFEvcsLgM+xT2bFgLzFY8KUqjHm5tEYMQcC0qkytWVHhDyBlK94WExWadsTZbnxK9SCka1acaMzd9HajXI+XIBgJuEoadO62xuQF/fqK/nU5hC/muKw== 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=n4ZxVERpLvmkqGZ7PjYCz4nQIvKyVijJa/+tDJTgiIs=; b=VwGZ6AdnPO6EJcVtCsesVb61xO6u2BGAfnf4Nvx/TQimAxdi13WdKv1orRjp8sNZq6W1T8dyFU8aJRuBQmwtaL5UvDc6gzH7uLA2f5CKEVkyFtX5GGI/g1XdJ32ir2VjcH/XZMifdXLGYZp3bc255yPdHUd5pC5GRrX8wSTUPAPDr29dR50FSSFbJ3u5W+UQOZc+QbjdwQUv4P3P0yaQ1ve5oVWH3Dk/WL6xNAJNiqrg/UsZJLEWoTLHUd3GbtgrNhu0bog1k3KNZwr3kxeVvjrDyWwvG9TiVU+eNviH5OJUfN10XW5bixIKqSdiPrMPRiFlBmkXQO3SO85o2c5KXw== 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 GVXPR04MB10682.eurprd04.prod.outlook.com (2603:10a6:150:214::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.26; Mon, 10 Mar 2025 20:17: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%3]) with mapi id 15.20.8511.025; Mon, 10 Mar 2025 20:17:19 +0000 From: Frank Li Subject: [PATCH v10 00/10] PCI: Use device bus range info to cleanup RC Host/EP pci_fixup_addr() Date: Mon, 10 Mar 2025 16:16:38 -0400 Message-Id: <20250310-pci_fixup_addr-v10-0-409dafc950d1@nxp.com> X-B4-Tracking: v=1; b=H4sIAKZIz2cC/3XQ207DMAwG4FeZck2Rk9g5cMV7IDQ1J5YL2qqFa mjqu5NOgrULXNrR99vOhU1xzHFiT4cLG+Ocp9x3peDwcGD+1HZvscmhNJgAgWAFNoPPx5TPn8O xDWFsWkPKJOuck8gKGsZYXq+JL6+lPuXpox+/rgNmvnb/jZp5Aw3pwLG1PHpMz915ePT9O1uDZ rHFqsKi4IgkkJDHkHCP5QZLqLAs2ECMGiSJ5PUe4y/mAKbCWLCgSAJAkXZ+j2mDOVWYCvYxECl vSGjYY7XBop6s1ptddD6YFDDdfZjeYlthvd4sOQQvMDl9t7a5Yc5rbNa10aWWuJXCmD22P5iA/ 7G2LVgW7QhUUopueFmWbyZt4LOTAgAA 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=1741637834; l=10919; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=rpjV8ib+BKGHKp/ind90+7pvN3dGLE63Xta+NCdFcT0=; b=op5b7GvUiifPIGi1CUkzaoEyibor57K9ogmlwrQvxpWavU1coiWPdKs3NfX5DO36nWR15FCVH 5BJstYMCj12CRG0bHkOTcgn+EduAkxvivfY34Ea9ZOjLlwWRp1QWxYs X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0058.namprd08.prod.outlook.com (2603:10b6:a03:117::35) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|GVXPR04MB10682:EE_ X-MS-Office365-Filtering-Correlation-Id: 77604d17-9935-4f11-7b71-08dd60108f21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?RHKAdxYEphYCTl7s6X0hhm69t9yZbpZ?= =?utf-8?q?Jz/OcG7GWcuARegWmLUXbUriLUuGBtdW+IN9+8KqexxMdVtY4L8RdxWn2uckSqM5i?= =?utf-8?q?WyXCB9SR/gqqs17ZQal3Ol4rAEF9KmvzWi49dR/vpJnC5LMgMFlk0yMYDG21QPZju?= =?utf-8?q?OL3H7CQgWH0gH4/uqSUelt1W0/je9X9c72t5drBt9PlZYxpDsBTSigJnPM7B1CbcJ?= =?utf-8?q?aDHrC+b9s/m767zJinJGXnvL3nNs92ijOx9WYVLfrBx4SA5tKip4G4Jy/VYs/WF8w?= =?utf-8?q?kuetVp8HRT8vHirqaQRZ6CUeSg6bdGznsXlBBSIWDVo8XJ99RrflHLyE5bGq5EZB9?= =?utf-8?q?QxPhnPGyoEvnKShI5BrX7GHHqcy50g0KMa/tMlb52U/r/vqUdSVh33KVboAAXtlEf?= =?utf-8?q?LC559Q1eSiFIEE3xoOwdmB03HFT/LkDL1HupvqT7E+LUxP38rz46AtnhKuvtK+gRI?= =?utf-8?q?iB1ex2Nr0iHIT49O5pzGHlc06EbO/ddp3COBIApKvCDtqU7XxpeX/ODX/2F2floh2?= =?utf-8?q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-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)(7416014)(376014)(52116014)(366016)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?274qE6BDFv2WJEyd6XPZKjlK+RAJ?= =?utf-8?q?3Nl+J666Ry6IZVb+Q21Yh1x9qlSsB3s7dbA5fO3zWWNCqegHCjzcVYItoHxffz9AQ?= =?utf-8?q?Xh77G1NRg+vizESk1kwB1VgnVuTRCWtzyanWe7c59Qcx8jtMj9f3pAZ7rWyDJZ8P9?= =?utf-8?q?s/FesAg0VujZtKjON/2HW/p2olX9oaROMX4o2ZzfQQWfnE8+nHmQcxrUUiBvwKSaH?= =?utf-8?q?RzzjW4jeXtZ7/2NxhckzBKDuyDLBXIb+kelMALi8vbyIcZmQLGC7Pf0Mwx8Rsg5Dd?= =?utf-8?q?d5mLbeQdCm1yGqgDiDF9kqV/HaZSLdqW/2J+g3981/9he30YYiNf5Xt1Sw3VxuFCo?= =?utf-8?q?sCND5qKJavr4BHM7xtk2fEg4z2oCJ5kgcXg0iRf7MjS+bJUpzfrtGCb6NzpoCwaWY?= =?utf-8?q?DZUHYx4mHQE8H80a/9gvOPvOpzvyuddaYWYPOMnuP/nNYLKTReh53JM97UtEVQ5IF?= =?utf-8?q?/vNWS8A0SpXMjSf4XFMaxAnlXKtP65VMZ2dZhfMrN23w+Wk+kUTTd61fqoUP/9K2T?= =?utf-8?q?58UDUmfs+1OA6loSxB9dkqZdAYSIIQLp1/F7Ad7PxO3hfL9cDXqPAMdvuEOgYwzAm?= =?utf-8?q?pQhBrrsetkgRBt2qJk4a2oyE0xndhjunoh7motChKYJz0knfz43Yes6SL0Pj14ahh?= =?utf-8?q?z7PyVo2ab3G6toOIeArgFFjf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id: 77604d17-9935-4f11-7b71-08dd60108f21 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2025 20:17:19.4960 (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: Yr1I3Q+s56GY0CE/TkSsf5JFRFcCPwK+NzdnbyBdw9wwcgBeOB+JgPjsUHmgMCQy2RjpDCNUJ2J7E1c9mIYsjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10682 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250310_131725_317622_17D05764 X-CRM114-Status: UNSURE ( 6.54 ) 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 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 (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: 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: Print warning message when cpu_addr_fixup() exists PCI: dwc: ep: Ensure proper iteration over outbound map windows 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 | 63 +++++++++++------ drivers/pci/controller/dwc/pcie-designware.c | 84 ++++++++++++++++++----- drivers/pci/controller/dwc/pcie-designware.h | 20 +++++- 5 files changed, 140 insertions(+), 66 deletions(-) --- base-commit: 5fcc194143ce5918ea0790a16323a844c5ab9499 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li