From patchwork Tue Oct 8 19:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13826897 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 80334CEFC52 for ; Tue, 8 Oct 2024 19:57:21 +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: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=33uAPZwvH7h5pgdZmtVwE3KTxsUxxUoGDbfjmVnW3NE=; b=S+s3ir4aZcPEDLMhbV0YLbT05x 5quO2zTJzbzds+vF3Kknp0ljqJVdxeB1t2Z10z/UWaoSYCAzAwdSt2Cdmw2NIDDpIGYuyj0a2tmM5 cjaYx5lJc90E/OefujUSSa5fvnecjgsjUx1tQp3/A0L/qOQXQhTxKN2ti5GHA6WDC+9poJljX+LdZ oRVPVTZLdokpHIorwYTyAZZeDfcQPCbhRLQ88TyY2hbkzD/cagoNzALY7hfimiXwTrtxIV+1DvZk9 /Jx2otGIlTPDQhrWnbVbiHZzqqlkV8jp+VaqZ2NYWDmaafYKgMzqbamHvgc3SWw9nNhabd4erNrwW Jz6O4Rxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syGKV-00000006zye-14NB; Tue, 08 Oct 2024 19:57:11 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syGHv-00000006zQI-3mFQ for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2024 19:54:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MHFZK2cYIVChOGZd4oig+D50cGf64cvl6Ya9atQXEQ8fpSGala58NMc7FMG9EccVO4X8vZc6TItxYVyVKS/XoimhFXd26D7nGutGYuq5u3IThel1s8jZNUKzpXOQskfw65yI3Nne1s1rvOM23uW9eiizNMe/q3tPSzY0LjtDS7n7ceLbNVhgAtpPrWyDFpWpTIj85xfXIy4ei0wlbyTpvKmqhtWbySjNj4bxwN8/0vSyeX6UAlNSMjP75uYARFJA2orEH3KVaqZ2p9fCq5i2Gq7yq4b76ojP+zPRlkx13yxmwsW1OTGMSlulrVYuSwqdx73Tq//BP9RMsqoAPbUC9g== 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=33uAPZwvH7h5pgdZmtVwE3KTxsUxxUoGDbfjmVnW3NE=; b=JNN7f2gK5sHcx+OR7FaE980t7x0Wa78Z7GRCd7OhyOGC/RIHXdmvXYfLhQZV7mR4RSFxlBEIDmzCPftL90B1VQ+ZNTp170E1m9tU/Qxb/z9VeWDZ60MoRVJY7qX0ZXO7QcNCe5jKIgPyVIuTaJKxJN/k4vDpl8F/r9mvubuvHKNV//nHKQhSgxv8Xgr/FzBe7ZkT3W4bvQMLgrrg2i8P1x+Eu+dVdaPfPtBfnFmON7HlKAMvOZOOpcouEUKtChQpZYtu1UyztVgrr0AnARVIhZ7W1dG4jwf1k1uumNRfOibLyKZip7E0qtdHa7iGd7W420T2gR/eSU6oSCrmA9Crmw== 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=33uAPZwvH7h5pgdZmtVwE3KTxsUxxUoGDbfjmVnW3NE=; b=LwYHvNR5Et7Jy50c8YCBwgHZffigIH0+kwc77VVMkyi10o3m9JO+YL+TKxdgr6abnp4c9sozlhc20C/BQh4Gtj9Zze1TIxiyDKnNgOnwJ5jEOIFI7KIbAV27M0wJAiYekqrMSgF8lMH0ErDX2TU+4m4+3GTrbfLXkYkiH7abMWBXrSpfekHavRj6CxFEg6zCdY8XwyMfqYoC7bRZkVWgTAq+2ZwvaLoH9suuyHiuu+lvCJQ+phMgONuAgM8sj3bk7MdvdDzq8xVwcSrqmDiEdDNJ9sseJU/pEY0I1K61OaQ5rCaypgiQDlGseuhZvd1g44xJwRL/KELuHk7YGv4Trw== 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:29 +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:29 +0000 From: Frank Li Date: Tue, 08 Oct 2024 15:53:58 -0400 Subject: [PATCH v4 1/3] of: address: Add parent_bus_addr to struct of_pci_range Message-Id: <20241008-pci_fixup_addr-v4-1-25e5200657bc@nxp.com> References: <20241008-pci_fixup_addr-v4-0-25e5200657bc@nxp.com> In-Reply-To: <20241008-pci_fixup_addr-v4-0-25e5200657bc@nxp.com> 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=4582; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=6lzXCmq3a0nuDAFW89s/3o0ihCyVHX43B4MeidRoOSk=; b=l47AOoAmiJoxrDG5/o4piSsM3sOyKS5HTVtwlyfdahw1RGw5bzy1NEL6FKAIS6md/pN2jNFLU 6dKtMIieij+DiKgmDTsWQ6qfQA5WB0e/9ocaj3fKfu/md2yijG5h/RT 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) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|PA1PR04MB10577:EE_ X-MS-Office365-Filtering-Correlation-Id: afaceb21-3007-4e12-1eba-08dce7d304fa 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?Daz3n9rYVwee6oAtzWG86mcTRuxP6G0?= =?utf-8?q?QPU+qJuBjFM6qFEqBC7Wpuvnuqy8kH0n6+v4eJiJx45AIqIaUDkF8vkvNVDzJRyRI?= =?utf-8?q?aDiJuqyB2qaR7sopxFTQklrwId+an7ZwxxI+ujvoO6L7Ed4cPGb5RlDKhA3Rcpqto?= =?utf-8?q?rZm44NgEEnQpoi/V/MtewOx3JIcFp8ouV6IM5vKzffZ4vjbI2+Hx7tKUlkt3cM1G6?= =?utf-8?q?KrMXCRZdSvat01f8oF5Qn4MXvFU4ywPcSsVblcp4AlEkblchS33jxGaGW2SmpAFor?= =?utf-8?q?wPG64ZvVntALpJg0xHdjGzAvKgxX5oQCAEvQVrWFT1qwIEg3t/Xb40+VoUcLoknU8?= =?utf-8?q?FM9a8LLQk8508TcikuYYiV8tb3oJvWJGTW1zGkgVXEjcUcvfPjxzYd7JCJZWrONgX?= =?utf-8?q?4mMaKCj808L53ZBfaxiG6FObrFUQ6ZUFkJVh+nt9Icvcc3VFRbTR7VDvATQdr97sY?= =?utf-8?q?D6uypHhhpq2TqHUNgUleXZMN5Qqu0BJKKrUbSNDyDxu6Cl119zdHKXSHymeclAesk?= =?utf-8?q?1vo937cuveweD1nF2pGlYmn+GY33INGUJh3qRWrK1k8c8xPJJuG6ZW6Wq1cw9u0yN?= =?utf-8?q?0b9xLlp1P5+gah9dqyPH4ldtLB00hP8juynieYaIE9099/VbbM9Lwg1/v004hNIJ5?= =?utf-8?q?mbNAaJRsFTLRpx4x12txIUtpqsWgz1RK5lujgV9fBgTJ3XccsAdPW6J4MRdB8ekAb?= =?utf-8?q?gZrpdLXJAC0/0Vvnzl4x6S/fK5FhmbAY01LuK85FqgEFHtm4Wvf2xA/9tr2BEleuS?= =?utf-8?q?qdY7NjI1EdZJ+ffhnN/wIigt14ZnnvJ7HAnxkgDzIb1BpyuMokEgWursI6adYosFg?= =?utf-8?q?HAIsjrPzWa+RknVK0ALx/S70mCDZjaN01eXKhraItzXhmBpquRqff97cHLbmramaP?= =?utf-8?q?rNEZmdHd2NgfEwB0NS1143d0mg5zcX2n6dfgNGXSRTjMjRRypMTuxJFcK6JA5Icl+?= =?utf-8?q?ozhu3/2vPfj0HRYKzGE5cqBJPTJp5UdUqstUXeG4VAmCczbGb2aIKhJt/FcqkwoU9?= =?utf-8?q?Bp8/KdljQhPF9PB75+K/QM1kdil3amrvuA3OsvaQmWDdbQmCAexisBUxJ5qiOgNwx?= =?utf-8?q?kv30ZiTHCrEZTGSBW4GPftCjGokqQQrjuPJZM7ZsLfOnXrI1HVOza5FXsdp16j+i+?= =?utf-8?q?cTodN/PP0kcGgW6yIo5Z3vuf3kL7Io1Ae9UP29UuTdj8mK52S36sYdK/cYbP5oOSe?= =?utf-8?q?r2qN67eHLs5msakq5PSfmElFqEamWV3ElVxj9VO8po5F1lfx113IabCNl7xx9e3bZ?= =?utf-8?q?D+dzX6Gr7vLBBzM5ufzDTvgzKU5WPYGqqmQbLpUCeedGVqN8CpWRa0gg=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?iJPju0w2qHDYggT9f4FH/R94kkzX?= =?utf-8?q?gsC6X29/bZZIlEUtGdhQJxOfyEtf5PPZvEHTR8J8sIpm/i0vFyCqAuZ8hcFOYZq8L?= =?utf-8?q?EbFgaPfv88DxzBowp+BNVgMKoM9eO1Xb1awtzcIZTo6GNnGHs4GFU7vo6v7uZd1XU?= =?utf-8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SGTasESJ7x/sMQATOayqrbmvCktQrkiaYt2UNQoRt5QxM67S0ItBG6kZYWQFDiRU?= =?utf-8?q?t8I8lf6cj/hIJ4vgt8MAGuzMzUkXaDLhevlCZ2MSoeHKD6YN8/ihqwiD7NAt1dVVY?= =?utf-8?q?PpCA24lyYuNnlR0o6/mGASc2fV541c+lcxpoUzy4CbPbMlJy1FnjdpgumR+D3fcWR?= =?utf-8?q?sMKlYQa9kMn//yPSQoUvu1UjbusHmigwxn1pnjn1cFh+QzdZntHrOdXvFwIdHgvw2?= =?utf-8?q?F9wglZrT36XdxAzxUFwPJ7U4uNCol+7m6ww93hjIS0RvM3r9dfM5NJsppj1gxA81T?= =?utf-8?q?v96ujgU133vMvmIDjlFD7jIBx0hfVIcnkI9a4qojc0LfpGqcRSbvl+Za6dloPbLyY?= =?utf-8?q?VPEn/xI94wcV0wi/ea3yxaPFOOBqFFObYcKCON/wvIOC58aRhStOnI2mNJsAT5u5G?= =?utf-8?q?R2JT8wQ4vLlBdaSxgnEIOu/rXJeazRKM2jAcbFfCM3mUyh7OdG6bqrMyS/7RdkJh1?= =?utf-8?q?kEgIapT4HOzL?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: afaceb21-3007-4e12-1eba-08dce7d304fa 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:29.0133 (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: qVcQNdLmntIybsrBmYkwFNESf9oKZzm0DzcKQOveY8w/JOsppZzRO96nDmWxcwUUkYrRlCiPJH9lbQNx6xfTlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10577 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241008_125431_969662_38E5F1A2 X-CRM114-Status: GOOD ( 12.21 ) 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 Introduce field 'parent_bus_addr' in of_pci_range to retrieve untranslated CPU address information. Refer to the diagram below to understand that the bus fabric in some systems (like i.MX8QXP) does not use a 1:1 address map between input and output. Currently, many controller drivers use .cpu_addr_fixup() callback hardcodes that translation in the code, e.g., "cpu_addr & CDNS_PLAT_CPU_TO_BUS_ADDR" (drivers/pci/controller/cadence/pcie-cadence-plat.c), "cpu_addr + BUS_IATU_OFFSET"(drivers/pci/controller/dwc/pcie-intel-gw.c), etc, even though those translations *should* be described via DT. The .cpu_addr_fixup() can be eliminated if DT correct reflect hardware behavior and driver use 'parent_bus_addr' in of_pci_range. ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ 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 └────────────┘ 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>; ... }; }; 'parent_bus_addr' in of_pci_range can indicate above diagram internal address (IA) address information. Reviewed-by: Rob Herring (Arm) Signed-off-by: Frank Li --- Change from v3 to v4 - improve commit message by driver source code path. Change from v2 to v3 - cpu_untranslate_addr -> parent_bus_addr - Add Rob's review tag I changed commit message base on Bjorn, if you have concern about review added tag, let me know. Change from v1 to v2 - add parent_bus_addr in of_pci_range, instead adding new API. --- drivers/of/address.c | 2 ++ include/linux/of_address.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 286f0c161e332..1a0229ee4e0b2 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -811,6 +811,8 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, else range->cpu_addr = of_translate_address(parser->node, parser->range + na); + + range->parent_bus_addr = of_read_number(parser->range + na, parser->pna); range->size = of_read_number(parser->range + parser->pna + na, ns); parser->range += np; diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 26a19daf0d092..13dd79186d02c 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -26,6 +26,7 @@ struct of_pci_range { u64 bus_addr; }; u64 cpu_addr; + u64 parent_bus_addr; u64 size; u32 flags; };