From patchwork Mon Oct 21 20:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13844613 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 8CFD5D1712F for ; Mon, 21 Oct 2024 20:11:12 +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=3Bk7q8jaB5ypFH4kg7DtQLBpo4spagjA9PptU/sPGm0=; b=RuMCJ2UdbW+M9XIWGVz7GQGMgb ypjjMOXFyCjMenXFLKVjzyjzTA9RogugjH0W4ogUYYg+LVdDOv+L1vfCZVAcipO7ux+KaHaE/nG6h VS3yXuNb9dzuCd+NQMbYCBp6qaKgB0FCWdx0iswYAT3YmzdENLOZmfSwke5H6uDpSw+K8sWCMeBWS +sJZQlc2PAUfGi7P54Qi96ExXeR3rHV8CZf4bwXcm+orvVjQlVw9hpFZ7USXPnMd/FoXlf8z+3/7m aZeSsvuBFs7zo6U+xIgARS2dZyictPeCd55LhdOW0EDAkHg/kQDYjzhUt4m/0pmhyzZ1xwvz5Grtu w9QQh0Ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2yk1-00000008Y42-1zFH; Mon, 21 Oct 2024 20:11:01 +0000 Received: from mail-dbaeur03on2060b.outbound.protection.outlook.com ([2a01:111:f403:260d::60b] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2yh2-00000008XSY-24MM for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 20:07:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KfWAs6+M+oErTg3vqx92HCqpnf2hhuk0qF13zMI7UEdQV/e8t9zK5K46jLOVgu/GPM/fxu9B1tRFOThq2Sww/2xsbnXUErPeK71ksV2xy7SOtw+7rcHhb1Butlj1hEITIojy1b/d0sAXcaNZZo3tPXHG3As0LtGjp5hN74PUq4fQI200wRgoHu2BzfL1u73/HQeS6+XopbPxScaL7FGSiavZ899eMls+Eio3zM7dsSdTmF5HwmIDnf59JMmX/e6C+vtbwVA7rWZX4JcV5GcVSzxp0893oHalnepM015gZfDJJNO8A5Qc2EvJR6O78IT1lOrMgeXAH/tpKIWwbAw1YA== 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=3Bk7q8jaB5ypFH4kg7DtQLBpo4spagjA9PptU/sPGm0=; b=TvEfiZwoLCMPaAE8WpUc2VZK2NHiM7eOW+p2SZf1kTbW/hVN6zJQVPW4/KtEJjU7iu1S6B2QPQhsudY/NYcQ98WKBqo2xuwjQKeXPQtFDAbcLpq6PnOdmuqGzDGGDyrJtrahZrrtWazBE3NVuzynFSFHSdo9cTmLTcZ6efOsI7Mtts55KhM9WYBKCt0vw5K0WPlqJAdJJLFdtzbDGXfDgINQU/CJKSPTitDyWK11iJx/hup/sNSa4TRjM37oZAHIWkCdbso5YDEZjFoRZQ9TS4Z6ckhdpO6D2lFqp/RS5A7g7VzLqtQs6pxQBs0MOsV3NofkqsUt3IkMEv0c6fQcow== 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=3Bk7q8jaB5ypFH4kg7DtQLBpo4spagjA9PptU/sPGm0=; b=M8IB0YX8v1nQuoBFCe1mAPduB5iEXeRIq60fESldaO9hLUmyBKIFcqHyY6FNtMUHzX7rCh+J5R3ZQJoyyH62p5RUlAe16Jru1noGJrizpPNGHFlZfYRi151iKnf5dz8QXasmNJUsx6hNF4YsNhRtOsr5PpyetMDas+0QC3zh0G4qyDwzMXV6cSnNWZzMRR+qUEmB+JvL/vmQvYqEO5SGUBfA4/ccmVS1tOvbS3Ji3vIRkVTAT1TpCk+qPs3N60U/3CfLNUSuwoH5OGHelmv30u8BVjpQB2EasGSaihh2r+1sGkkQu95RjbDaKuVSXbbNl8QhECBa1USX8Any1BuQtg== 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 AM0PR04MB6882.eurprd04.prod.outlook.com (2603:10a6:208:184::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 20:07:52 +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.024; Mon, 21 Oct 2024 20:07:52 +0000 From: Frank Li Date: Mon, 21 Oct 2024 16:07:36 -0400 Subject: [PATCH v3 1/4] PCI: dwc: ep: Add bus_addr_base for outbound window Message-Id: <20241021-pcie_ep_range-v3-1-b13526eb0089@nxp.com> References: <20241021-pcie_ep_range-v3-0-b13526eb0089@nxp.com> In-Reply-To: <20241021-pcie_ep_range-v3-0-b13526eb0089@nxp.com> To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley , Abraham I , Saravana Kannan , Jingoo Han , Gustavo Pimentel , Jesper Nilsson , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, =?utf-8?q?Krzys?= =?utf-8?q?ztof_Wilczy=C5=84ski?= , Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729541264; l=6071; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=z/qjOkp5hDUbKkPREBnGFcyAmTYIDRDWM3qKhQ4IVc8=; b=NB9QyP5FD+su171LzohM4TyXh/YDwW3sB1H/1vi82nQ6RRL5v8bUUFioIfVQ1pFn4ddhsOtSz uWCtPSYEejgDd/4ZJ7AQc0V9raeQ+4gaBmkL5dSA5Xd1GmrWNQJLxdy X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SA9PR13CA0071.namprd13.prod.outlook.com (2603:10b6:806:23::16) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM0PR04MB6882:EE_ X-MS-Office365-Filtering-Correlation-Id: b262bce4-4927-4c3d-2e68-08dcf20c0b19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|52116014|376014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BYHQx90oJFhzNvGjvvU7G0mMX3YDFhr?= =?utf-8?q?BjteVFkcLbjXOwSbM25wVbGamCMHlkzD6fZZw83nRdY/LGDwURWzJCMYfYvxarvBm?= =?utf-8?q?pWdi/bbAwWOhC6F9W506TAW4ZzBTf8gIjPRkbiFeEXtJaCnYf2HkVcEzt0M6FniDn?= =?utf-8?q?JMYRr5c6oM3MkQGmCzkLuhtOGFB2V7eFG7thR5LNROVLBsZycxlfAhHVx3tugJWD5?= =?utf-8?q?nVDHgA79xOrcL3gKxn29i6PRZgFRl5XC+u8Dj1nXnEviUvKXv+VKpStvuA2PG3khA?= =?utf-8?q?D8z3LJHwYU/ZClQpw3/NmC5AGGIqxLq+cpCKfaTtk64T7alTRpWzyAyVNtC9bV0Rr?= =?utf-8?q?tj/lC92nHaCrur2/QyAIq3Cdt/rTBCf0Xvd/scjIyWW8F4uWyN8r2N3kfDRvtdHLg?= =?utf-8?q?vIS8NOlIyOYELJBfup+TtkuZtp5XKQdSK0kYeuYioxHgXcQjIBgxTX/aodBQDKK5J?= =?utf-8?q?0aL0hptt/59gl/IcveR/1iOpNq1w+PzuWWiU/ewwuoadVKhRngeoQiekWOfQuR+W2?= =?utf-8?q?7YbG2VZ5YnMqIVmoGzd/X+75pEQce4tagvd0aMCQ8JzyKA+RpPgZJKMX2qeKdF1nj?= =?utf-8?q?XSG2RtIsjhWAthDmm608MLcabSS6GjAsZxEEiW8ukkDNlgc8gN/Yg5gMdNMMrzKga?= =?utf-8?q?cvB08Jn2AZutQ2iQNCnXXR/xSOcnDrwuHczoZQFSXmv5Ink4zC/A8n6Bx5wcgikWl?= =?utf-8?q?Nkue4CX3p7u10ZsD24Sm25I+/w2YZo3tKxCanWHQJSocCaOQjgpzCbiaSvPQ6+ZAz?= =?utf-8?q?WY+NGDRgEh+uYtA0Qwgusi9TzM2sdjay6ewWFQPoarYgM7UpWvt2s5tgRtf9DOsvd?= =?utf-8?q?luEr9ZQ/ugE0bFZgEU9PFip8M5ixxJFrjZbixqlbLhH/aVd1hSAsc0eqv0WbOJ+ei?= =?utf-8?q?b/xvY0v5eRBXpXz9UJ/BpLlds/ps9o75IWwjRplsAYT0JKH3q5yxpJpn/CCZOwye+?= =?utf-8?q?ffv+5OGmPAFoWQbWEFiwC9dN8ZVZr4CzJyWgctRMfjhaNqW0e5MyrSNYoIqgMKa7u?= =?utf-8?q?TGTDnB9GWaO4vkP4p4iKPm8/Odqno2Z6QgVVnUmox+dHrFTiAYksPpbi+qvrMdwOM?= =?utf-8?q?/lvHuSv+4OEoaTF06n6E9NuzKuVA5tT4oaBi15mpB67vlpxzJ5GLKAZCZGJ3yhqQa?= =?utf-8?q?17o34zGV8MmBjTaha9QAEuUuchoGkDCTRbscafV1Jv7pNTggOuUzm9we7BmFZjC5w?= =?utf-8?q?ui6EtsDAhhJfjSF0aiovdi1E0Yj0SJUVCBj+iUQAS0qbo/F+R6qVjsd2rgAofBC+/?= =?utf-8?q?bHhd1xCuEaOEPsi5MSpppsCfu7Ykugb/pfDKZV4hE1Voar60CeT6zMXIGpC1McAl4?= =?utf-8?q?Dkz+xlcD2rYq?= 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)(366016)(7416014)(52116014)(376014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OrWMeWHKilbOvi1DUd7G50t7O6Ax?= =?utf-8?q?RB/5vfy8zuRnJL63A/6ZxkHS4TCtH0l/RV+iQB/veZkeLqZNA7fNB1fWl4RG8YRnC?= =?utf-8?q?lr/jWUDu6h+MAiae+5bWZdapLQCnWyntsnt9QLdffTASqWHzaQzCU5L66w71itSKq?= =?utf-8?q?k3r5EsqMvsK+wdSG48NYUsalHCWF50+o4A9EIS3FaQNo90TKBFqiiKW0E02jyvRgb?= =?utf-8?q?lQiHMc55XLYEam7G59wQhDa/SAcn8IpTucmX4YaRSHuAUtOrASwFfZYOI+O/mWX80?= =?utf-8?q?fC50JRR/fA37zLQoDE/Mn8Y9YzRp2ZWTIVtSImylPI8CuL6/BjSrHBpHRXNxgkLtG?= =?utf-8?q?5agkEzjK/9CpVWX+JeDAq+R1fGFIx1JooDVoCVe6thRQBhmqk3PbQx3FQ8izmBU8Q?= =?utf-8?q?Txl0AjgIAkB3MWtUObKb3qk8zIMOCwk+GnGf9G/KiV7Cpbl4ohMmHKEh3BVJ8ggwY?= =?utf-8?q?8ph+JP7skpv6a/T4P16A5hzr7nUoXjAxhro2F15xyrEWCOVk7i2Wfyjey3pKFO3VX?= =?utf-8?q?pHaK8sCYfbyJ9/QQn7BnjiqOqI/uDmyJ//0trpDe1VvEKKT3iH3Bw7qQkmQmP4JpP?= =?utf-8?q?SVvgG/FL+XiKSIeTY1Py5Siw7Dxw+8IwL2gBLxayAPoJQTpOyUHiqQKL1UsHZyH4t?= =?utf-8?q?NL+tWH7d5lnNwwlbe+jbPI0MiYENWsrvnodZ3RLgAVGNWEUQbljNY3wSXBjxApmUo?= =?utf-8?q?K/Fgb0vSK+N43C/wDH/TLLA5EmVLV6ft/BaefpgqPQ93ecNjkjgJCzY0p7nnOMAzc?= =?utf-8?q?mMx60XvahkU5/g3oFCanb5SCY9hc/LQcmyDD05wU4nC1Jo9SQf0tWv/V0NKHSXbsB?= =?utf-8?q?OZXcLHHxyrbLk7CYtCW4El9xtScSMl5TbBwe1W+QSBUK/799PDuPlaSOERL5Qv6b1?= =?utf-8?q?N5XUyN6egj/I3GUhwioBsLngI3jWeLaQUmMs1OIAAm51sS0zET4da219Y6yvpxjvh?= =?utf-8?q?JcWKw1sPosuLyNZiGEwj8y31E2kJ1PdzwNJqWxTAsDnr9uygIJFHySjSfD6RHA8U6?= =?utf-8?q?F9boVOgbIplDe++Zyja4UNlSeVi2E2HbxfMROS1tZnrwFO2IyU8dOnvZjdzcfp/Px?= =?utf-8?q?VnHsdJhNIiSKe9ZU9OpBz3WRxIdwWCqq1oOgoRpLA5uv//EgH3Xb2wHCToEcw4msI?= =?utf-8?q?N8O2vA32eOChBFhnmAlcV6fwP4ok4Jmtnb1aHI+1rue9Lb+9hN9uwKeQlH8yZB9ez?= =?utf-8?q?z79PCQ5PmrPiV5q3DfcxcWrYrg6Qj7LsfS/bbsGHywOAiPu3p4xDY+pj6i3q/cQwf?= =?utf-8?q?WVeRZCBpBQQrs/OP2OPzoRmS9xGQJvwEGh80GuQThSDDsWWl4vMT+fPAQF1lsJgrW?= =?utf-8?q?i7FhfTY3PktFD2Feai5IHLFNlEXBj/x5GW/Oq374CJMrAf9UMhtx8Gi7TA8Gmh+Vo?= =?utf-8?q?NtyWFpj/2lxUU5mCTrGz1a3IsDVhDIA6J0pNC/MGCBXK1uASu5zNndWBxGVLnUfsd?= =?utf-8?q?bhA1b3vcp7ePKz36RPz1YBOKYGhFCaM2GXI+Z82Z2f5AKwtMSUr2jEn4KbtN0FfHb?= =?utf-8?q?2mACO/gRkJ23?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b262bce4-4927-4c3d-2e68-08dcf20c0b19 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 20:07:52.0156 (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: cnibLKj8M7lRn/IX/PC/LWtI0rA07Zzpj/XcP5AnQDxHvmhsCtZ9R/HY/wbHn0P52hToJb+DhEV5+LoHHpjRBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6882 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_130756_709487_7D955E2D X-CRM114-Status: GOOD ( 16.80 ) 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 Endpoint Root complex ┌───────┐ ┌─────────┐ ┌─────┐ │ EP │ │ │ ┌─────┐ │ │ │ Ctrl │ │ │ │ CPU │ │ DDR │ │ │ │ ┌────┐ │ └──┬──┘ │ │◄──────┼─ATU ◄─┼────────┼─┤BarN│◄─┼─────────┘ │ │ │ │ │ └────┘ │ Outbound Transfer └─────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Inbound Transfer │ │ │ │ ┌──▼──┐ ┌───────┐ │ │ │ ┌───────┼─────►│DDR │ │ │ outbound Transfer* │ │ │ └─────┘ ┌─────┐ │ Bus ┼─────►│ ATU ─┬────────┼─┘ │ │ │ │ Fabric│Bus │ │ PCI Addr │ │ CPU ├───►│ │Addr │ │ 0xA000_0000 │ │ │CPU │ │0x8000_0000 │ │ │ └─────┘Addr└───────┘ │ │ │ │ 0x7000_0000 └───────┘ └─────────┘ Add `bus_addr_base` to configure the outbound window address for CPU write. The bus fabric generally passes the same address to the PCIe EP controller, but some bus fabrics convert the address before sending it to the PCIe EP controller. Above diagram, CPU write data to outbound windows address 0x7000_0000, Bus fabric convert it to 0x8000_0000. ATU should use bus address 0x8000_0000 as input address and convert to PCI address 0xA000_0000. Previously, `cpu_addr_fixup()` was used to handle address conversion. Now, the device tree provides this information, preferring a common method. bus@5f000000 { compatible = "simple-bus"; ranges = <0x80000000 0x0 0x70000000 0x10000000>; pcie-ep@5f010000 { reg = <0x5f010000 0x00010000>, <0x80000000 0x10000000>; reg-names = "dbi", "addr_space"; ... }; ... }; 'ranges' in bus@5f000000 descript how address convert from CPU address to bus address. Use `of_property_read_reg()` to obtain the bus address and set it to the ATU correctly, eliminating the need for vendor-specific cpu_addr_fixup(). Add 'using_dtbus_info' to indicate device tree reflect correctly bus address translation in case break compatibility. Signed-off-by: Frank Li --- Change from v2 to v3 - Add using_dtbus_info to control if use device tree bus ranges information. --- drivers/pci/controller/dwc/pcie-designware-ep.c | 14 +++++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 43ba5c6738df1..81b4057befa62 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "pcie-designware.h" @@ -294,7 +295,7 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no, atu.func_no = func_no; atu.type = PCIE_ATU_TYPE_MEM; - atu.cpu_addr = addr; + atu.cpu_addr = addr - ep->phys_base + ep->bus_addr_base; atu.pci_addr = pci_addr; atu.size = size; ret = dw_pcie_ep_outbound_atu(ep, &atu); @@ -861,6 +862,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) struct device *dev = pci->dev; struct platform_device *pdev = to_platform_device(dev); struct device_node *np = dev->of_node; + int index; INIT_LIST_HEAD(&ep->func_list); @@ -873,6 +875,16 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) return -EINVAL; ep->phys_base = res->start; + ep->bus_addr_base = ep->phys_base; + + if (pci->using_dtbus_info) { + index = of_property_match_string(np, "reg-names", "addr_space"); + if (index < 0) + return -EINVAL; + + of_property_read_reg(np, index, &ep->bus_addr_base, NULL); + } + ep->addr_size = resource_size(res); if (ep->ops->pre_init) diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 347ab74ac35aa..e22d32b5a5f19 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -410,6 +410,7 @@ struct dw_pcie_ep { struct list_head func_list; const struct dw_pcie_ep_ops *ops; phys_addr_t phys_base; + phys_addr_t bus_addr_base; size_t addr_size; size_t page_size; u8 bar_to_atu[PCI_STD_NUM_BARS]; @@ -463,6 +464,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)