From patchwork Tue Sep 24 21:54:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13811259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DAA05CF9C69 for ; Tue, 24 Sep 2024 21:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: Content-Transfer-Encoding:Content-Type:Message-Id:Date:Subject:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=qF5QZhBMKTw6CoP7tWb4b9lE0t7q/1o9hBbcC8aUdj8=; b=HzAPxrl6ftoLvtHGDzvvJjgnYG dTR7JKruOFADMuX/uFs/1zhNiPLJytCF4dnWL31zGMqSIW5yj2Q93ShLXJwd98VMZvwxSs9lkCBMa qsIn5fLSaMsfkj5sOtq/gjQQ2ouZ37TpmUhgM6lFt88Arj1aeup+5zVqaODRkmMHpbxW0d0rCAdCL cn3xH2VmtYURYc5b28uWbDXre+S3iTnqenZGavgo8TXI5cfO/I1gQBdJJFevzDoC1CRmeu25PtQ// lN5nnv+7VmMyHKs4Gf4qalNrRjRNSpN49yn09hw8sdjzR0wv49KB3kQyBHxyDGTBPwMQDJf9qrmON FITjY+ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stDVv-00000003Nm3-1mO7; Tue, 24 Sep 2024 21:56:07 +0000 Received: from mail-northeuropeazlp170120003.outbound.protection.outlook.com ([2a01:111:f403:c200::3] helo=DU2PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stDUk-00000003NUQ-1reg for linux-arm-kernel@lists.infradead.org; Tue, 24 Sep 2024 21:54:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CmT2nyR2yEQGE5l/FT02tI6zocfEuYy/ZLxIsC34eU12Eh90M2tBftXxExy4Z3ApxyZA2E28mJvfAGD4m9C/eHOhH29NLFj28kUU3OMkcznOSGPEdJSqVPHg5QwWyQCrDwd//ORFmPQp4s/BKQQLUc+KiKE4RJR4w1l7y5GvVZ/cZA/XrGlk6uu/TMG+uIaDwOsKpr/tlUmOR7c4nE1A0eIUnrOTznUzygwDmUiq8XT5g1587Z4Y+ZqjItCZLM9DyCbFtaxFIH5yTg9+xY5ZruIhYz8Dz7zwXK75JTet92kGIGn+a8oDJmkOE/oxBaWppEI/dVE4uNQnpWpudbNFlw== 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=qF5QZhBMKTw6CoP7tWb4b9lE0t7q/1o9hBbcC8aUdj8=; b=YSYUXpdbn4MPjHZPqMlU1svjXXLGgS6QfhKcopbVCUI4h607LLizMSHqca8nUTFFirUjPAh1JtBUyMcSfAsdrEPYTAaCy0TZi0BC7uf+8MX2qmBqV6ULfILT+0f8PbKI9XcUsDGIsjQNrkeUbBbqepcUnf6AN1EfijqC0qaVOGupeKb8oZemN7BMssQ7pfy7shdG6hOxv5CbXthwH4egkBjwU00xFZgWokjUNrZUnj7PjB2xJT1SDJCAKiy1jZoNipDxtD7xfE8+taQfI4fUBTVfSOe6zu/NSolfuKE6SaUFvJsyUZiep4C2Id8Ji+ZXw0mSKqp5turJWDKGBVzcuw== 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=qF5QZhBMKTw6CoP7tWb4b9lE0t7q/1o9hBbcC8aUdj8=; b=FGYQGxcQFGJJ9qRMsGT87K9Zgpw2dcKjCVtKkAcfczYjGf9S70zo+dwgFm8il9tbjDFEMoZQOI1kje4WVH5UaWGoM9fypI+tTm4QkP4vPHSp24ER6VfwlUyDLxGGRABNyj+ZIoedEQLfcDlLyPfT6gJU+emOZjLfcAVRR224faJuu+AxYLIDicgiJh/CfqNkDIg5Qr20xdlYX6cyVQ3mvFzQkGJF65SVImN7z974RSXWXJtnDgl35nNJidRj+td0DiBt/SUl5SDSutXlW2zMsK16i64kCoRV+sxV5nRHI3udkx4Dn9jsfoBkMOIys5KqXalkI7EzSmzh8zW9CofBaA== 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 AM8PR04MB7953.eurprd04.prod.outlook.com (2603:10a6:20b:246::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Tue, 24 Sep 2024 21:54: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.7982.022; Tue, 24 Sep 2024 21:54:39 +0000 From: Frank Li Subject: [PATCH 0/3] PCI: dwc: opitimaze RC host pci_fixup_addr() Date: Tue, 24 Sep 2024 17:54:18 -0400 Message-Id: <20240924-pci_fixup_addr-v1-0-57d14a91ec4f@nxp.com> X-B4-Tracking: v=1; b=H4sIAAs182YC/x2MQQqAIBAAvxJ7TjCzsL4SIZpr7cVEKQLp70nHY ZgpkDERZpibAglvynSGCl3bwHaYsCMjVxkEF5JPQrK4kfb0XFEb5xIzahiVn6y1vYQaxYTV/sN lfd8PuypEd2AAAAA= 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=1727214875; l=4155; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=iYHcmJ/RVnmcj4U/N5THcYTiiqChA+jWhJrPcB5jOio=; b=X9Xfuwdk1ak0H/iIzvPIfh07bi10tVWNePFnlRix2i5+sgJDfXQTYQUPxiiHsI8BQ4np30Wca AxUTY4kLpfnAcC/LFIFlhq7R00cATY9WQ79ej3Tqw0t6dBRHqG/pJp+ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR20CA0023.namprd20.prod.outlook.com (2603:10b6:a03:1f4::36) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM8PR04MB7953:EE_ X-MS-Office365-Filtering-Correlation-Id: 1adc6612-3d06-4f6b-860f-08dcdce37d25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?iNNM0b/qxqzFu+lkpo4/K5JO1mURdAK?= =?utf-8?q?TbVNItVsrNW8yuBq04Wli3CAaaQy11Q9k9xYDmfMIWR5SZnhDcLGt1KqLCpazGErN?= =?utf-8?q?bS1j8DBlK0OLBRXo7RqtDv4PDf66EECpTUUyK0txNnIpu6MQIEaVHcKaNqEMifE+E?= =?utf-8?q?GxV85Etl2M8jlWsPABvnNmNLmLquIRph8ySlAtxnOvF0/Cd8kjwuCLU7myO+XMfqH?= =?utf-8?q?szy/SBu28Bl/1BHMwBPG7ecMrIEPgIgJBJNXdaOrKP/tVnS61KaPEJTaKPsXyFnYX?= =?utf-8?q?NdVkMadhkKySUkFv9RwNfJFsydZecNGhCz84be5VzR/3Be4OGxxiIaKiBgnyCVHWN?= =?utf-8?q?Ss3+8UMJWtHQ4OA8XlbZ3dZd3Jdinbattm8Z5LhkNkCqYKp5Qpgalol4HFzD551qp?= =?utf-8?q?i+mk6Z6lgvrcYnDyNyeHTXnfK3f8+zkiioqFg3uZvHnOhbL8T8LBT+cuo20HPTHFG?= =?utf-8?q?iws3Yv6eTm73UPaHx71u5LkGJi6ZTAp5xnlMFvtf0su1wmsx6mfzpqwSfpzH9to6y?= =?utf-8?q?rtNzjvM3NKjHXmE5G5sIgwa0pTF0WlmzCHaAHFDGF9KqUlmefVe12KXnSNsCHHOPF?= =?utf-8?q?fG8ec0dR5waNg2Qfxvk3Qd8SYoyjUZFqvkJxuuE1lZwjeTQ0IVwX4eedjxmpMGp7V?= =?utf-8?q?E8HkjIjZICl1m3dpO0dG4DSI7bciQmmDliWRvxWsCLJvVvFYFoEqTNSWoy8AcLEFW?= =?utf-8?q?wU88aLYA2mj2j1MQW+TAHqfi+s6qxHHDmEbPusVoFlowVoiIzt9+WjHPzl1jZ4TVi?= =?utf-8?q?PUR8xOyLy46JvfEHJ8nlVQK8kWq0CGHXFUbwCNlPFtJnFDsFZdAc8mxcaNTXBEma5?= =?utf-8?q?SB9lEUNTp+smNanc8opZqan8FSDx5m4m1dxpXGFjah9M3IEes/W/SN+XRE6Zkot3l?= =?utf-8?q?6W1NBlU6p8te91isTXIiS+VbaaYxT6ycWgRhBS822JP6Unz+mJRDByhjvW/DJc9EY?= =?utf-8?q?HG4W4TFRD1P2YHna5G+4QjpwE/YfSVPBRkySivwOru6CljhZk6r0HgFLUDmE+Nc4B?= =?utf-8?q?Uv2qS3bIhKooHN1OKaaoPiCqA2SDQXdSjEY1V9Zu5r8oDPUSClkgvCy7L4K+IY/ew?= =?utf-8?q?HEBWpiggvsKNxXhIjCrtdb2TYTVCmFTU3febI4oLSJUUz2ZOjk3502C9jKlMhiHN9?= =?utf-8?q?Wwo+8t4tXLm6sJOjwgB+81zYvzWbL4guE8tTJfkrdEmAxZ9YUSfJdNWOrLwxp2L6j?= =?utf-8?q?U72v8VLH1QHqvHxM12KPq60Xf6GEHh7tNJQVwzxPmw/5CjpaM8MJM0+GCOPU1Py7s?= =?utf-8?q?ivPZgjKtzZVXb6oKTIhhZMpBXKFMQ5RmWZDoSfKRkDBhUemb2NEhWKmBkQBWOiY6f?= =?utf-8?q?KeSsCGH0knpg?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dqMZ/PQw4pqlHLLv+7UwclTYfPuJ?= =?utf-8?q?xsbaFBe73R4oK8wvuWBUtbQ8mK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ZJH5KryOApzeaJYOkqxMOoEnA9Fohl3iwnodE?= =?utf-8?q?9rzHeDTyiTRe6KW0/usSfX7utLy4Wv+vZFUvTzbuV0T4UkupNAYMDku1pu3H2SmJg?= =?utf-8?q?PGUUxqWctCvlj8rRFX+yq8cV29lz9nzWgBwLEqQlch59iQPA6QXPflVI8yV022/3/?= =?utf-8?q?ZVoL003bJTpQSUGtKff1Cpl5b46B4bAWIjDd7H/g6VvILYX3Y+5JskE6WVsEnky7L?= =?utf-8?q?sYY8fwgSHWQy+2Q8Kbw6VfLQg2/sc7b54G8De5dfH+hjJf/PY5j8QRvadRQJ/ARVa?= =?utf-8?q?iqW29rPhuE8S0+1EdHIFwsQ5TGws2DQvs3vd+HrH+CdKHuzlZPOCUphOa5c0cGH6+?= =?utf-8?q?RcAs+BrQEStnvv+bfFPC9SU34gFPRI+39CxvHeXJJQc74nnwWNnsyAQfWd42l3aRL?= =?utf-8?q?NOwhitf5NLciNuhWafoKiXLV4cDZZJWlONDbOmLtxTReQ3/HqZV6LE6diirMMqq1Y?= =?utf-8?q?r1B666IBALWezbhkfFgWMUhyAP9JjJQW0AUnk519YJWzc9WDpesBwbmlJEXjX8JIU?= =?utf-8?q?vBLaMfZ6QE6LydgAK3rAwHQRPQmn0tx4OIFsIFss8CVUqw+TxjfwlrpA=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1adc6612-3d06-4f6b-860f-08dcdce37d25 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2024 21:54:39.6108 (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: JX3U3/Mm5r5RGMiw/2rcwgV1mSTLn5GHhtUekswOTvNEd03fMmFwfe3S6AVZhx1/fHDF/P4zEMLie8EEtmTUMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7953 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240924_145454_672547_54C908CE X-CRM114-Status: UNSURE ( 9.39 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 --- Frank Li (3): of: address: Add helper function to get untranslated 'ranges' information PCI: dwc: Using for_each_of_range_untranslate to elminate cpu_addr_fixup() PCI: imx6: Remove cpu_addr_fixup() drivers/of/address.c | 33 ++++++++++++++++------- drivers/pci/controller/dwc/pci-imx6.c | 21 +-------------- drivers/pci/controller/dwc/pcie-designware-host.c | 33 +++++++++++++++++++++++ include/linux/of_address.h | 9 ++++++- 4 files changed, 65 insertions(+), 31 deletions(-) --- base-commit: 69940764dc1c429010d37cded159fadf1347d318 change-id: 20240924-pci_fixup_addr-a8568f9bbb34 Best regards, --- Frank Li