From patchwork Tue Oct 8 19:53:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13826888 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011061.outbound.protection.outlook.com [52.101.70.61]) (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 EBB521E0488 for ; Tue, 8 Oct 2024 19:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728417270; cv=fail; b=bvMcFcoPgnOR7IOfKoJqBdy3afw2OVleOV+EjvsBFzNFSXHsR2OJRQg08ffAaFpN5u3ZG7tD/oWas/6mHl1AZoSjK7f2C7gWPMT69TzDXmu7hL4H2BC7v5kaPkGWphHUhVphKqaUZxG7qCggSYkXYAav5bRKvXLRxf8DLyfzRwQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728417270; c=relaxed/simple; bh=HO3RF+f1eP8myCyS6q1TjWPk2I7D1R5GldyB/e+ttPg=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=twTS31nmE3vAW+hfeGilLwgUkdTxN3FCvFstCaHjL25MHOS0Vb0jxl4KK/GNEDyAkjnwC9m6bcuTNYs1mGyBGgPXv+UxImZ8tz63sHp/WcyE6+mfVwETdSCwDcpydGul3R68ut7CDM0oAHIxXC9snx2SicsGJNURCmd0VAhjcns= 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=W8q8Np/b; arc=fail smtp.client-ip=52.101.70.61 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="W8q8Np/b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tAiq2G9utsKPqOgzBdL3TMhtrCvjwC76oPfbGxAPVVigmuLT8QLLROHNlfvXWeq0FHyUb773VDgrEKvnt4nhA9oXDGfg4nD78xiKLU6IjxQcDR/5oh62CpwZ3bs6FjHYRTLnlilHW3UNLTNY1pNLYRkdEGJ/ylvwAuFZ9nsSb8+Eye8Myz6obMFJgGJmxv2UdNH3lqeMI4XAijmdljBZ/aSsFILfagZWZL6C1FeK4xnZxTlKvdCcFnpFIBCgw4GrB+4917KS4qab8ZnZ9VOojXVggD+R3nsfsmLcQYRXBPK+uXY94dKxXeGvltWiIem3JCrwPByn1L0xUzLfLHtSEw== 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=NQ/vBBc27kEks902DM6ab+mHUnmP7cGQAewthgz7UTY=; b=c6EzRigi4sc6nLgDepWdvSxDZTVXT444tf1YMNbg53yelySMdALNMAud1GbPuO05emAPzXPdtuP2eZMb/5pLeG25y4+yBBrJC+0B6v+X5DddnTqooaoHI0FwVaJUTOiBdha2NdgMNC4og/DQfnK5FWqraSlcNI0m63YtpAhckLjJpn3Zhiyn1UfmTvfgLWq3oNf2IMii+pKk8DozfYhGkKV2q5k7Lx3khjR++YUoU9xENZ/ub/cC79lfBMW5T760BCcWj+Av/Zs9865pYO31h2JKiWJVcgGaFDlJJBLP4lRzt3/8vZpd7xEGOGYG9vaJBT9e1JtJn9LTPtJl8TPiNg== 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=NQ/vBBc27kEks902DM6ab+mHUnmP7cGQAewthgz7UTY=; b=W8q8Np/bNhWXue9KNSCjsjOZysHaJMnDkN/svb5C3/X+dMpdek26OYQd+xjdIdT015ucA+u07rc2ezdUsxCzfC0Aklc/jFT5lbUFqVI457PdX4Tlz4ST4+N76c9X5kvCVMTaDTQfgGmXBgX17haLEriHCLyv+BKXUDLmmEntdbpo8eXQw3FDldplaHzK8KD7qxBoMtS/j72jCPpxBzT/SGpKRLxDOYX6Sq/KKZzvuQufqhpE7QmpHYRXULig3cACrZontoJw1iAeO+qYmd79Nr7n/whE/ccyuipe5ISJtBIfjFhbRlXPuoGOzQvhX9RkmFHTmMdRYuOYwavJLRHrAQ== 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:24 +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:24 +0000 From: Frank Li Subject: [PATCH v4 0/3] PCI: dwc: opitimaze RC host pci_fixup_addr() Date: Tue, 08 Oct 2024 15:53:57 -0400 Message-Id: <20241008-pci_fixup_addr-v4-0-25e5200657bc@nxp.com> X-B4-Tracking: v=1; b=H4sIANWNBWcC/3XMyw6CMBCF4VcxXVvTy5SLK9/DGFLaqXQhkKINh vDuFjZiiMszk++fyIDB40DOh4kEjH7wXZsGHA/ENLq9I/U2bSKYAFYKoL3xlfPjq6+0tYHqQmW FK+u6lkAS6gOm7xq83tJu/PDswnvtR75c/6Yip4yq3HLQJUcD7tKO/cl0D7KEotjibIdFwghKg AKO1sEvlhss2Q7LhAuGmDOphDP5F8/z/AFRpHvBJAEAAA== 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=4665; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HO3RF+f1eP8myCyS6q1TjWPk2I7D1R5GldyB/e+ttPg=; b=G4vFqdq8y7fJtg1OZDTXkcv6y0idRjaE5Pgkge0AJnx6IUBRXudORnBPNhw1jlmrfUMQm49x0 eJfofFCWywkA6lk8RUNOPfhcjTOVwuqF9QQ7vplkATQAlSxRRYdHCBW 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: 354cefd0-7d32-4635-46bf-08dce7d301df 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?m2kkHzZ6aw/d4l6cmgIfPk04qwrHMtS?= =?utf-8?q?YYVl4ORl/y86NxSevGgSGjXZhFpb1shYNvvmJ5quR/yxpT3m0TESzWy4MGW5LnXNo?= =?utf-8?q?YN2kwsc/euhab3j6dZHOfhO6a6/BtcNRwc0IFW5jYa0ZpSDOnJ8BW9v1j4hCHE7F+?= =?utf-8?q?JLrXR7ymPqDK5KkhAer2TmpLLOakEtA2hQdamDtDG3bx7th+4e1rrQsJqftv3vIq3?= =?utf-8?q?T2ryi1MyGWWExW2uVv9WRSf/y/dFOiWtBDNN7/E6TBPC2OxLRB2qjhzGc4p1LU2k7?= =?utf-8?q?1z3xTxg56KFeZAccAYVeJZU2orCTNAivFmmIpu2jg46rVpdC3Strfp0wbIkGBQZYu?= =?utf-8?q?4Ytw2ygRA2MBcTy6kE7d7qR8w4kABZ0WvQSLsR+kGC8qsnrZjGlNe5lK4DYhXC5NS?= =?utf-8?q?Dpf1ZiAu7P/ihSjggG2QpG6HEKHb0m2Zs32te8SJQo9rJcoMo0g17LWxMXlaFSmW0?= =?utf-8?q?LwW5mja6AP7jo2ZXPoOEDFAzhdgoTvm3sC4uqiI9ZlIpEQdAFIlIKxFXnMZ0rsewx?= =?utf-8?q?5/ozkIVdKk6mclw5+AYZSl2ByHGDzYjsHXwJXLsEeF63ZWfLOTWgc1BUay5vQGH/m?= =?utf-8?q?N8er5pHjxbYohB0dCWem3vAbRWhtpPiU5PJxj3ScwohMS+ceSSiph6japi+hK2f5M?= =?utf-8?q?QFJEdfGEH68HTvL8q5b03sDkm8ON/qNlqqj22dLOf8iq3KTaC7/jG+vm2T/IwIGTY?= =?utf-8?q?9I5SEdsw882/fVHVaMQ2c0F6va6ABgSKYy3/7DXIIXghNr5lm/Nuh61VsQzkN5K0D?= =?utf-8?q?5BnKcffPRp9Mk6U94jVmsZGnvFALV91u0uFIBbWYPrRlWbQ667j8vtIp6Xv4V4li/?= =?utf-8?q?smhbfF4kGwn+PwOBlmfjbKSG3ym8RjJW99fQHZg2CsaN7Jzvxz0GhVBjJ3mkVDZcb?= =?utf-8?q?7zMtyMVGpLgndgkLVWNp7lvzCNuX+enqpbeMXFkI39yeUKniO4tU4qgz7o+sWkHln?= =?utf-8?q?z13f4/XP6ZDxr79FhGAmSkenhbQ9S6oTtsKPSwCx+2Tad5JqM9Ie+r7mrGbGwn/+T?= =?utf-8?q?xnI7pKSmNg2D4eBU8+ZgunvaTmPOe3RWRfQmEE9RSgB43ugfHWc8kj5XgGf6lcGrf?= =?utf-8?q?3CnErPjiOzLy4oDp/zUz2wc2eOhLxYXKnWStAsnH2EdzqiNIYuAQlHsaPXv0/vgTw?= =?utf-8?q?wiUhaVJx50f/QWqI8ovU+P0qz6mLADMNcn4zx1SXq9VeGgb8zipHGOwoZMze9tfZY?= =?utf-8?q?PqTSmm3uvtKIiIlfi7L4JoEEiNmaYRp425HDR0axzyf55Q4015N3PetG9Kuw7cDWV?= =?utf-8?q?dGnKhXhQtJOc9PhcUkTxshfECaApBVKv6GeJPCiGR8NsNbEF0sTdbd3A=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?sLDYuPJn+egEUHJuQKPPGEAE92fu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f-8?q?aTP0+85fCkNliIiwkeljzLjds7PglelkCg5vDhkzMLpeduvfbTCYb5Eop3/6ihb+2?= =?utf-8?q?yjt06QB5prJB28irrqqaS3nJQcJO8xv75jaQ2nnV5GBsXebfQGXXHC9Fsx1pocGjz?= =?utf-8?q?Dtd9Kekuk7kVfVIu46j+M3zKzUGTJvNf0ew0o8V4nMv48RT4YJ+5jCTB9mQUDlcQp?= =?utf-8?q?C13FTXIeXZc6wjn0TFDWeV5gtBXpVDjmwoemaNaX5IQvvj4oFnI/dmmCLieo2CLeA?= =?utf-8?q?oNIXP8rRYN7Q6bMUjAkisgl6wq9UHxOg9f3taO6wwdtBLAjiIqkrVYRfQ5nkp6/Ar?= =?utf-8?q?qm+JpVLFTR38JEZsZkmDyAv+TT8hs45IW+0TDTohbe4rtzeFd77sueqpec4VLF2fj?= =?utf-8?q?4EIvbDeDt0/nuiwSvzKs6LxHmX+BifdS0xbf0Q4abCy+UDRlfV1XiyVnulGKo5ZFJ?= =?utf-8?q?Fc3fzmCi0cI3vTcKmZ01WqdQXqXJ3lj1omdpWcO36+6rOrP/kiaChQwdX8uBEx5tq?= =?utf-8?q?fZRxpDuRegQSn0slrN7mnh1sSqgmb/4eOqg+3uQxdQg36fpBB2rvHXeSyO4vfZyy+?= =?utf-8?q?lcpo/CKN+/2Uy7egREeKj0MsLuByGErS5dF+A8eQd/2hOoB94eWQo1OucvCQFdMFT?= =?utf-8?q?Ms7fGRwcDcKp?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 354cefd0-7d32-4635-46bf-08dce7d301df 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:23.9643 (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: OXlrbN4NYGEGTAtPzdBMllmSiMH/fNfWKH/bssceXF8VE1salyBvujeMEpH97fDttSDl+UZPAx9uu+5Qcg0FaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10577 ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 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: 69940764dc1c429010d37cded159fadf1347d318 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li