From patchwork Thu Oct 24 20:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13849714 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 0E4D0D1036C for ; Thu, 24 Oct 2024 20:56:41 +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=2ZEqB5SgGYv/wLtHKqtrS28/MuvXtIH7arWnGnAkSxQ=; b=ebXIaXigO86ku9ZkxlGmZyxxxy x05KAlcZKKfXAjPKhM8JQKlb5juyujT2JSQ5QnlbgnI+XnDtMzpPPDbZG5ovC69H34854lSm1u/s9 2Xxt3IrElkrKV/SOrhDjj5yPPtz5rtVHqBwQpZyWxAEyj/VY+UcwbsnDpSiGYvOnTDclqjGocl58i leX/SUVKRYlzCfxPywegq8lGlfn+ujXCnvOPiSOXDOmHSNW/xpBuDexhakjNkRPhnvq3cHOisQar6 hjAIzNYI/Z1Zk6louCBDwi+BVls0yQgzdIcDaMT6MvN4VTyvVDfBQzw07GRAdYbi+ol3MLZ1L3IdT nxLrtfsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t44sg-00000001nhQ-0e7q; Thu, 24 Oct 2024 20:56:30 +0000 Received: from mail-vi1eur03on2062b.outbound.protection.outlook.com ([2a01:111:f403:260c::62b] helo=EUR03-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t44ey-00000001lHN-3fjh for linux-arm-kernel@lists.infradead.org; Thu, 24 Oct 2024 20:42:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xExKwUHTn6oZsXwRvMdoP5g6tFY3lG3X7l0RcW/z1UD2lC7dG1lvPl28BEEKtau64lquy2Igx+hHPzkq7k3eUPiqGy2hp+Z0RornioV5Rufcu6FVyBRFhkE31MbpbNFTtxahvUX7eLWb8TBgZi+v2s1+datJ5VdlxXvD4u/YBHVt3/rAWRETR6u4HYqwktaLNXsEFRc97bkwUoGE+boLbhy0QNZ4lB2JEZRP2sx5R+wzaMD6oRdxSFF5Hv8HJO8J47HjJxciz2tLiV9VUx8i5kNKyEhB0zapMwCYoPWd5u2g7TEBBHkqVMP1nUjr07LDw1X+drqmaudPMV+xDr4RkQ== 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=2ZEqB5SgGYv/wLtHKqtrS28/MuvXtIH7arWnGnAkSxQ=; b=TMpLZgd4wqcziKR01Gnb01GGQHPnCkDE2eYon8t2+9/C//29d7UEjLtEpmvGb80Jm+XsbCTDb0drI4A27g5AMMIT9aEsfv/OphxEKhm+g3ocrBRn8ghVPNNG+68ECWogiAOR2sxI467qi2D8/nbdtcqTAJm61K1Ap5b9vEPCGs2OIfzzMWcm1jYGhymmz1Esuas6dJX4nh8LLwoV1na+WFSR5Gzgx76eD7LzbZnF/5ehXyOLDNLcOm2jZcBYcQzLERWGoIdLNOOso5YH+t/yDXMPZMqK7PvyyWEf5tL+IbQfoJXe4cF8FsVglIKLeGh9c+RsNkLhSBlMjpqgxGZITQ== 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=2ZEqB5SgGYv/wLtHKqtrS28/MuvXtIH7arWnGnAkSxQ=; b=Aw4USNMB7TKUDptBJ8By0tAsio2H54K6A2agLXSKMjAjnLezJpjfJ9VAScAZtoyayt7c0K7n/LqonB8RFHmbEdftHUbDTJ7QIHiPxnepuOPXmM+qlQXKnzIEa5yc6wDuieu+QMF24ACtbNAoXy5bdZvUN4eQXqHgQzZHzuyGNj8Heh5q5cSIalIPUq0XC9N9lgw0gMsw9ZwDiD7/DX3wg++z7onJKQ63dVoMKdpiXwar1B14gHAYwn1pLjGiPxmkSbGMDhOyUd5QLn3tpI6yLdCNiWwMd5qEhCs9fJGKFn55whcAImSGM/hsZ1Sv/tbzqr3ln+bB7zMCI2Mk+2wBdA== 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 PA4PR04MB7517.eurprd04.prod.outlook.com (2603:10a6:102:e0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.21; Thu, 24 Oct 2024 20:42:17 +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; Thu, 24 Oct 2024 20:42:17 +0000 From: Frank Li Date: Thu, 24 Oct 2024 16:41:43 -0400 Subject: [PATCH v4 1/4] PCI: dwc: ep: Add bus_addr_base for outbound window Message-Id: <20241024-pcie_ep_range-v4-1-08f8dcd4e481@nxp.com> References: <20241024-pcie_ep_range-v4-0-08f8dcd4e481@nxp.com> In-Reply-To: <20241024-pcie_ep_range-v4-0-08f8dcd4e481@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=1729802524; l=6280; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=GsBrY/rr2TGV9C/ufXVpAjG8EooxUe4YBDJ9aZkc+U8=; b=ovwh5BoEazxQSkess/heM2mtUzNAlTzZAc/9uH+fSvCv/SPD5JyAPhMC9HLfFwlBinBisJRMO x1V7/EzLQxnDDtthTziKY2Fyl95BKt58z/edAtVscRq+yEPYD8VG2Th X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0112.namprd13.prod.outlook.com (2603:10b6:a03:2c5::27) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PA4PR04MB7517:EE_ X-MS-Office365-Filtering-Correlation-Id: 5808ea38-83a8-4067-8006-08dcf46c5926 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|7416014|376014|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?kNXGlpbypasjCpruFX/Dk4RNvfcGtYY?= =?utf-8?q?FvJ1K3qjre/Ees56AoAuD4mdg8dTERGtMBt7HtjP3fi95+vLpHEG0p0KnRoCXHsIn?= =?utf-8?q?xrwAQGmXUnbJcfvz9Di7J+Jq7HrjqYM4tMVwCon4XGwKGXfFPzSC6yZ9hKLwwVzRL?= =?utf-8?q?rc5EDeao9ABH+qQd0XxFsHvDq8VdYmj04OXyZwCfs5KTQiwP/blWHVB5iBeCEijS2?= =?utf-8?q?96w7NjdDNiPYCUKaHUp8S/s+2p7BlkWDd/FtEyrsLSjCgZNBBb29iNQ+xFwW7JsE5?= =?utf-8?q?Q9Q5nvofqpYJpV81pmAjtkjggm/kJRLMtvbwHATIWA9SdfmO0SGKQf3qeJ8/iZC14?= =?utf-8?q?xra/9GsvJUmZ7rfuWupSgX13EyUwDi0wUrqwUQSJwfawnrZ1er3qV/yg+Eq1jD5RN?= =?utf-8?q?Dk+1+f74c95z+so6WPrR017Vq1m2oXawX/wuuDzmmIFIQI3HJs92U4koxWBB5vsdH?= =?utf-8?q?B5VJ03s7AFGbfChX9LocwJ4UpyJ6Nz4C1O+Qa44/lrVyQ1jjwODaAtbWPJ23nWM1C?= =?utf-8?q?RxqhX8qKMKbWuZsT3iHOwCxXCCFUp8jiAWzOjPjqUHGeXc3lr02tz7EKnQSq+00qB?= =?utf-8?q?YXxTkFRflae/LrXpWjOfCUo8WpY+hXaQwB+UH112e7Vp50EJprd+m/Ht4+L/A7wQo?= =?utf-8?q?lgDuE6u5QN4a4/LcsG6l2XGyo5Rq/tKyohrAVEb8ctorlOoVuNRQenUcZi521LTIV?= =?utf-8?q?Y/z1SNqoCzBLKjaVZDieZA9fOHMhScfYdBhV1NunBoZZGwESh8cWcau2D2qBVwAiG?= =?utf-8?q?LctMQ+kCChNRcaXj78ftmQ2A98KYGZR1xELHBcFtP9RKKRBI3mVOUXvHo9leYFvin?= =?utf-8?q?3NRZc4h6zcQAJQaDbva+dUDlc54M5ufpV+xcUu1N+CHlPTJ+FSWzfYCei3y7uL5IG?= =?utf-8?q?5nXaGtoNp5P+3RbK5rk2PwYp527dkgofz/LdyPFTpnHzolhns6RH7pd8EOE1mDlsK?= =?utf-8?q?oOzHWBR53V2TY2pmtLjar1TGqf+ElFD3KgqIlw7pVMbCGTXdrZXc3ZmHq7i5OGIkE?= =?utf-8?q?pLFOJ8FGBlykl7L0obCQgVFQMSg6BiI3a5rbc8lisHAtSj5Z8ivqxmFIVNdGuL+rR?= =?utf-8?q?reH6Yey39rNaGyiqMal3FFBaQHKo/l37Hxnwe4zeWdrSawEIKn+dpk3IjQq62zMTD?= =?utf-8?q?m3dUQD0QHUkt33kdlpD++JUWkb7ihzcoZTc+y0oO9QVApidFc2EKKT703fIVI1S6Z?= =?utf-8?q?seRpIZ9kxplkUQaGjgc8wQ2ue6AMciKtX929W27TqinRvB6kXbwiHwTFjLXz+XjMc?= =?utf-8?q?1nSlzZCLNurT25ltzY3SqkhUZi4beV/RMDw4cFWM3B1wZAiVkDTZKk+UKbUKB1cx/?= =?utf-8?q?Rc2r42GZKaJwRaBST4SH/CSb+5NOiZI8Xg=3D=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)(1800799024)(7416014)(376014)(366016)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?jM6OoKrWqTmpi1xA2KaN7kPGiWtv?= =?utf-8?q?pCxPmquZIxiWpVFBmb3u6Ad/9DxEw/QBwGfi5HkyeaMid7124IGpdrrcxAp6tYPkZ?= =?utf-8?q?Rg02YKdZDvxpUBc2LI4e1vypiCDG3+dNv0UZ1oAFfLVilEALDRCZDgkagDGC2uVMQ?= =?utf-8?q?y3fEtfeZ9SYGJUaPJyeTHIu/10y09SfvQkZGyNFGLNRR0TEyCdnwYkGzGzZkbGdkS?= =?utf-8?q?YPbUz6B+LNIyvQkIPtR7PCE7Y2IISbYhq8Y8btaNMSdnxMAYAaM5XmhC8WkThg6eh?= =?utf-8?q?bVucGIBozzhXKic1RfbrsuLjMEmwQ2aEwgKCozc9PVtBEBMeWzTDGGXtRktow/xT8?= =?utf-8?q?bfKDdymaM42g0r1Keh2QpXqYzcMUPKyKur47HCTVRwcaoIQJnVJHkzGs4ItHy3jLO?= =?utf-8?q?d3ZnBQdIAntaImDWfnRSeRlpoPuNiMDUAKx0pMr2aXGp1QloClicbRS4pY0BmYxUs?= =?utf-8?q?0dJWq02Z3ib31QZLFAhufsOkFELUUT707aukORNqWJ5cK1p7PkBFn5e3g8BIcItE7?= =?utf-8?q?WrEb2HWQKMEZUsQA1pjOoj9+C8RV5xisrsfGXCqxPSbAsOBRvGPTmwcanCrQCBCQr?= =?utf-8?q?ZownWG49qO/D2SKyvTmxPOIYydKTy7aZDyEDzF2wEDOF9kL9DHpfispkMwBSWsSTH?= =?utf-8?q?KP/YhXFDryR3F8phdice1SbasDEVWBx2XRy2cT27jfzyAjAAna+0l6mNsSfWhHsQ+?= =?utf-8?q?V1KPOfWMqVypqgsxQdnieHB4CPEkgmzRAL9Xtg6yg3LlyKUUGmYuXmzLsVfQYIfaK?= =?utf-8?q?fA/WqABuiSJNNgAwH9OpVEyOwjoNbvJGyW7pvi7IiC7npR8g1qQ44n2eg4NjlTP87?= =?utf-8?q?GxmmP4C639VPghCy/+WSRAZsb9Gz07KrsDS9EIrP3wSlGE5a/Ah75HghlNoUEHFHj?= =?utf-8?q?DhKrTeY5PiwseDjNv/hr700pqqnTl4E9sKOYUTs7mpZyuDEVjxEOUyblDeEJQEm86?= =?utf-8?q?iUAHmxzKA8OD+aF+w5GaS1a+RCJvWX+BPZs1h4ItcFMWUBV0/XRxEwOfAdZangzPn?= =?utf-8?q?3FtUvFS+M4uPq4Qd9/6sXYVbmuh4QDY6u6/atDIp8QS5ldaSi+0P4den8d3D6O2Qx?= =?utf-8?q?y9lCb9jvG+5Zksxxf/eZKOfnXsVcWd7DjKLNjY9N7+cjUa5cga+Z5PmVKiPuv7qkx?= =?utf-8?q?ibNA+SlzU7BCeUSGKAHgHS9I2monczHeaUBeEFDKSKL+xd/vShPBe1K/8GxHuc1Je?= =?utf-8?q?152cbA4+uRwWybGRVWQFMBQOfhqsoBTrtb/mJPoWYj+CTjaMM82vCC84g14t/LqlN?= =?utf-8?q?El+BJqyy2d+UhPnckNEwrpe1rlnFV1lF7BFMzPODhq2XyC26l1XoGUpyof0H1a0wy?= =?utf-8?q?ULDg7JmwtXyKBEYOxycPXlnxaBvN5TWddpQIP+IwL+IG5rauRj4KUdYKaBFT6iVB5?= =?utf-8?q?qbYU8PDZBKa3LCgFUD4sdRF5Z3zqeE56W6xQiy0upmDjn+ILRZ7XHshnAP3BKXK2U?= =?utf-8?q?dsIHRghO0ZQTfB6AcIt7N/fuIdvAYOvQdpvySYPEP4zTTVG7ElsZalb4qUMy+NEN5?= =?utf-8?q?mnv9f7aZJ3uu?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5808ea38-83a8-4067-8006-08dcf46c5926 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 20:42:16.9954 (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: y4CFhmwQgPjtm6HpIfBMFVCgSlvykrxv4LHTMEEAdLn8tfbUbWos+eB9Ke+vFrYo9qW1fu7CmdWbZE7O9NJlAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7517 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241024_134221_112745_7F27C4EA X-CRM114-Status: GOOD ( 15.45 ) 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 v3 to v4 - change bus_addr_base to u64 to fix 32bit build error | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202410230328.BTHareG1-lkp@intel.com/ 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..f10b533b04f77 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; + u64 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)