From patchwork Thu Sep 26 16:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13813517 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010008.outbound.protection.outlook.com [52.101.69.8]) (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 0A7E914884F for ; Thu, 26 Sep 2024 16:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369267; cv=fail; b=RuqARCPq44bY9MaSpzmNwLxqReq4lXKg5f8+yTKVdnZ8d+Bqe4uiMPR0zaWEOxB3OLnXNFYLqA5bTngwOauCjbNdJlLRPPU5tLnJuCHkAZencPaPSV9xYDrrauwq1Jp6PhjyBfVln3IT3zUrH5hzf6s085qRldpIqaJY9/NAQqo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727369267; c=relaxed/simple; bh=FpkrPa2VP22uAr6FMuItNQ2iXonduMIYVJxmxwL5tnw=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=o36TwwhPLxNuzt+5aQ8hltuEGAVq3N38LAhjoYyy/xC9X0//pUxNgnYQX39eoqFcDcJmwlE3m22bGYIpauSaFHjuQiWA80k6Lwr9ToyzoLYurdSrKrNUPExI8sieqNRVFtax0LbETDkcGhJr0LaNE5u0CFSSvofGT2RKAs02xeA= 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=XkshRa7Q; arc=fail smtp.client-ip=52.101.69.8 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="XkshRa7Q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q4tG7ssT/TCQdv9N2XQQ8e2fB0I3rIW/oj8y5u6CXhXTiHfzco10BnT4BYEYm5k733kRWVg0BajrPYJY+FLrea78H6BZIGuZqASkHtq8YGPHeLeTZRRu7SXUdahTKyrhnlddXHryc+F/rCPZl2DJVnSF9gmnziSYRtOZHzQMUCHc52aYiYPEoRb4XInPxURhanEbuyVlJJAet0eT0i3oTIm0USnWt/EocGBclaTl8GcTYTrshdcSZ4z43+Z67eU8Wry38K0Y6fIXm3C/pGrxrA05g20Vwi5UjkKjE57Fsw1n05BQGJ7xN2BI8htvL4+bW2wD1SKeZKmKdw3cEapLJQ== 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=g89bNhf3rvaawhUmL+454hBG5uyRA2EDI3gF4CjBLiw=; b=o3Tu1niirkdFBnMmjda/1MB7SyYcYTKCOoiEO3+0bNikVKvWtqPdBXri4kCACbdSHw9loG8230bq2blv8uT+2JJx9duDDzrkeu26ybBpKnqfxvzbFabpMDp7hci1w3CvfHgPKw1ierUbvnS689pQ+ZIvqIUuXuZxoSZvf1o0xi7J0G6r/iphV2pf8spSiV0mTZrfpdQhSjsKSXBB5QmhM5CllmRbL6LD629hTDSRPWgwuONRx0tH0zP2B2Xdri59/ioDef1lhKqp1x9+X0JZDDuPqil83jrxMfWRoDEVU9tpcExjo12uLEzMirukZeZkl0aPwTfJWqqtnv9UgZRCVg== 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=g89bNhf3rvaawhUmL+454hBG5uyRA2EDI3gF4CjBLiw=; b=XkshRa7QUzfI2ieekNvnEaS1+wIaKp4n73EQEAArIiccZ4p4p79P6dRrLblGxehz91OkFNOcQvRMMYBJJdyQfuvMeTLKx50ieIGpxOa2vqEXmvdGnm9i4gXWJC/dbT8G8aTZaak/T8HGCMQ1tBNrzunWrTbOWjP+BOVTsRD2FrOan/9Q8ccBtbfRyUHzYSnjzbtu97a54b5rpgdwjGmCUSuSSoD6M5DRB5/edMDSTpHiAQ6qvOARLItUohPaj93cEc8JJjWdFFYtVlqpotDtDsyxtBY2xGGNzPrUpB2vECSoZstHvUH4Y6MRl+4pcy5EVfzl1ara9ZGrKpPqhtAz6g== 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:38 +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:38 +0000 From: Frank Li Subject: [PATCH v2 0/3] PCI: dwc: opitimaze RC host pci_fixup_addr() Date: Thu, 26 Sep 2024 12:47:12 -0400 Message-Id: <20240926-pci_fixup_addr-v2-0-e4524541edf4@nxp.com> X-B4-Tracking: v=1; b=H4sIABCQ9WYC/3WMyw7CIBQFf6W5azGAVIsr/8M0DU97FxYCSmoa/ l3s3uWck5kNskvoMly7DZIrmDEsDfihAzOr5eEI2sbAKRdUckGiwcnj+o6TsjYRNfTnwUut9Ul Ak2Jy7d2D97HxjPkV0mfvF/Zb/6YKI5T0F8uEkswZ4W/LGo8mPGGstX4BnB9VfqoAAAA= 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=4311; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=FpkrPa2VP22uAr6FMuItNQ2iXonduMIYVJxmxwL5tnw=; b=WvjshxrzRCkYJ6yfl5FN0KS676f0DXj6HgJqpPvUDeqF8+VlSBg/zKSqR0wDarfY9nnVq+pSy MvY+Sd9Os6kAnTdG4CwqyeppS3LWLvuxI2faLN9Ea2TgF4cPvTGYAn+ 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: c48966b2-e334-4426-1b57-08dcde4aedc9 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?gQUQjZh3WA53pwvFByIz1BvArQFoFym?= =?utf-8?q?2pF+rxcywUKyCTuOiplg+GLvDnfshHsVJVaenluES30YlwEj/QsdF3feIiQF5xcrR?= =?utf-8?q?LQcvCKnn4RW/NWH6hgukuGiCmmShzbopZmuXERD2mEZfV4Y/9BdqpCGW4MbKzkdNc?= =?utf-8?q?Y5uGbjkS51h+qfI7p8NFvCytWPMbAXTKDGXecCZZc/jSSKCUYpeg1eD6JAgFsPWN7?= =?utf-8?q?EA6amCjH3ARZrncUwuU/1Z+MU0qY+EjrOKiFgrAXJ14JvBvKMrP9tZx8pba+Mp+l0?= =?utf-8?q?ncnZlIxP6I+mNtgLFbBzE1nzZ85VbWI8oT3PxitrtRRw5wdAfVIgMZ8B4AvrGbRbQ?= =?utf-8?q?ZCyJpfUvZc4MiUio7+1E43Nw3OQvhMca5ojo7DSxs+wPQD1a3TJ85WGRO0rT5nGK/?= =?utf-8?q?8jJ/yuYs9ysJf2OJTg8061NwDh9vsqH2FoQc8CTsBHtNFoXWecGg+LGCe1L1+xROK?= =?utf-8?q?yGqrBOqfR1fSD818eGNSGs+pqXvRiP5IaM69QfbX4kVrqufqZoC287cqVPS2FZgA2?= =?utf-8?q?4rJfW2U6yBhLAEYat8aQm6LOqXOon4fbts7IgvtLB7g21xSCKamvLQJa2aTPoiThv?= =?utf-8?q?mnrX8qiTiga1Moo1JY2wLBZ1hwCaCJmnsUSQAWXUS3rOuRbMMQ1sdm1wB5O3+NCSm?= =?utf-8?q?6ZQhqlhv7JZuV4aiGMoDJfrMRFUfIhN5+RykpckZslSTHudrRDOijR60ojw454BUX?= =?utf-8?q?VSwwcuecrllJn3GWpY1TCseGUWWOINtUtAGE2IDPwi2G4wTVUN7m4F2bHAC1R3F99?= =?utf-8?q?y6QKAZp2QSHOyrVdONI5oV3r/pp8KI4jSnql/pxMUbKEy7OSngZAFZJjYIrqDZxVu?= =?utf-8?q?zBgeK8p7x9pmkwPT3+luLEWePCQRvLQTk+XHQV4AI0YMlElLjFWfD9ZeCR3NKHOj0?= =?utf-8?q?tKkId5qeVVDmT+eNduuObsgeKAhPYycKqKG6vxTMmFwC6aJThzyAIchWsbEkwP0al?= =?utf-8?q?nL/gJvyd+oTFNSML+iVM5tYJfxoDO421TE0Zt1DkVdT2hIvzT4ixNLTVb8xT71/7N?= =?utf-8?q?IG17ldcDagZQLl7cCbJYYSfSV99JP4pOyOjoGHqx0G/lDPgRxbZa5cFzA+Fwkiolc?= =?utf-8?q?OHNL+mwkX3P0H2uDalsOZ/XZdlR6Zpge1nMImc0ThL2oP5Ce+0Hwt9Sci5hB0vfGD?= =?utf-8?q?lw0W3CXIVQf4WOdBvr78t4WErR99GkZHJTSFGt4FrIoz2M0A+LCfhnxZKGpVQuDHi?= =?utf-8?q?iYY25ToApc2lB1ig+7lGz023ZuIyLcc7cXtRLPNkn896ZnOrvh3+xCj1Gd7xuxqBP?= =?utf-8?q?skkqr0+jzK2U42iLiJoQe7qm/QcorEANYNB5El4isRRrLjG9AJ0JF5wCaxOZZsSDK?= =?utf-8?q?ZysbZMm+MV5UcTegZSGAz6nW5Y2VWzVEr79ryh4ioMdB+DuSv90B0ek=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?K/LzCz3jwNaAr3/6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Bz/yR/WRLv?= =?utf-8?q?2RzuhUev27/n6hf2e2rEUROeqnQgzYm5AnbQ8IUnMXkWU9FqJg/rREG+/4KD+Bnjs?= =?utf-8?q?J5cWHca4JQ0UwxKzYtcUEfv4QHUce7TXiPO/gHof+MCz3CngVGObWH2O1vOBn+dy1?= =?utf-8?q?S8POLrIhP0R4OxiWav3K4pwztVtrafHQTUJjaBowdZjf5PEDUmRbJa6g3VuFJm+3a?= =?utf-8?q?0EiKGW0n42JQo1avs1mrthQw41JytszdNrATz8pw+SibckkLMN0ya8q7Acjpu+P+q?= =?utf-8?q?fnp9g7ZaGcVOHA19pGguzNjZyiapcseNEMMBut/cNtRK7Y/AQeReVvUM6ULQg4sRi?= =?utf-8?q?MoNQcwfiR0c900LaM99wd1ZYF4Cr6zdO6N5Z8VXtiUlAoNraAJf/YosoIyeJoXfv0?= =?utf-8?q?3wBfFKbjzI4V8hSQXrP2zGaej4GSuuGdlx6Vs4Mz62h+oiCIQdLEzRXqhuYapQV0r?= =?utf-8?q?hD9Pib1ZV45NzkKNBePcuy/mqVKV9fGnFS+M0Oo5IevFgV9Y4WN1CBfhHH5gXDrPJ?= =?utf-8?q?CajYo0bXDUvfTzICR8rD5nGkhyCn/U2rr5fZC257h7TAmC7kXRvUHzLkuAl68gJfZ?= =?utf-8?q?8uGP4UP2O40OLVBqX2HRUBswNaj8pf4jZxlbPwkOaA1MoW3EVrjP6HgBdvD9D0L5M?= =?utf-8?q?RXz4AdUooOtS?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c48966b2-e334-4426-1b57-08dcde4aedc9 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:37.9137 (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: ad9LHK1B1MWOoBJ+XP+zIb5MJFNynF1duG3ewH93S2t8ZU2W00k6zDV3VmKgwYnYzMs0d5oq4Y9tnVEv31LX2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7768 ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 └────────────┘ 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 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 cpu_untranslate_addr to struct of_pci_range PCI: dwc: Using cpu_untranslate_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