From patchwork Tue Oct 15 19:17:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13836992 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2075.outbound.protection.outlook.com [40.107.104.75]) (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 594361F80C6; Tue, 15 Oct 2024 19:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729019865; cv=fail; b=KlPsUg61CVTpPmDCwLjDGhaSHumSveoy/qsKWh0l9qqzV9wygpSHFhVkGYVgwfbAZBZv9IkmZBZ0Rlyx+o++Osseo8o1oJTdRkYsdrn/u142nDveMBDNVEvrw5lEQP4Q+grmOeuUguxUVCC4XS1RD9lR4Zw8MfFfuWHOzzoIXZs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729019865; c=relaxed/simple; bh=eJwd3O4EeKnRheRlRCKKSYQF1KJCtHBDVtXu5oOnzWQ=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=HDw2D/PSD+zE2P/rmsWOnltVfqJoM+QkAHTPCQva9qkJAPcvT9SVQrlhMbVibEWeJU5OdBEmwqfQx+FvBTK6Y423IxfnpDvNEf099cO5BZX1cEV67SeNcjisvCXWcCeiHIgRPJlIXfmABHhVlb4k7/oiPJTYOStn6NKEsI1+4TI= 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=TZLHBpPr; arc=fail smtp.client-ip=40.107.104.75 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="TZLHBpPr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mVleSjpkZiAfdC7L+n8luRgsqIbIKnd3UJuA9yQxa0PGUvzTZ7Iow3//jaTaNgYXz26oOvevnxpitzYoLR16Bmb8oNHeHSVEs1C4xIm2S0BFlitWHayoLdIRTdf+71jXJNqlt6ds0lnmA4McXNH6/8kU10GBXRDOZFMhN71ggd25hOP1ysZ6Z6XdS1vfgcOLU6dHlPqqFiANW6f+xEX3mf0Gp/nvMfqVMaE5pIM7+jpZ8TUtAO1OKNWJeT1LfjBqNrZcjCNzioN8xo8vWrshw85IZ4RiuU5jRzUpzyoAmqb2ih6yUnJZXJfaJ3FskVJJq2lW3dE0vHOpTEl3Xm91zg== 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=/xL6fBPQNfNADh+MdEADBRMiYQL3C2whQzkdaGtdHrY=; b=mVo0yGPepCS51b9rJpMZ5oVbEqjYWseHxtrx32/ssqp/DYdNpKCvQVG/NQ2335ObxS+w1Cm78MatxS0QJgUbJPdw+QhDwwrDJDp/zTlrcc2ZJ2QLMmDf6IQ0hPY753ucEbpsJvrgOLO3m+ZskzleJaBs555tVpCFHrFq5Atw/s2TgOnLhmFqD8rynWQtNVmkYssbY4QKgTmCktpIJRRgrb82ZdX95ClN33BAzrIU4ZVoIFY2xQT3FgX65O/xvzReG0ZTdv6uQ9fQ8f7I3BkY5p4tYllrbdyFkQYi0dseyL8nkQlKQIEs9UCdL8oivj8s7c2rfUwbKIjTU00/BnnPVA== 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=/xL6fBPQNfNADh+MdEADBRMiYQL3C2whQzkdaGtdHrY=; b=TZLHBpPrRCz8iZIorvsboiSTYzWRU4x6vLGoAvOyHdnRYxyu4rd4ECyhoVehGLe0lRBt3h1JndqtXJPwl+T4ENrD9xTv/ld9Q7FMk0x4VMeHXcGUXwjK0Q6+XHVb+T8YbmYfWPsuqwoNC4PYp+3wIdnhPaRZYBlRFtpiHUmXpqMGDNud48cu1FK+tP4gIpP1piNCxR/5QOBZneOs8Q7H0gAitj+VpY2tSiy0Nm0IKqR+h4//h96xY3Q21WGff7tpjYi7vpMsgtXjAa4NSKp6TgTXFuKOzobD3DGWqHjrhvQl1QBh7qIBFzPjV8EdDLx+DOhFXNZnzRkXuWDlpvPHhg== 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 VI2PR04MB11002.eurprd04.prod.outlook.com (2603:10a6:800:280::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 19:17:39 +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.8069.016; Tue, 15 Oct 2024 19:17:39 +0000 From: Frank Li Subject: [PATCH v5 0/3] PCI: dwc: opitimaze RC host pci_fixup_addr() Date: Tue, 15 Oct 2024 15:17:16 -0400 Message-Id: <20241015-pci_fixup_addr-v5-0-ced556c85270@nxp.com> X-B4-Tracking: v=1; b=H4sIALy/DmcC/3XMTW7CMBCG4asgr2s0Hs/khxX3QBVK7HHxoknkQ EQV5e51WBRQ1OU3o+ed1SgpyqgOu1klmeIY+y4P/tgpd2m6L9HR560QkKBG0oOL5xDvt+HceJ9 0U3FRhbptW0sqoyFJ/j6Cp8+8L3G89unn0Z/Mev03NRkNmktvqKmNOArH7j7sXf+t1tCEr7jYY MxYiJGYjPhA79i+YAsbbDOuQKQEyxhc+Y7pDxuAaoMpY2RhBCi4bN0TL8vyC/CtRjRhAQAA 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=1729019855; l=4828; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=eJwd3O4EeKnRheRlRCKKSYQF1KJCtHBDVtXu5oOnzWQ=; b=O1YSQCILgtibqeu/5G7czt6ZNbdcMoefNn6fMgbGBUFHtH8MA6lLhPLMu+ngYP7lGCCXuOdOk k3GLaX27qUBAwKuvzZoi8NZ4AkoRrlVWtmaFCqgdw0/W9Sd9wGAAjaX X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0117.namprd05.prod.outlook.com (2603:10b6:a03:334::32) 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_|VI2PR04MB11002:EE_ X-MS-Office365-Filtering-Correlation-Id: 65c57f40-7973-4103-18e9-08dced4e0921 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|7416014|376014|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?TZeQoMBs3pzylwdo6tw2Ce9PDJL18hU?= =?utf-8?q?TCzTEWc4ifh8fzlqfI8/E4ivnn/BFbV5kAoFfoa3MJ7E868OZ8nWwCWkz4VUl6/AW?= =?utf-8?q?ZeyYsewROSR5homMk6JPlaZLysfPosxUQuZxIj+A/Ag/WCZxYM9EBnXS2K0GRsCX6?= =?utf-8?q?7Ryy5tn6r6EtBTdzkKMnLAjSagTiMa4isXGhJrpO3SkbHSJWPJoir6deHtYAmF+O6?= =?utf-8?q?8pY0NEVOSHQEa6f/ROPr+5xNKpkOb6NlskJUXYpqbJhGVNCa36D80m1MprU/h62qo?= =?utf-8?q?FHyOtr6ZJGSxo8P3pWm8J5iYDhZ5xD9e/0IKOv/jF+aINDDSduBczi0A6cANcxj9y?= =?utf-8?q?4+7BztnSHne89JjB+f+RnlVpsYpilspOcEQg7A+ZURXlFi8evK3CW7XD0GAGUSrkU?= =?utf-8?q?e9EHG3pu/smsihoxZePbg+b0ASU6TgH52Icr44eqFZf+qWRfYIcXz0jcqx3dG+y3X?= =?utf-8?q?DRtm9+5jJjw/suypx/Uab712U3WVF8i8pMrPnHYZKpXXZwsN9YsGxoEW812LR4PdU?= =?utf-8?q?WUG49795EW6UKSvs5ucgLIZRcXiMhG49JGpfxcbTle5kq2ap7o4+9+eWf3Qj4w7KK?= =?utf-8?q?RjV/7XYpGafFnmB5YRPWGjne1W2FyzZ/0JChtj79eTCntBCnh0tIuEznwzsg7b7ra?= =?utf-8?q?jwfRFzTi3cedHe2KKf1L/FMN2s1LFOJzd56pD/VjrzBrBeBWbnr+5haF4kMZuY9gP?= =?utf-8?q?a17FoMLCcALppXXj5EqsK2JvBheRQ1OI/5FxuDRxphkZobgXPGp6HYDxCYPanBjK1?= =?utf-8?q?wAnx4h5FhHAq2hfcmo/udx/k+yznQu51599ImuB+RG6y85QPOSjVztkFhMcgpP5lq?= =?utf-8?q?OWN9DNsH4glxn6Wn1jC5IHhzIiaaeE3Q7E8yIo0Enz+2KPUMpxnkic94rE00rqWDZ?= =?utf-8?q?awTiXjZQAyykhQp02ag0P7SRny0w9yrbmprXu0pVlThXp2WEddO5StmwqX9kUav+4?= =?utf-8?q?sjOyrv7VdFim2zMWN04rVkHOpw99HuIldI/Dm0SrbHPLGftwyhvO9Ha8MKvIYyC82?= =?utf-8?q?LWRqgu4a3PO4wCXgiIGaU1a2f+TTvYJoRo2lWnbiOcsNQ+hdqqLgwuKY+CgbHk5jJ?= =?utf-8?q?OPR9yxec3inaIsQ+6h0JHWx4LPBOx5rE1OWxRVNMAKk/z79IwZyRYvES/JwaxvyHF?= =?utf-8?q?wIhc8HW8+MVTs1Hk/3YMD4mOXQZtvSorI+7lHQrMRLbFOABq9SensUX9dDuNWAzz9?= =?utf-8?q?buUt9K6Idm3e9yHPaCMoiSKO9YfFG2dbdAaNus44u4OLtMMa5J5x4cL7lK8QbVY9D?= =?utf-8?q?ROAIDBFgjB2gc5vOW9nLpuDC07nX4J79W34za32hPDYQ5vnzd/aQM1Ug=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)(1800799024)(52116014)(366016)(7416014)(376014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSp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IjbFnJ9AKa4/MRgX7Pn55lj5M9rnXzC1sd5qTKS?= =?utf-8?q?C7bhm+Nvk6Ubij2e+HiV7k81AqbnNnX/lmzrvqEQe1kapBZRyLM1/lTf3zYBRfHe1?= =?utf-8?q?WxT++e7g8ZHDIxMUYDMD5HTlyhXVoXDN+gIyRpnPE0RkHvLwe9eIeCQSN4RioCXC7?= =?utf-8?q?FpFAPrFSvtUQt+j//WZ0rmqiT/EzFjwIHqLmbRlRKsPTMFpWPMvZFSYSMOVxW4URa?= =?utf-8?q?Ps5EehU2ucMGuDUKXoHQcdZMZYBDdQW1o7oLpPBXKR35oIE+P311jBJY7QNZc5Xay?= =?utf-8?q?glnXzMwVuqVJBo5DQMFd+f53th6LBenN+aV2VtgO609mbTDK0dDyeycz0onQWWizy?= =?utf-8?q?HzXpLiQgPRhYJZKJh6MyUtk0cTo3MyttwEc9/RHB/KA5D0uU7gWzZDswRtqkJL5O5?= =?utf-8?q?67g0QnfWUjDOmwA8j64AV1xxrgsg86W8dIRX7alhiIGKgpxH7t8pxY7mkNVu0QZ3z?= =?utf-8?q?Ro8zMyXiyKXkoBA6pIeD9i1wzI89nt4+ZUyoKGU0hQU6FF/CaEBnTIuWVZiAlxGZc?= =?utf-8?q?orJWaDxNqI37tBIpahizzDFAO9kn+Bb8+Q5GRcxRPNADJ4fxzF/zWZk2i0HtCihUy?= =?utf-8?q?tzaXt1gAyDdBEjntjbjdW3a3ADCXX/OFjjl1AcR7nH8ECnp+G6mgBudo=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65c57f40-7973-4103-18e9-08dced4e0921 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 19:17:39.7119 (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: E+8vqJu3CoR84OaADxU//PLUV0KNXF/KnEkmFkm5A46PVT7PYI7bI5o7C5ANoYDy7GUcK3h59SraNqQ/ujYCkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11002 ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 patch: https://lore.kernel.org/linux-pci/20240923-pcie_ep_range-v2-0-78d2ea434d9f@nxp.com/T/#mfc73ca113a69ad2c0294a2e629ecee3105b72973 The both pave the road to eliminate ugle cpu_fixup_addr() callback function. Signed-off-by: Frank Li --- 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 --- Frank Li (3): of: address: Add parent_bus_addr to struct of_pci_range PCI: dwc: Using parent_bus_addr in of_range to eliminate cpu_addr_fixup() PCI: imx6: Remove cpu_addr_fixup() drivers/of/address.c | 2 ++ drivers/pci/controller/dwc/pci-imx6.c | 22 ++---------- drivers/pci/controller/dwc/pcie-designware-host.c | 42 +++++++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 8 +++++ include/linux/of_address.h | 1 + 5 files changed, 55 insertions(+), 20 deletions(-) --- base-commit: 9a3f54febedec23fde034d22bb19cf6f13143484 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li