From patchwork Mon Sep 30 18:44:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13816860 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011028.outbound.protection.outlook.com [52.101.65.28]) (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 1AD8E199E8D; Mon, 30 Sep 2024 18:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721930; cv=fail; b=J3wW8tqoIYZ/g/uqFikeat2KonWBCHdsDoSVrPht3R+oRRQv4+2279DWRvdXuK5tGmawsSvIQgK24jL4ltO8/SDOJaA8v8soR+Cf0UXP/7dJe9DYprqecE9VLagQaeEVAS1Q4aiL3LEFo56GMOCJdGeEEOqUaGtruqoNg4I/gmo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721930; c=relaxed/simple; bh=hI15LqP3AkTCXzkB5QbZfHvwe/ApYrNlpYXxxSVfXtM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=IQt+e8pNdYmsl+ndprRdZm9CSNMqOwrCvw8kdcP1i+R4pDQ/GB2Vh4OEQqJYtIpkVRKbrVw5BzwXK1mjWjOhrPjNx2VAKhHiPFKXV6pbEAlq8QNR+xB3qEqb+T9/StpGOhTFQAV2e0IgXBLRD2f3gK2MwN6vpdJvd6WAyMdyQO4= 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=ggRUIkzW; arc=fail smtp.client-ip=52.101.65.28 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="ggRUIkzW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CGxBA9/MAo6sA3G9b3TtXHXXrCSF7VXXh28fnBqPkwsGf7iKzz2zSaGL+QoUMw6l/mvtvsGDGTiJmZlw1dR0jM1WRAdvU7iuz2Bi3rtot+bLxmAuRBEmJcVjOfkKkWYHlIX3Oiuv9fWZXDOi42TYd5dSTrOW7xGSY0hsEBENBPr7Hvqq2vyx/SBapCvobfCzjbTj6vZ/9Az/6mr/NXDEDyOdlx2y5cBUbbhF5Qm5s4LCmUrKeSFgFZmg82GRwcsI+lWysHcJLKIJqckvUjb93tvIqo+yh2vN6VmWHuCu83y9B3bei7yugWexCxHpaZ5hnZDhNXFPaXmpp6JUi0g7CQ== 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=9waaWlkQ/3u3rRCj848z/MRqONKDyAao24e0lG78Okw=; b=uaEBOs5y+D8YhdmQAVCFI+5iPaZUWRbsTuaiQAVi5wI6ZeRa++HOsNAzScGLhK5GGNy/BBBzE3xcm2ngdVQu+2p6eNPz+GAeHZ39LrnSiQLtrb4wKqyIDk42szEBfQxX3DpCvYNBE/7mMtAYt0IKjfNEuJIbFX8RCzFGZf3RvWdoZPbIUUNFPcSCjEDQSZRadV5ew7sUbvmXzG/65NonDYSXho56BCVxWD64qZGmMPqaDZYtRehYKjnwgUWqQUDS5/EI+idfTdBcfH224P2xP025nMf/4GYSHU4rWQvGIMfXy3cFav+WiUhWDQFFbtvHRP2TF/K0bTfPcs8rqlzE4g== 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=9waaWlkQ/3u3rRCj848z/MRqONKDyAao24e0lG78Okw=; b=ggRUIkzWlhtOYyFcVAyuaH5C70mtRy0IZXy7ThyAH49O52fujf4wxL+gDg8TR7PmU0TQQfYU/FJIWyvxxkb3XJhHo7sUguI7v+98KfcBnJWceTNofdDdnYcyi6PIpwE05niUScnZWdFleQNnyygskkgqNmH79HqpOqIdD1LXarBabhXX1lK6RBWLOJiDM4F+sNwyVGexEm9iY4k10P7O2cuE1MXBx/tnQeUFTaU4cBuPSGJHIxt/SBEPJyoejcpjGL0Ceh2n20gmPmIpEs/6Y2Bf2cZtALbKbavFGzEaULgQrKUMWOD5Lz63kXhVuNfQP8kl2jkbZRX45Z+0s+RIPw== 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 VI1PR04MB9884.eurprd04.prod.outlook.com (2603:10a6:800:1d0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 18:45: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%4]) with mapi id 15.20.8005.024; Mon, 30 Sep 2024 18:45:24 +0000 From: Frank Li Date: Mon, 30 Sep 2024 14:44:54 -0400 Subject: [PATCH v3 2/3] PCI: dwc: Using parent_bus_addr in of_range to eliminate cpu_addr_fixup() Message-Id: <20240930-pci_fixup_addr-v3-2-80ee70352fc7@nxp.com> References: <20240930-pci_fixup_addr-v3-0-80ee70352fc7@nxp.com> In-Reply-To: <20240930-pci_fixup_addr-v3-0-80ee70352fc7@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=1727721910; l=6460; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=hI15LqP3AkTCXzkB5QbZfHvwe/ApYrNlpYXxxSVfXtM=; b=KYcComt04ELSSMbGyOZXCNf75nWPSNyzGdPwWCwZ3q8rWYUoCuxwJ0qBr4+QO+6EoIgJnBFZL KfAWCbHVX+/Bgl3O2KbRP3yATCqGqSvXvLEv8qjfEC14ZtvKUhcQVT0 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0P220CA0020.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::26) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI1PR04MB9884:EE_ X-MS-Office365-Filtering-Correlation-Id: 33adeebd-4dc2-4e41-e1d1-08dce1800b28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?92vjwMVDk4geJJ/gIHWAL1mfLSXr1ts?= =?utf-8?q?m9troaiOWsG+FkxLcs5GEoGznFiafd0gC2zqAenG/2TSpUQ/1oOuLb5noTFZ5IgMd?= =?utf-8?q?KlV8qePfk2VgJbDX0Suba/6tl3KjsawtODKD8CSxm2EjLmgREDZqh/uuoTtBm01JJ?= =?utf-8?q?EMLqJwW5upKFfOeoxUr8eZ/3A4FLm+goq4bvniVyVE7PyXtqgOH+fCpIOyAlcy045?= =?utf-8?q?gcSu2Ufpr3HYEstKfiPl5dzN975VObF0cmjLFkrw7RFlIch+AsPi0bEWhlMZGG1is?= =?utf-8?q?hKsIH+tHOp1+Faz5wNZPMyRgL4RhXAgCFMIBO60vukCPrIpjBe0P6bq4dsWNDPVny?= =?utf-8?q?1rr6YpfoE2E8+X66j0MErFyTdDuKkZ963boAr1XkrDPFxmuAjwaPAFxMBs+jC9Jb8?= =?utf-8?q?0PtINBRRcYv9cj+KSGpgf2oggWYdbze75Ee1rSeCXNHzg13+BnSm5h9ZzZlDIb5dB?= =?utf-8?q?Y9Si7M6r9rZW3bDs6PofqY/7gZ72/2iafJWal3uDp7av8sFZ4p9WqTu4mSu9Thzyh?= =?utf-8?q?GBN8u2dnu17+cNDhpgfxM89ge8F1EZDmcofx6uZUREeCvxOl2OJcFlEY4vyc9lLt3?= =?utf-8?q?DkTRdCOK955gaWkSo7H1edww5BGqEPcqJgmvHFdpE7Hs3KYx0gzRq7LRJxrXfhv76?= =?utf-8?q?Z9d6eZk0AsQZSFq3zw1U2e20JkVESDahH8vgOa4L0tpBnIW2J7hFmijSFJ6QbVgaY?= =?utf-8?q?6Qd931abLVgnUDc0On3gcXYw5EXTGyStL+8e1k+R0/WCsiSv/6L0xamvS8K6tXG82?= =?utf-8?q?Q/bpwslSIPt2787p4X8hRU1xyc+gFjL2MsxcVLCdzE0N+TLxh2s2SA7aLD+v46/2L?= =?utf-8?q?wUMlvYv3UEkJQlQDKm8xe+tJw9T8G4znYNIgJPJZUhq1ZOiii5GskhHgpAaQKsSgv?= =?utf-8?q?bKjSmMG2xdD2uWkaFv206aq9W61OcnYQPaYfrKRwQtOu1GrNwn3oHBbnY34KnuBPi?= =?utf-8?q?zEYt3a+8vJMe1r2ntKShou1hEEr70fClSA6RMkxFYy+ajRwnYS5Vx7b7NL60wshGh?= =?utf-8?q?fr/vJ9CD6d6qrzmCXkBd5UX+57re05F77EswOkihleRXtuGVOnBLjvv1N2Mq8oLK/?= =?utf-8?q?icJrf84C0sRMaUnw2O49Cx8d+hwLZHMPgFzh5Hh84wHb1Fef4ycfbV3aoJIned0ex?= =?utf-8?q?6lIA/d4CG1i8+jDXeBovlnVSkBFX/al2zIVE69yglqBFWKuwaeNpW38mFJ/cKgh3M?= =?utf-8?q?A1ntV3L01L94kLoutDdYwOwxtahFM9i1cpGryjHdWsRTlB3tHaO1+n+yRygCbWCRg?= =?utf-8?q?PFWShSomwn9lpwIYbRAVBdv6Xsk5a/NzkoNefQIU2L5ZMWYa8onI1McAMNm/mgzgs?= =?utf-8?q?j+M6dVLiabaJGAgoEoWXM3QDj4Jxvyl8/gnAkOLu7E7Bp66zLg3+jHo=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)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?L/Lq6SX69BZ36RTg64oYkfyWPyhj?= =?utf-8?q?/seRjcE6KkJUflQf37KISA0ErmI+K+AlWaZtC979X5AEtXudg8uoPrIVc6hY/L/nH?= =?utf-8?q?AvxYFFsE1pM7uKJv+6D2/6R/T2YuEnpD/+njNFRBqJoJDYDW0TM5JH+0cdwJk/q+5?= =?utf-8?q?4ySLpLhqP7OUsTMc6yVhTosC7gctKgApmof3lJKwFaNuGcGmVkz1y5np//s0cHew/?= =?utf-8?q?ptZsP6/+5twNBVmgErZMpRku3TsGVX1WlF12PFNyprPI028Zh6Zqqng4l8/AI8cT9?= =?utf-8?q?/npdk27na2LQhMnwdcIl0FNwwJn9cjXMQcqqnDvN2+Fx3iEB1PoqjlhfD+pKBHBCF?= =?utf-8?q?QQur8ZR2dfZuSS6SKAmBIkvkagSOR/9yxx2M22JLkfd2ZI69b3zmXuUUjZtOZOpA0?= =?utf-8?q?Fqai2unk5mFBxJ530mfLvQbg3uNNpA0Ihd99PE/tlI0W3y9LD42cbD5A8WgzOcpw6?= =?utf-8?q?Y29KV5WMX0YfmRo9rrsF7dhWL6c7wc2B3hVPWZ5RyFtSCi4Vd0YAaSUVibq2GZ/pX?= =?utf-8?q?cm9eKpNJ0gL7u733Q22YERQrDtX7XSGNMHAS8MFN2Dmx3r+RQ8ZpvPk5EYL7neVVY?= =?utf-8?q?z57avuH76s2da2+6nkYTDf4xIoqgfRh/vFJN/kkux0pY87p2Z3tPD86Z5vclhFMGC?= =?utf-8?q?5SQdY19lhtxbE+cSR4SbyV2oAxzUyaWD6VN7+fC6TTzse0A9P6AK8aKQ16q7/qX4e?= =?utf-8?q?GJk//Pr5aMtLalfdx4ozBurxBc0wNrhRC5xQ86Puy7hQog4MZVcajoXB32yum6KVf?= =?utf-8?q?ctr9I6v9JbMiApmewECuvSIfV5xORyVsJESD6Jme9CYzeCsgmFhHt8pIPy/aLl4Um?= =?utf-8?q?n6N0OiwG/dAn+RuiMBWpjPGaWFC66RivjH/zbdFm93pFYYw6kz7uLEEAvIKg8U0A2?= =?utf-8?q?D2qZpr2I/GNQe/HZ1l9hglEWiqiAOkr99Q82hqd+vZq2lwqj34Ar/vofMFMk8pfcs?= =?utf-8?q?2MI4krz5XR/VhvHiKWIFVBEukPNKObcv1yCqudGyKB+9KYXd75NdsiYewvZT5Mm/O?= =?utf-8?q?Fol4qYzE1eq+jIqcBDfJFDN3vfUJsNDiGLLxDoM2K6ZEzxDn9wkErDalHou9vp4hW?= =?utf-8?q?HUAOwh+lk9eCE48/crJZt2tPklheYJEG4502gi6Po4nONaqmo0mbRirl+dCbsfW2f?= =?utf-8?q?ettY/bSh9s627osrSZBJg9AHt9DrQRhGlRjgsc6AblU4Zio0Z6C3Q5Hz2BsMM8/ZW?= =?utf-8?q?6rXe75RNesYq9tCcpNzXyZGn/JHU6LfMPaGz0cshi5sw07WlYOOclQZRdHcKBo5LW?= =?utf-8?q?uggM8JSzGSZRNd8+coFyfoyNZJPlCdCh37EcjONeQM5P2EX+tGXSdX79u5AQy0igD?= =?utf-8?q?IjQ57PJ+hF2aDWQkICT0rb3AJmvtopU6gIQ/FyLM3uup0srEmqMaq2UjEdo+Kp8SF?= =?utf-8?q?qPsioriQKe4B4yt/Z1JIs5HM7vGHNlG/fHvflLxnKKeDO0+zy15ecL4sHeqfqO62s?= =?utf-8?q?N3YEyheOlWnT3JplO+7d8QyLKZlXlDL5gPnKO5urlzrOp2Sq5DkKQOyE=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33adeebd-4dc2-4e41-e1d1-08dce1800b28 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 18:45:24.0190 (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: rSdeKrzWxAYIywvxsABH3KK8fHVSM/bgbf3GEl7GGEZ1bdTsrD9K6E7DDGriMzfVx7vly0HsmMM/Ui+GTTibgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9884 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 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)