From patchwork Thu Sep 26 16:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13813519 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010005.outbound.protection.outlook.com [52.101.69.5]) (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 43AD315D5B8 for ; Thu, 26 Sep 2024 16:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369280; cv=fail; b=qQVVd/nS2TyExCY1zPrewDnWXt1m6xyGIMLr4TqdAAt9g2taEl1ZWUj2kidqyPpA/R7oV+c4T29MRGn5b7mM9yP1mEIMmf5/FTEAnzimk4gIu4mOCM+CcvgFa6K0YZ7VAaT010A28UGRWN3eHQLQ4ZwQzISckBXUXbefSKs4pzE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369280; c=relaxed/simple; bh=9UjixEiIWjU2Rw1R//IY4okKQq5e+4Lm/9kG3kM4QOQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=mxXGkuxQK9JxgcaCeHTys5tOdszL++MKo26jBKUVbnTGLMQl/rBy1NUvwLwR5Qo36t0EPqs0uVqmv4zK31WJkxyYLxnLCANQADsXp566TVZrxP9zaHpqx53cnuquMWqo7yef7PO1BTDA5+FFjIBM7KF3OE7YRktszdTREW5sR58= 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=dINAPUZV; arc=fail smtp.client-ip=52.101.69.5 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="dINAPUZV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YX3YkgoLnrL4/vDW0eMDcIQ0PUvwwa6WdoTswSv7HXzGfWeWx00Wcm+yX6CZ2/hcQkZuTWPzBA1hzJYjwwk21/PI5tCPtikXadlNSMUCuoSCB9IXgTD3tfsGa8Rs0OWQdGAYGPN0LgObawCiR2o5gIn7GSBndSGYMozFgOMOzzB4cysIH6L8vymuWaSTJxmGXPZbk5UNJscp26Niud90pIgYrvx//acv2v7HANPxDWbYvf3m/5fpa6ur125Wuma6wDCv/cJrNfW0r5e59GFmYVsJg1UYyWh1UF8M+F6oDu/hLEo1Is0Pn/VThfxHVZ0Jk7VQMA5ZLrYjA5L09uYu3g== 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=aUBWLRM4foMjxqfM+aG3qnhroBHRstX4Wda+VTgndrI=; b=H7kNMMAn6of/VkC4Gt1miqhZo/0CHRGiMay3xwT6eHBtIaWFFQsBo7hNViHMi8JeRsBCgL0Vxxh39Vttiyi6Wyaq1Y3dXb5HQfS+kZWxX4wO8Jf0Sa4heCIbCppYslpuHUYs6hWQ0b1xLFR0iGI1bze//RxKO9RICPLQETWGSGqHrPtbtYhJGpnfxRKX8I7JTM5vCI+de5PIAZWDPPuLLMuupvLHT0xyw0MWcwSdLlR8nD09zyfmGpvAO9lBVfUFcwzGaBHSDizxoNlJxB/KQMSotGjP4nSZYHjaAEWDW74JshRZ4jo5NzhLjm5pyql+Nl6FDyWlodpzFJDMd0yN2g== 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=aUBWLRM4foMjxqfM+aG3qnhroBHRstX4Wda+VTgndrI=; b=dINAPUZVZAg8jJLagqhjnJ9iSUKoASqrgN9KbVlRBHU4iJu/Yo5XgVw3PcixttcVCcNoikBeABGsSZEx3RfGR2BWQutadizOeFCImUZntSQmHrI2uY+OC6klvK4IMozPhFHZto+kQ2llq9T8httyaTqG5lI63s1Qs222HESRanGfG/e4vjlgKrqaDdOdhV/Cwe/JsAN3kLFHivV+aidFM42Q52rLZv3AKKhvcDu71CgzXgKyd61FmA8ysMd9MubV3Y9tkKiclwbIzrAjWUD/RiQCEHF4xx7L1jQ8cPp0FZ6dJZGTTFHntyTtubVi3cc2QBV4UjDpg9AH1Y5rXveDkg== 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 AS8PR04MB7768.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Thu, 26 Sep 2024 16:47:47 +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.7982.022; Thu, 26 Sep 2024 16:47:47 +0000 From: Frank Li Date: Thu, 26 Sep 2024 12:47:14 -0400 Subject: [PATCH v2 2/3] PCI: dwc: Using cpu_untranslate_addr in of_range to eliminate cpu_addr_fixup() Message-Id: <20240926-pci_fixup_addr-v2-2-e4524541edf4@nxp.com> References: <20240926-pci_fixup_addr-v2-0-e4524541edf4@nxp.com> In-Reply-To: <20240926-pci_fixup_addr-v2-0-e4524541edf4@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=1727369253; l=6330; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=9UjixEiIWjU2Rw1R//IY4okKQq5e+4Lm/9kG3kM4QOQ=; b=q9h9KFax1bOFqYOQT9j41i+XoLB60/QqkG3o6i3uWdyqfh4+ocMXLrofzpIpfprWxamA4TAwY r+alQ/+SJAwDNmS4W3Njt7ovEv5qmQudOSNVvuxrDiFy0mDhTRtR05s X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0091.namprd05.prod.outlook.com (2603:10b6:a03:334::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) 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: PAXPR04MB9642:EE_|AS8PR04MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b0b3112-1ef3-4863-f5c0-08dcde4af372 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?2RRLzLXgAd/gMvAO0PbyN3rod46ncc/?= =?utf-8?q?uFmY21Vw7Vf7J36x4t8byAFQnuBNB1rlxraIBc/LCjvaWrc6J66RxDqFwL+XWdqX6?= =?utf-8?q?A19UgdxL6PIY9bcsOgUhPY41+n2sOUorXKwrx3tQNO683r7kUzMpL5YQ9mpwdzDTT?= =?utf-8?q?kucVn1GgU3H/AGHRO7XdVGk0WFMwlc40rve/Io0UdKpsa9zV6gb9CRwgXqORfuJSU?= =?utf-8?q?pB4z5jfgPKIuXTLXzoy5hKLTgQ8OBnSWiqq33UZcwAbxb7o7tfnLLb3ryT0vHlSEo?= =?utf-8?q?V2HPTVELTUkaSO4I1u40rP5toPpR0E3ikWOpvcPxlocNqSfEQFHCAe3hd1Nh9+e4t?= =?utf-8?q?Fkw42r24b3PSSN3caJK87DfwJLHEuchxijTgImQdjuI6XtWsbtC2yLijEOG6e/T5A?= =?utf-8?q?Pz/+r3e130yv7yvDEn/Cr/RXPBp5uozB3NHjlT2GRTir2st3+0X7U9V9qel8Yv6N7?= =?utf-8?q?L2lAMbxXymoKsyYAgi8P5m9kz0pzF45QRewnfOdKKp2x0BOCD0RQargjYJIZRDPM9?= =?utf-8?q?zEL00B8hdNRv0fq88Xm1uaQ2RlfkAv2oT5C+4Bqa15DQl5GTIbiKJYsP1cjy/cIcH?= =?utf-8?q?40/3yuUz2iso1sCRnuy+k5nCWeKD9ByH6jPGKNGugpY1uFo5rv2rne0fC9ie4y5rt?= =?utf-8?q?Hpi54umhGnHIJA0fyuzNwqavGrVzVZzoiIUYMxoQjK5nhax1aYAx8jxENanuM+vzX?= =?utf-8?q?Av25pcrN7MecDZDtSe7sVUwjpfX/7N0YWq6orUBVuf3poCt+UPfB4waxvjKRP6B6W?= =?utf-8?q?XZ5Y2ACxmYWZMyQA0wT92jtWWIfB3kVRfO7tD0Y7Rv+F4hWtSBb3KH6HQQhKzYcF9?= =?utf-8?q?WuoelRujR98gwse7yC4I0KpK1Ei4h04UZWzjLNk6kd2tnWS9JqerPmTAj5/RONDbR?= =?utf-8?q?QprUpzbbDVOKxWGoF3kqm4Mceb+4MDEcuDnfCcYsKlgS4/gKewiqYQfKtHu/x1oFz?= =?utf-8?q?P7wNgOMiuDdJodjf1sr3XmB/zP0lqkLVte+IT/N2+jkY1+mjB/svKYlaosqbUJSVA?= =?utf-8?q?l+Id3SCLKDvxx4DX7i/RZG+XUwTUoAzbAw82W9uhT7NEc6NkepdDsrnq+eTgEKMH4?= =?utf-8?q?uYF5rR+jY8BrPbZgkeGTl4JuB989gBBQhqAjAw5qurgzwV/ECBAOxLbK2Jo+mdXyG?= =?utf-8?q?17+nFr451bdy/9ANX4jqiNJqkJg0D3habaX4w2yt785mkNh4jOtXLEzL+OI5QigXq?= =?utf-8?q?OwMGjP8Xrdvaox08R0LeveQ29NI4lOITzaL8M50mcWwvJx0NUuPlU3gTgbSWR8dr6?= =?utf-8?q?5nM7yECu3ovDSrxoWBpiN8pvezpvhp7UT0e0nEtkOgzg/wG71u1cdvPrtKg2cSvO8?= =?utf-8?q?aVBDk8sa+JqYy41bBKD8Uot3PQnYDv0qdw+qLpDCw0W+VEzxhHl7/HM=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)(366016)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?S0onaC1en3prQ7LkFQL1cMa2gEz2?= =?utf-8?q?w+zToXNBAJ30OCCZl3t65qahI4qwbmCK02BpSPMwVfUCAidYTv5Bque7YVvBUjKgQ?= =?utf-8?q?+BrkqCa/hyWWoal2toj5JuGqrQo9H1mmhWVbiGBL9xhY3bnH/DMj44Xqr9iQwaEG0?= =?utf-8?q?qxdU4cGFOQHYp3h6ZxlDt0cY3Aewv6Hz8D5p/8FG+hcFGxu3DSQTWSYKJWtNk/yIb?= =?utf-8?q?Q2gw5oY0lBsZBgBlonmDWYecJiMCi4pIU+kMkOd70l4sYE8Wjqz24oNd6WDJ9mOtY?= =?utf-8?q?Tyo5uqAk9qO4P0c5aLhFdCSyPg2lpplFg9qtJHhokWR3TKkd7uMPXW05bq8QKM36V?= =?utf-8?q?URvTskjbIPD60xIib8RoMx4ei/0O2UJK87Evm8VYYkbl3x4ebeVCh6hix6CKS+h5y?= =?utf-8?q?2gDUdsuHF9xEeuHath11ZPF3xOFUkYF7z6lY4mUD39nCppPZ7I/aZOqHvzvHSsrlU?= =?utf-8?q?ZEUYv+8JSvnTP7BSvUBpxi9iGWP5rUyfCgoQcH+rgvn8pIEDxNBq7RfOZ5owkstLW?= =?utf-8?q?BVT1PVk50otbikg3bEUdj44UpoPF9lx5TngExB0SS/VPNe1mj6DkkwRP9B52i2BDF?= =?utf-8?q?Rx+osvLZVq8cmEvbJdtTcDeJBvr//KJDysunrlvrbE8w6kqc6GOTX5rwNmNQS+EKk?= =?utf-8?q?bvYNRPxtH18ETQJxq728yyHliICMiYkp2XZ4DYmAqeKTRZ24Td3BI2tPXvs5Xw+z8?= =?utf-8?q?e17Vq8rMp4ho78g2l6ORJ6TLSUDyqEFEP53UOFLXvmnh2i6XYpFVgU3gD/44aFFzb?= =?utf-8?q?G56oxjiM1SdKmxdQwcEY+OfwJ94XwkSaH9WA/wrklHwK6y4PnIPsgn/W277Zd1sIW?= =?utf-8?q?HD+iSspTQKTz5his7buOHT5HfKxxY1NDo35hkbHBJyuG/JuDi0Jq9JZ/mEYh0IAHv?= =?utf-8?q?KWmc8WGqbj93tkiQP7c/t8iqw4Q7A8mnxk1ZCY552qJat1mExJqUgQZnSikC7wAaE?= =?utf-8?q?LSbBEoy1moNiWSXGC7OvKezIqd3BoYb+bGZNu0YbvMW9urmGC+nKWyDmzdqA9BWOa?= =?utf-8?q?/SD4ym80GpIVvoF4wcQ2YTD/6pgN9H4R49mQ32xaAHDAsP++RfNjzY7X5WiYhUas6?= =?utf-8?q?tynWVy2kbUw4OGoQQM+piKRy44U0q5KFRzzgvrRExT1oZHM+PCsuVK54UPg1qG/3I?= =?utf-8?q?J6qnXH4AWlAUN+0J3D0GducsqFXb5tbz+b9ZJ6rqun+xu5CJR/Dvm6szH7uV12ksq?= =?utf-8?q?lbKazzBbC/FIodIiObNq9Dbdp43dPfQFWsElauJYqHM3IVP4EcTmJys5b3L6zvLJR?= =?utf-8?q?ky6NvSwALGGADL4wi+ZW3vSCAHAJ2ByU+80YW5yNN0aDYHliFxOxIvUJJtTrm41y5?= =?utf-8?q?Elu+U8q7M3oIH4xRGrcrvnD49Fe33RpBXK6VrE/HyQGV8t3hgzyhM6FBRT0IG0N7j?= =?utf-8?q?efjiBT+q/S+kDnwev6zjtQJyZfh35+s8zz6SKYaTPKnN3GLeeNJ6QBYcyvV96p8y6?= =?utf-8?q?0RQL6yq9nt+rxKM9muvyRMbmZjjvfW9n0OFe8BUONNX+wPMDtEvO0Jj8GxcU8nUtr?= =?utf-8?q?F6ZQwU4lqmLg?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b0b3112-1ef3-4863-f5c0-08dcde4af372 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2024 16:47:47.4004 (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: FIQW7J5AEGVscQ4iCnuFX78Jk1gedLLPgkobYdQUl7asNhTZbzqZHr4GnObPZ+xHjh/zwIvqRMRsR98ZTY1xJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7768 cpu_untranslate_addr in struct of_range can indicate address information just ahead of PCIe controller. Most system it is the same as CPU address, but some hardware like i.MX8QXP convert it to difference address by bus fabric. See below diagram: ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ IA: 0x8ff0_0000 │ │ │ CPU ├───►│ BUS ├─────────────────┐ │ PCI │ └─────┘ │ │ IA: 0x8ff8_0000 │ │ │ CPU Addr │ Fabric ├─────────────┐ │ │ Controller │ 0x7000_0000 │ │ │ │ │ │ │ │ │ │ │ │ PCI Addr │ │ │ └──► CfgSpace ─┼────────────► │ ├─────────┐ │ │ │ 0 │ │ │ │ │ │ └─────────┘ │ └──────► IOSpace ─┼────────────► │ │ │ 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 '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 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..95b927efb5e46 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.cpu_untranslate_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)