From patchwork Mon Sep 30 18:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13816863 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012035.outbound.protection.outlook.com [52.101.66.35]) (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 27620824A3 for ; Mon, 30 Sep 2024 18:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721921; cv=fail; b=Dh2t1hqKg4+Yf55wWd5MnUy1UQM02rgNy0liJGJeQk89cgwDPfH0yQZ3E3qmPgXXxvDn6gk7jCATNw9CKw/KYPjgFlosp839iO5oFn3KPnB5DCRnRu4Rx/ChOXhLiagvwOQiq9rZbbvLHxK3lAwOjE/T9TVs5HaZYj9e2SsntHI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727721921; c=relaxed/simple; bh=3gwDyouWtiGcmzwUVM97GcKaE7eoOS2EN8sfz+VlmWY=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=SjwbuLBny+gMiLQuVTufOlYnaPHyvYTkFILBAFYxNYM4U2jZAvnu+Rnqc8WTr1CTxegcJ6/SLiOoKYEccgRxSmBF5VRseZLkU0u5oRl99eApmC91gnIzb63/1dJMYED+2o2KE8mSCMczLGd5doGOe+w48L1hc52VslZggW2P5x0= 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=LYzyGMtd; arc=fail smtp.client-ip=52.101.66.35 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="LYzyGMtd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mKaFuF7+VwXEp4F1Kkj72HxZ/3CpXyFC72EP1jfrSMzPwzxud+O2zT8Pd6pXG1Ml/XIWdlv/FPKDAkXEyr3ZoRpFXnlPRRz9W9eF0DA0rA+XncyO5AMqQAWHR/53zF3Y9NVubNDRyNzVk8PamRrVwPS7XgUlzKvXBk1d/VKZ8sLjVxcTWr3uIFQDws4jXWh+iJX++AQWjVpUnVV8S0Ya+EweW3fGlm1qvXDKXgt7A3l8lKoelqoLKD6lsDbro5URhioFEILVE5Ge1SRF1kf+Ky6DN0U/pLnod8DF6YMLDrsoVzrdH/VoBB49wCp6t8V9JwQLGvWo78rb4JtystGrLg== 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=uQw/ydhcYzi6pw0tOVFnhtMwWQwC9CBeLvukS7bofNU=; b=o/D1TNBbYnvIZWoGGG44+PM7nlquhE5bf3Nbf2F4oIz3JTm/6wszSy4NiNcZhExaCI8iWG7mz3Hy0jaCChsTN40T6aWBoQ+P39HXfm1PQZfnNnpfftMdVd5k7A1Mdh4G7Rj3wWd0imrwsfpWqvRb7ovpMR4ev8UAFqfeMBU+3Iw+gXJzWXnHnX6S/PQIThCadRsnv94irKCWUOdz0vkGQ2d1nxewFkt7zgNGS6+QgIXBJimodZDQPtC6adnaQ6p1x6cFPU6vp57+BcE/TEGclzaM32FJH9fvQurzwmZ6EA8HXjvqjJd/LfhIU8I8i2r8b8Pq5pGF2Ck+3cIcrUPMAg== 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=uQw/ydhcYzi6pw0tOVFnhtMwWQwC9CBeLvukS7bofNU=; b=LYzyGMtdnp5mdKQuLb5WOX2bhFtXbnt6V5uNaTUgmRpM8laI4HhPtufqXNW1m7FAxV7lNC78lgHnH8OuChuMTHv31f5pBEcXIfnSQurp6fVB5Z50rB4dmeAdbHALFSZvlfMPviWV24+kZyWAcIiCNMyfG4hDHl6QTpdeHZYXKmvVqPDC1Rk3oy5PaNTX9157oVvqzwNN8lekT2EatOgymhZu8Qlk26e/JvCq8lfv9igykgWHVfMBse658xO2YZLJk3YZKdw4qsQp+5ErEiaSCSoZKOpKo9lfPUlbw1ABWRXdJPJ+nAMEvv+Cm2JqkzEPf7vvvwD3VMGHEbiZEhLTew== 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:14 +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:14 +0000 From: Frank Li Subject: [PATCH v3 0/3] PCI: dwc: opitimaze RC host pci_fixup_addr() Date: Mon, 30 Sep 2024 14:44:52 -0400 Message-Id: <20240930-pci_fixup_addr-v3-0-80ee70352fc7@nxp.com> X-B4-Tracking: v=1; b=H4sIAKTx+mYC/3WMwQ6CMBAFf8X0bA0tWwRP/ocxpLRb2YPQtNpgC P9u4aKJ8TjvZWZmEQNhZKfdzAImijQOGcr9jpleDzfkZDMzWUgoGgncG2odTU/famsD17Wqatd 0XVcCy5IPmN8teLlm7ik+xvDa+kms699UErzg6mgF6EagAXceJn8w452toSS/5epHlllGUBIUC LQOPvKyLG9b3X2R5wAAAA== 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=4498; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=3gwDyouWtiGcmzwUVM97GcKaE7eoOS2EN8sfz+VlmWY=; b=3FD3jbNRQtDRdpttJuUXemdRDzrLZD/bG8q0m/VZB73/CtIi5lWhLmNQg5E92hh+4UHVNLWRp A2uja3/kqicBiFbB58Gly/+OTEsM3/zLdKZYqsoaZoyLYHX3QIFHi/B 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: imx@lists.linux.dev 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: 32f54769-89cd-4b7a-e156-08dce18005b4 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?TOaLjlK1bhJCdoBuB53DGYJyow2XUQH?= =?utf-8?q?2QirUg+KIFQiSzVj+ZL4HGx92PhcALjI8gAYtzzaJ6y+Kngxf0N14fAPce0dg/NPu?= =?utf-8?q?Ef0KPKO5QLv1NmPCmub1AXcLezHATUzgK9vHycv9F/cg/uPNz+KYYpJmchul7JFZY?= =?utf-8?q?G5iHAiD2mtD4Os7aj7NmteNU4QnDrQzy0rwEes4HHBhdi8ch2hnzci7+C65Zz9wUi?= =?utf-8?q?IV7jrzYitO6HhHny272SIpSykGRI59mX7/N4qQht74R4tTyCUGXvLp79Ffc2uPC2Q?= =?utf-8?q?XsthWpQuVdHhLtWqOaaoM2Ne+IBWQen0W9Y9Fg4LlFw9Mi3WnyifMUSKXk81HlCK/?= =?utf-8?q?stfZ5woFl2TedeTmy2xLELsoGkL/3lnjaV44VZv65eotEp5VGZ/TkGMOlKJ9po4RV?= =?utf-8?q?kmj20jWfFCRguEa8nJnDwGqjrEhDTCr5z4o7rqBWj5kiT0TEHcHJzKY73oDrH8Xu1?= =?utf-8?q?Vu1r4III4rVi3vV7Tz4/dA1nW8UOBx9tu/qC7JuU4r4ZayuJls0+Ekb9CWGY0msV1?= =?utf-8?q?6CyoulAAIhf9ZCCvBqor1+JOkvHJzE7g0g+6ZChJVJvh2mV8M4zQb9Yi583FpHY0+?= =?utf-8?q?raJJr2c9KIq3PwUh8d+jqbN5TVwaJdE85w1pVw0uP1/Ev+yjqwRjaCvoxVuKTm4eU?= =?utf-8?q?313TWO2Zr3rCzOEiJNht43tejY1v3vjuVGxdBHa8R3s70tJzNteWJWkWq6APuMMfp?= =?utf-8?q?WGTmikg/WPfZPFtcUIMpWQCDtiwo107/q/nSLNGRZrZjcSoNY4rUouklL+iVMkY/O?= =?utf-8?q?CJLcZ/Cl5U3XyCUUdms7L4W0hT1tDtohICGLNKEo1gHEg7fsvF12GRrLKHMbpHEsp?= =?utf-8?q?44RqhhDmqRHxlL/EFSsgzUJi2l/P6IpKfBbLZ8cFV5WpTFnM4akpnTt6NW2obV5Ax?= =?utf-8?q?uC40Dlytutqiw+/2TZlrh95vtT2VWW4sDBowCJwYFt4pwHLYAOZJ4Ao3uLKJ0N6c7?= =?utf-8?q?mKxuQ42a5lV+EWZiNmJLSNWkg5dSoclHX9bA8ybiN2cEBpNDmD0rBSAJrod5J9E4k?= =?utf-8?q?EJaliTTEO8q2XKi2mXnXEcj+BufgpPZIQn7fGMTetdSrvV8zKMQfse05Xtsjh1suL?= =?utf-8?q?WDrBn7fCSEiijqlIPWGNMJhWKcSvX3aQmuuFsypZMwaFC8StiLRCl661TUt2pg/9L?= =?utf-8?q?lOnHnjtGWyKm9FEBGnwqrlB5J5KibaVZDJfbS5aYz5m9OI9/X6M5+zGRKxDNUNRxl?= =?utf-8?q?0qUNzKvOkxoN1mxqHS4kodCwcG1FJTPX0CIonoQkQkUNYgXNwWn0SFFWwtPRmwKZe?= =?utf-8?q?45XyZo+URUs4skqsFwCbMIpIFDRuyWGirdYxzaNszpq8wHT8A6bB8oHH9nCMt9ygO?= =?utf-8?q?/04bptlT/DJEiY9RnT6+Ea6zcSdvuo7u0DrVFnO1BAS1z0LjTTFggBg=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-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DTn?= =?utf-8?q?gxBiFRluvFbfM2Bi3dIhdJdwqKMNTX9mvn1v3zxUUixoHJqBHjkUe8r2ElklsuerG?= =?utf-8?q?C3gNjziaI5a9RQaQQmR0wvvnjrKlQ2s+KOVCyQPeW1T0qoUvMoGe4rOFwBYpJpVvs?= =?utf-8?q?4ysL5IKTG6MF9EvVDI+CD3WNGgfStpkR8D6LRjrxiWUPoDl/aKOq1V8fd4s6Otls9?= =?utf-8?q?uabSBQ2qLOKled7gOgiumZdAYiophtXEtKUZ8lH6inzWQrl+QUTgHuy1XSUO6DxVB?= =?utf-8?q?/rERcHuaL89i3hjV0Zs2WQ6xL+F7Ze3Po4jpg9vKiQxnre04d7Oi5eT6PIv2eO7nD?= =?utf-8?q?rKoZP4vAKhGsBoXKKdlCqemS7OR9BM6xU/vaW8PXuJ3Nhynx0wbNsUZ+KpAzB0Esd?= =?utf-8?q?lJgFm3fDU9/xVFGYPscP4JjPZZE3E9vEgh2SkQA2U5sRY1yP1IKL6/tl8AzxLxFyZ?= =?utf-8?q?BmXXLlgVDU2ac0KTKLS1Gr7vR7/TgehV07aOhYeXN2sUqqgebBbrGtc01Cp6k3wA6?= =?utf-8?q?p1X2RNBreMNHpEd9dWd5iNe7CM5HEWcevSP3f7Hk3Aj5tTvDVkEHwS+yaqm38HVeF?= =?utf-8?q?Ny31nJ+ARuMAhzFr/PnFzZ3Zi6ShaReuku+je3YaT58QFuunxTw4+OJSDTS3X3wZ2?= =?utf-8?q?S1+ois+KisyjQBu4s9P7Kl72ijYemrHELAUao4sl2UJ3s5yjT67gQmYw=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32f54769-89cd-4b7a-e156-08dce18005b4 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:14.8510 (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: iR7k+92GAHOVBjTrpXS+SJPxh/K+NSGXGnUtzpOc8SWRsQT0IRRnWifZS2WOJ5ccb3wEV38caIpWxhkGD4K09g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9884 ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 └────────────┘ 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 = <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>; ... }; }; 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 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: 69940764dc1c429010d37cded159fadf1347d318 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li