From patchwork Tue Oct 8 19:53:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13826890 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011017.outbound.protection.outlook.com [52.101.70.17]) (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 9EFE6215F54 for ; Tue, 8 Oct 2024 19:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728417279; cv=fail; b=dlvcfL5Y3bwjvClB8vzOf7/f6SyUUnC+EYzZMBfl+eFNILvEGyvPduL1d0fij35R7eVNN6OVHupS+l0dvT2SzyJ+AOxqJGGxRpjr5TN74wD7lGyc7zRoX+4HqIo1ya9JgIRcSKBIhvuMYmOf+LNSP7abmevqjcunR6Ocph9CNog= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728417279; c=relaxed/simple; bh=0L3qEl/+gpp3mZUPcyNe82/HxmZU/2VbLozR9pKpTKU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=fjWuwhcToCTsI1rnX0TW7DUlIamOFu5GFHGNsam/bqdLp/UrwDlsErk8IxpvQ9Yg8RyCF1d8iqUkZBIPCJN2YPeng1sc1RlOYAxJcPjMclRSKCJvETu+EOlZ4HFTSQBsfjg/3vx8GES4LbYZCn6CwQF4PZCAY9Cs7ky0qcLUebg= 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=DmahCHvh; arc=fail smtp.client-ip=52.101.70.17 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="DmahCHvh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oF1fy1nC/nB8sVE/JSLHi3VG8sqR1fRPNRsbIDKKNPKnu8s98sgaunToCdLbMPmDu+cv335hHfOXse3Y/T7RutwAOFIUc8hn9nSy80sj8TqxOMEQypmaP2TiUbuCDRDJwgnxLmKyDf/ZCBY2FEBu03ITsWexVtM4kCxOtxoFwJmHKpF2hFutYBqCQ0Q1rNprjCz3XQvRZd5P2T2/FdOKkzTjHPaIO7eQURaarhHQPsxRJ95hIQ2Ys0d5r8HaG7ieLN75ciZWKGq2VlnQlTMSnQBmTH9j9GN/wARraygSHOARnNCucC/T0SRQa50fdPUCEsto0vaX1jKbpipSLL+c8g== 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=/xjmrzgXUr8SnuZoLtkR/dSps1HgUaXdt6njq7Rjbfk=; b=Ffw0a3Rk8zzbct/F8/KbAAcdTeJb7L9OhUmHuwxPxie3l4dJSxNqteA9voHNIQj9wOzJymBlZmR8QqVo8Q+k24Ik8UHaiONXQvTTTBfk1eiO6Iex6TKFjkezfor4IuKSXqJAYVGF/Jhh7Yp4n0sfL2wvVzezK8Glsw+3wsXnCXTH2+lx8/PUwfYMzRcE/5lRELGTTM0HiP9dRyc8CH/0AV3L1KxuWAgoFfLGXTWN6R9pQDaj6sStdxVgoPPQ9wWBKcDEu0ty4Soum1nCg+kSwkZPDEYzLokFYzEpeeyN+sOG/7Z07djPOAINMoewXjXdJs+m/+ReRzy0m7buic0xSA== 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=/xjmrzgXUr8SnuZoLtkR/dSps1HgUaXdt6njq7Rjbfk=; b=DmahCHvhgtb+V5Vz5hArhx0iOoSSdzT8z9cNxin07q0cX38bDCPIun3DkpkT19qMEsUYjlLpO7tPWWlAy4btQeKfT0M3EISAyZcIKmPxAWwJQoOhL1JuGtDa+g78IGk42pjL6Mr/SjP/Khp0A38cJhlW5NoxCYY3xDA3QY1LqMWhZKawMhuA2RITTQfon448mV0zQz67+5B6NtskTlzTfKdtGJ0BGgJcfhNnq+cWMbCzpCtTF+ojWHCoHVBclYPS87GW53kcAL6Uy5VID5mkvsIyLqOoFLhmtsi2/8D5zcm38GdNIkdwWkSyGtkyvWfn6pGgW+rZd1B8sdBOvWnamg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) by PA1PR04MB10577.eurprd04.prod.outlook.com (2603:10a6:102:493::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Tue, 8 Oct 2024 19:54:34 +0000 Received: from DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d]) by DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d%3]) with mapi id 15.20.8026.019; Tue, 8 Oct 2024 19:54:34 +0000 From: Frank Li Date: Tue, 08 Oct 2024 15:53:59 -0400 Subject: [PATCH v4 2/3] PCI: dwc: Using parent_bus_addr in of_range to eliminate cpu_addr_fixup() Message-Id: <20241008-pci_fixup_addr-v4-2-25e5200657bc@nxp.com> References: <20241008-pci_fixup_addr-v4-0-25e5200657bc@nxp.com> In-Reply-To: <20241008-pci_fixup_addr-v4-0-25e5200657bc@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=1728417259; l=6492; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=0L3qEl/+gpp3mZUPcyNe82/HxmZU/2VbLozR9pKpTKU=; b=+c0mkhqtxDyYANK7fl7oYdK3Me3oM0gAyo894gvHfYjTl8GLgpijvOtaIRqiycPXA/sOpVG75 9GurMMaIJn9BMlBknOqG382vuZLJmj5KStQv/+V37il1wpVVXv80ZA2 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0195.namprd05.prod.outlook.com (2603:10b6:a03:330::20) To AS4PR04MB9621.eurprd04.prod.outlook.com (2603:10a6:20b:4ff::22) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|PA1PR04MB10577:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c889615-f9d1-49d9-75f6-08dce7d307f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?O9QSZyplGq4Y+D1YUVk9oEPb+PM7mF/?= =?utf-8?q?NupjM4mi9wq7SXPU8zHGJ2zNxiFAWh9HP62R+Jmg8GCJWnVToTlgn0Vyj51Uc5507?= =?utf-8?q?QJJV5EgI+4HBqlEz4mA9PHACn8k46rwn1HrXFMwSqz2rsn277kn4cPtP6KrFrkN6G?= =?utf-8?q?aeI3C/s25s6Qt5kGTMUUMcyAbAfqlGEUufBW7WhDhHlLr+42a9FHCK+VwupO1tgzj?= =?utf-8?q?tkfNrVgVkp+pTr1rSzIcWYy67n7snyBpQBRqS54nLAscSY1bIgQQ0ORkBU3GDLrXz?= =?utf-8?q?7ERuQB9JPFDp8MfdlidDc0hXACuZCokNwa/C/qIK4ely7/cTgGGEuako1QNVT/Pdb?= =?utf-8?q?mJpGRrdkI8UHEQdTMSoYJRpDTYg6XnyRlL4ARQIr4CpEASvbLIoitS+hZjxexfgCe?= =?utf-8?q?9W8yHNsVFYeM8qBvA5Uas3P57XtRf8iKQ6ECgSjEnOKRGdYNe1j8fzUAGIZ0oZ6Pz?= =?utf-8?q?SmDdbfXrmOZ5yvMK2tGoCB0Pwgkk2liDAhiL465IR11Gs+lHG1sqj0OU99kWqDO4p?= =?utf-8?q?8ibiK6lLNJJa/zkEQuEzYdtYD07Tz7lmSnrrrW+6JTSsuuDUytYmfDoP5pET1jPh3?= =?utf-8?q?jx/RSp6eCKuHq53yQZWACzsdfReojUnhZ9dojNJ2WG8mHP8ntlpYbofdTqEjfV0cx?= =?utf-8?q?zQzZUIlme1CgVSwlSZL3X7/naqhJTVI4gw+q+anHRFBIQC+pIP7Mrv3B88fvQGqr5?= =?utf-8?q?2KD/EhJLz4lXQL6oUt7gFdeiMbQM5d7hokbk5vVPgBcB1LxAQQVKmikKOLjrtbE1y?= =?utf-8?q?AuCzXfCxrmvS9x68OJ2xKrZfTcip72fujm/OP009m2+EW6hvdknY3xLc9rkhRfGjx?= =?utf-8?q?oocwLmnbiN1ghPSkIsDJcg+4CgFrvNvn82F97c3LOLZ0JP5GXqI2ceNZNCpiJrU9Q?= =?utf-8?q?KZqsrLK6zJBiYYth1BoF6wqyn5lqyo4AnqbcFdaVWwMBFSz955IiAANmyl4w3pnr9?= =?utf-8?q?54de443si19wtUQMKf+8BCjlf0HSKFssHxNyAWcljqUBntQCNsYtWx8hRnxdclpKN?= =?utf-8?q?TFRFmr69fyKOG+NrBNjQgDTJ8v8lTb2qit7Esrf8wSpPz6lZyEfEWw3LJyVoQ3N1I?= =?utf-8?q?u5LNftewUNdCDepMpKSRkWffkBHum5PEp3+FoCEalF74GNd9MP7RQfcZ8gO+oHy/M?= =?utf-8?q?mnV6OwJ6Q6P7K4KtgXTQEfTfbpv66G1XJ0CM+jYZFuSeRAKt9I2Qk3+0dKMe0vYEQ?= =?utf-8?q?ueAsph9CqvWfqNcZ8mNGlyv0yL4veHDjBTU1Gbapu6cV/GC4aEkq5Qte+/uGiekWa?= =?utf-8?q?we5DVj9oy9niI+MECfWTriFrPD9xETHl5Isz2g7t7vMuHqecfBLM+4Ag=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9626.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(7416014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/FKMr26aqOGOVH0LojKsqhoGM2dY?= =?utf-8?q?bwxlRLSYwRSoKK3D+Z3B/j2S9t3jR/TPrurJxUNDPiOG7R4wDAdxA89pNYMQ8+YYq?= =?utf-8?q?9tnzXNzGJUXGrasG/AJSc5L+x1H7CW1uRowwJEYqJbLP/XbZ7jQtbVRrfdDnmlnzb?= =?utf-8?q?fiUVwMKJ6cSK9jVfVRPeqwayAXSd771ea/j+5Fhxrz8kAd+gmNrrQteYynwTXYiem?= =?utf-8?q?vw1z9wH/JQnK+PR/1x7emryGGotzHXvDdvnLuR+Ipcu3PFMk0lebIiaLF5MB/JYVf?= =?utf-8?q?vXLS9usWSZfk5kFsgf47crl3rgOQbR5LfGyhypizk5lG/DQetkUhzaebSxQemaroy?= =?utf-8?q?Osg58t4mTlEJ74TOP4y559t0IzLyCge3pVhNrwor+ocQmFeG1PkDnfwSmVj06VJ3s?= =?utf-8?q?aPT87sqhB90PE/k1WsYatiYtAqpUylxdHOB/SBdDERDAUI/VADed+7xm9eMOuHIEC?= =?utf-8?q?1FLhi+Es/hwq0+TV0weSDpJupoNRl/vfI6990v5E9dQeYbwaYaXigrq2dMzichzPi?= =?utf-8?q?ssbr5e2beIKNv7ewuHR4MDx/QQOqJLe6N4QxpQdQGQ9qu4YLaK0vdW/8meUvR6DwM?= =?utf-8?q?zLxq7at6rMm+KT/SwuM79amANwtpACQvTsLz2/hZTTBVANoEQDOkdT4u7+ZN0jWs9?= =?utf-8?q?0eF+lDMarQbudOMzq5flTzm8v4IwyVv766BWq7ar9wO0eDC3sNNWtnpbfGvzFyu9b?= =?utf-8?q?g8mro52qw3Cd7namMOt4cwShhd4jjbMqtNFxncGmzk1kbXqMmxXuLoXwMJf4yOYqz?= =?utf-8?q?KYrbmzTqUtwiuVxdiCSa+hrvj0fyVyw+iY2IM8X9f+7DmRn/lYdxBHYJ7f0TMn3Rk?= =?utf-8?q?audJDT08blgROs1eR3ZVSqZNXtjpxLN8FkSvc4z5rZUYOlWEnpwlmASpdpfJvVow7?= =?utf-8?q?eWXcxnDWBZ3ERR39CaV0WUTlx4sK41ulhB4DcHb5aCJi6KXGJtMynAmy0ggsCPq5p?= =?utf-8?q?D+WJBZaNBojqnkPLSBS3g0ipo5Dput08oEO+JmGbZQo4Xh8Hj0OZ3P6v9oNxlHWZw?= =?utf-8?q?5rhwrsZ9HbiWh7YjJj0/+jv4kN+UEo9TuSazi4R/yvZQNl8pLdqnOzXLX5/n8jknN?= =?utf-8?q?nBAVZnvl34xv7oOaulOZYF7/wn+ioBplO6zPCY0rt6hBcF1XkVT/j52LvICYOdYou?= =?utf-8?q?VIP4MQ9EHaPouQMB5eqS476cmQSqQN0Nn2Pd5eMe1nYvLKjmZjUlA/jFYFjZEGWP6?= =?utf-8?q?b10l99l7EFGR/ZAd6UbdwRw7O544WsPOg4fojxlNfIX/5M0OzhoxGCQCKMCKor/hZ?= =?utf-8?q?7YzDu1NEkAyhxWtF943VnU9Etux0dFc73Em43LRyGP0ITG/bJHtHlIAivGf3sj0Eg?= =?utf-8?q?9MXmnUaxSCfjPLbTU+M9NJ858kXyRRhAxRU9yitLDlSj9RSlOnR4Cbjj7uFWmLy/Q?= =?utf-8?q?nLKbhk9u+xxBEcPJqyBvNpdS0cMihu86qUMiivAF0z5hnYgQmBS8FJgoDsy/QnNB+?= =?utf-8?q?F1hl6wE+WdA9MuKwlwhO+JVW6gF0lzUT+r3XoN+d++HLqcYqGgBxEE5M7OX0u3Q4N?= =?utf-8?q?EbQ0n40b3XTk?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c889615-f9d1-49d9-75f6-08dce7d307f5 X-MS-Exchange-CrossTenant-AuthSource: AS4PR04MB9621.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 19:54:34.0340 (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: ZnHuMhiainRCtcHtCZtm8JgbC0hH2mKqjnASiKuwO0aDMoxR/ixYwllynxCi5IXocCAf+X1OsYaoG7MJ1/CKuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10577 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 v3 to v4 - none 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)