From patchwork Tue Oct 15 19:17: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: 13837022 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 3D5BAD1F9C2 for ; Tue, 15 Oct 2024 19:35:59 +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=fL3UKGvdWP+KFjAwQhRXw53UwJq+kOcQRY6+VijyXiM=; b=HfeczALAwytmjsIriq11GdSZtR AYg9xVWkRqexFM0Y65munjLFt4d16IuX66ESDmL9/QkVaoMpfJNXmgBBmOqYnUbehIx6cTG9x2Q0f bWuZI8DUMmIJMIc1/pFN2T3fR+RW+uFoYGuV6OrbvWa+t1LY2iM89XRHRYJMXqeaDkZRUYpN2tQiw Wk4hrFtisNYLmqJSYlcBZnMF+EP7XDSJvQcz5yqwqwQeriWrCCVEaZ0TWBPQTNpO8aNhbtNcX3K7A D3W/OTnDdu/X3rnlDeS5Z++kL5O94INVU6o74O0uPp0iAqC+IHqKkTGJ0CSJw+JwBXPs9rc4MAVNH vC9CzHLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0nKe-00000009PQc-1rT6; Tue, 15 Oct 2024 19:35:48 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0n3Q-00000009Meh-3ili for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Oct 2024 19:18:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=fL3UKGvdWP+KFjAwQhRXw53UwJq+kOcQRY6+VijyXiM=; b=lEgFpvAtxJCWDzLNscX9j6KHY1 18m+enbXcxXlP6s5wt/Y17wWfsX8BephgFL5lQK9F9W+tbOujIuY7iHnVFNvyeBK5ZzY3d0M8Sdg3 P/emJ8+sqaVS2ZaZKeY78rGl/Zxn5XqV0oyYu0U+2t66sb/5GsIH+j1Gb7paZvy8j0Qz6MbAL0dk1 eFKBBiU2mkEOcI0djAbUYtiG4DRUrQ0vRCjiQ8fY2yALZaLwsn7rKaNvGz3SqyRPninzD1Mh/l1qj +HAlQe4/OL+8XcWxcrPzcJtkSCCux0iivSKeMBMRWAbo1UljApsik84djs6ihnR/0KIO5wBsQQXKK +TBWQtNw==; Received: from mail-dbaeur03on2060b.outbound.protection.outlook.com ([2a01:111:f403:260d::60b] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0n3N-00000006dkw-0wy5 for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2024 19:17:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vM8R+d/LfoZGuLYyngUyDupJ3aO/O4wV8vmVEtu83yOvevgg+P9Ltp1ds3e4/a3Q/bE3+cmtg8DzbvWplwsJUMLCEUAx5puhLuxrR9hRV6zWW4GeErW6Qa1xiWZiRaepLAMCdeew2tC9wqvnwzg2F824Bu9k7UDr63UgEXVKW0BjVZhDD/UERtYkq+FnvxXqOJFV0QGcCOa+nx6IXPuaUdgqMoJTcN/wxyt9xNOGG4EEvkacth1eNnJlbO0vX/+b4wLi6/6K+Lsv7IKLgVwh/XTvMOch8mmNHNpvwuJVTz3eNy5jJYtn+WVD2xmuN2ztqeP64Rf+oOACZT8fMYxd3g== 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=fL3UKGvdWP+KFjAwQhRXw53UwJq+kOcQRY6+VijyXiM=; b=k4VEdOcQNdZwvInN5iIFh469wpD5CL7Xbq/yvZdtBHmD59ebkKmsEjb7/1tTyDDt7Mzu02Soi0PNvVdLBMMb1Sel0Q2aFapEvcN6yfj6pGwdTkT9+6HJVQt13cmAxCd10N4lVtKFF+LRWlPk1fu7XCNGW1gclvlIV2ypcyLe7oiduW7a1BwUbTvKwK2rx/kPPEGh9xyeApQQkQ3oB6Hjx9M3MvyLPurWD6v/99dvAULohSvuEvSoAJOnAziGfoS+HpphZidu3mw9l7U8EdND2fC2MLsirsj9Mveh+3b/OUsydYlxMf48Py3UuOyxeMTXkCRjgTQFqu97HZQAFja4sA== 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=fL3UKGvdWP+KFjAwQhRXw53UwJq+kOcQRY6+VijyXiM=; b=kD6QIQGE6DhlVjt7VzLe8SYXFu1/rbs/BIOd1a7ryeKgMklakfEt5Vv6YQse0UlHOjO+dmLXDfF+T2IwK+7zykFhN/p1r+XISr7/dgYssNQjl6QQUJKMcixplAStf7Blr0SNN0+YdNb5xNKsp2oLyPG5ZLnbU7rQVJlyZdIbQiyEgBpTuHbcwAp4hBYwgiMgY850r4GiZJLUAJsBYsCBGdiiWDlXtZl3Fp2q8plY/3cCmglSoPNv2ABCy2mrkfw2cuSbjeUDJqeAZ08+a4OEtMX7eE0RqVbkbRi4745SyRbezhbMP3M/zJgj1lJlalu5vxF18LOOJmHwT6Qmkp0VIw== 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 VI2PR04MB11002.eurprd04.prod.outlook.com (2603:10a6:800:280::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 19:17:49 +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.8069.016; Tue, 15 Oct 2024 19:17:49 +0000 From: Frank Li Date: Tue, 15 Oct 2024 15:17:18 -0400 Subject: [PATCH v5 2/3] PCI: dwc: Using parent_bus_addr in of_range to eliminate cpu_addr_fixup() Message-Id: <20241015-pci_fixup_addr-v5-2-ced556c85270@nxp.com> References: <20241015-pci_fixup_addr-v5-0-ced556c85270@nxp.com> In-Reply-To: <20241015-pci_fixup_addr-v5-0-ced556c85270@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=1729019855; l=6561; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mxnXQtsQ9r/Ji6o5AXb2owHgaiMSnmyNmFBnlNFd3kM=; b=hCXFkStAglAgicEerZg0T9vjbjZOfT2D6EApXOSIqlVLvUcP9FLTbnekzA8GqCTVnl6JiHKeh 93wW59KQVo5AvoqIVG0mHxDp4xZOBJdwVOFC0RUTEyiZBKNbGLA9Q9V X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0117.namprd05.prod.outlook.com (2603:10b6:a03:334::32) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI2PR04MB11002:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a7990a5-dbca-4741-e6b6-08dced4e0eef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|7416014|376014|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?EoOZaUTMFidn1kfxM2BEfwLkBa+aZiO?= =?utf-8?q?wYIzzvGd8jpdfyUdOZBT47EV9wYdt3uyU4zZzrZtAn3ChCRxbzRIVujcStKcyY7hr?= =?utf-8?q?fEWlHnsDOpKTOAu45FIpUW7UTnbANNJlD2qlKQGreqkKUwNHA74mCBDy5B2uuQTS8?= =?utf-8?q?CTZYVSPV3l5frvJbDR7umcL5b0KJy7X2K5QcNzUOOBxylg3mN8Z/XguroYV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= =?utf-8?q?jA0ag2KucCDe+2UrPivYG43cYDInTM+SHTyMgHuWU7LrJlzqA0jXZbM2BmWumd1/m?= =?utf-8?q?PAiMYUz+XcrA7v3qVWB9N0/zCPxTzMwfhdwQDx4DRafIayURYVZ9IPAcPgq4MqQBE?= =?utf-8?q?qeehrIDbQuF/eqDrEMlg554II12hsWPd1YezjY7VtNgoYTXqqUMep3d+MpjevpVMU?= =?utf-8?q?qe5eF4s9cowGocPh97xVs0AQAVyGJ4PPMVUncf/c3+i4bDSlcY0uuWEA=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)(1800799024)(52116014)(366016)(7416014)(376014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4nlx2r2CBlgeDC4EHGw6DoepzjgE?= =?utf-8?q?7e5p6+jdSMhozX+rni8/3/U/44uRuJZeFKPoyoJHP0pX4TdSE7shLP0HUIRGkFyI+?= =?utf-8?q?1+lrbe/OxJWVsK6uXO5iygawBjkfW+upPi6lo2FsjGHbPRHSy5iwDY0HRATbhkAat?= =?utf-8?q?TaO1F35Gj8cTti/yur8Nwm9B98TEzgKAZ3VGtbH2r8PDkLNjw4Yw3ZdU/8hjKGQrc?= =?utf-8?q?Mq6o+Acep264Zq8erv3c1hkBGh6TPUvaRqBaPm9hGH/SmMDUfy1tkQ7uf65bSMZAj?= =?utf-8?q?axNM55EGuBS/Qt/VorOcE/Fp1CsOCbuHoW0n7DLZwT1rxZGMY63mpX3IpIh1dog4J?= =?utf-8?q?tBiO9M7bp+E5wWGomROYsrNe65JVBhDIzwyRUUzBu84lN5e4OkbuDSQmqxKMqWAtl?= =?utf-8?q?AwgkLfsoOYTYWQCzXcxibAw5co8fbCCigLH/iY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M68gpqHEJp3pIJe73Ab?= =?utf-8?q?/j3ae82TsTYeFDmXkkSIEttNEPGg+B5G6BdwzKj7S9Y7Ho4EkT+FwPsWDaQKFyrsY?= =?utf-8?q?YEJvgPnoo2ScTAW46ZcePXQKgVAMfA9FetMLZm3RfE73r/fJrvC6Dns4L1j+ALiPc?= =?utf-8?q?UDodmEAtxpGvPvQgd63oE4twOig7cwx0WDR+lIkZlXNjoxvoOqy1Stbs=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a7990a5-dbca-4741-e6b6-08dced4e0eef X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 19:17:49.4657 (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: NduNIf2tDf0Rls1GonXUCjvlSzQyN/oWuMJ+6eRhxvTkhsk/CS0PKj+hTH9oJeR4M0R/AOuoqP1/LgkuV5WpWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11002 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241015_201757_468726_22575C60 X-CRM114-Status: GOOD ( 14.70 ) 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 parent_bus_addr in struct of_range can indicate address information just ahead of PCIe controller. Most system's bus fabric use 1:1 map between input and output address. but some hardware like i.MX8QXP doesn't use 1:1 map. See below diagram: ┌─────────┐ ┌────────────┐ ┌─────┐ │ │ IA: 0x8ff8_0000 │ │ │ CPU ├───►│ ┌────►├─────────────────┐ │ PCI │ └─────┘ │ │ │ IA: 0x8ff0_0000 │ │ │ CPU Addr │ │ ┌─►├─────────────┐ │ │ Controller │ 0x7ff8_0000─┼───┘ │ │ │ │ │ │ │ │ │ │ │ │ │ PCI Addr 0x7ff0_0000─┼──────┘ │ │ └──► IOSpace ─┼────────────► │ │ │ │ │ 0 0x7000_0000─┼────────►├─────────┐ │ │ │ └─────────┘ │ └──────► CfgSpace ─┼────────────► BUS Fabric │ │ │ 0 │ │ │ └──────────► MemSpace ─┼────────────► IA: 0x8000_0000 │ │ 0x8000_0000 └────────────┘ bus@5f000000 { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges = <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>; ... }; }; Term internal address (IA) here means the address just before PCIe controller. After ATU use this IA instead CPU address, cpu_addr_fixup() can be removed. Signed-off-by: Frank Li --- Change from v4 to v5 - remove confused 0x5f00_0000 range in sample dts. - reorder address at above diagram. Change from v3 to v4 - none Change from v2 to v3 - %s/cpu_untranslate_addr/parent_bus_addr/g - update diagram. - improve commit message. Change from v1 to v2 - update because patch1 change get untranslate address method. - add using_dtbus_info in case break back compatibility for exited platform. --- drivers/pci/controller/dwc/pcie-designware-host.c | 42 +++++++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 8 +++++ 2 files changed, 50 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 3e41865c72904..823ff42c2e2c9 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -418,6 +418,34 @@ static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp) } } +static int dw_pcie_get_untranslate_addr(struct dw_pcie *pci, resource_size_t pci_addr, + resource_size_t *i_addr) +{ + struct device *dev = pci->dev; + struct device_node *np = dev->of_node; + struct of_range_parser parser; + struct of_range range; + int ret; + + if (!pci->using_dtbus_info) { + *i_addr = pci_addr; + return 0; + } + + ret = of_range_parser_init(&parser, np); + if (ret) + return ret; + + for_each_of_pci_range(&parser, &range) { + if (pci_addr == range.bus_addr) { + *i_addr = range.parent_bus_addr; + break; + } + } + + return 0; +} + int dw_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -427,6 +455,7 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) struct resource_entry *win; struct pci_host_bridge *bridge; struct resource *res; + int index; int ret; raw_spin_lock_init(&pp->lock); @@ -440,6 +469,13 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) pp->cfg0_size = resource_size(res); pp->cfg0_base = res->start; + if (pci->using_dtbus_info) { + index = of_property_match_string(np, "reg-names", "config"); + if (index < 0) + return -EINVAL; + of_property_read_reg(np, index, &pp->cfg0_base, NULL); + } + pp->va_cfg0_base = devm_pci_remap_cfg_resource(dev, res); if (IS_ERR(pp->va_cfg0_base)) return PTR_ERR(pp->va_cfg0_base); @@ -462,6 +498,9 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) pp->io_base = pci_pio_to_address(win->res->start); } + if (dw_pcie_get_untranslate_addr(pci, pp->io_bus_addr, &pp->io_base)) + return -ENODEV; + /* Set default bus ops */ bridge->ops = &dw_pcie_ops; bridge->child_ops = &dw_child_pcie_ops; @@ -733,6 +772,9 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) atu.cpu_addr = entry->res->start; atu.pci_addr = entry->res->start - entry->offset; + if (dw_pcie_get_untranslate_addr(pci, atu.pci_addr, &atu.cpu_addr)) + return -EINVAL; + /* Adjust iATU size if MSG TLP region was allocated before */ if (pp->msg_res && pp->msg_res->parent == entry->res) atu.size = resource_size(entry->res) - diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 347ab74ac35aa..f8067393ad35a 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -463,6 +463,14 @@ struct dw_pcie { struct reset_control_bulk_data core_rsts[DW_PCIE_NUM_CORE_RSTS]; struct gpio_desc *pe_rst; bool suspended; + /* + * Use device tree 'ranges' property of bus node instead using + * cpu_addr_fixup(). Some old platform dts 'ranges' in bus node may not + * reflect real hardware's behavior. In case break these platform back + * compatibility, add below flags. Set it true if dts already correct + * indicate bus fabric address convert. + */ + bool using_dtbus_info; }; #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)