From patchwork Fri Sep 2 14:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daire McNamara X-Patchwork-Id: 12964275 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 D8779ECAAD5 for ; Fri, 2 Sep 2022 14:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g5eQJi3cngB544Hvb7r88OVho+NzvyE7WkE4Fqfmj/4=; b=DHFQcKi3KCmu+i weAEE34ALFv5Bvg9h7gKbl9qt5RDPxYCsmusSsdoymw9B5SuiDICVR6rfDX/kiCqL+hSSCkwjIU53 EbxvH2MeiUMumX4mtvNSAsZJXk0JyqoyAZO9g0Sya5wWom88WO4wmyF76FZPDcqIo+GwmqrSpNbIK zsF/GQ07d+VF83oW00nKnuxOVgo3WvjDaLmuyr7+1x3pUOvmUc3CBnptwKDLqQxqGJ3IDk/FJB4Le Ab2tWxWRNSjn4fIg+RYlJNorrez8vuGzN95ARAEFNXqmbLAdEPIrkHcIuHOuA9xTexcdUmTFQbjX0 xjP8mqwUsIwkIn3GaeCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7Z8-005Voz-2Y; Fri, 02 Sep 2022 14:22:38 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7Z4-005VmK-9l for linux-riscv@lists.infradead.org; Fri, 02 Sep 2022 14:22:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1662128554; x=1693664554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ruUuCbd7+5Ub1DZrutHdCrvbcDkefYKJFQJhor7JwlU=; b=R8fN+65Xz7+UVgbjoHsnKDk5ZVhAr1fmWIJ8E/sEKUeeKwA7KhktC17k pauDhyim2Wx3wCvJ7pth5tzTLOkCD5wjeaBYkn2OoSdEwFhph9Jk2X6ps mCC1Ih+Y1Rst6FwWWVzDwWUNt0soBKdJVNTrcs5me5l5wJoYQ9GZuYu9a H+tu6iu2rYb6RyxwlIdbAfTOA7v/7vkigmdNTy2pCxlriI1QBgt9p1Dxx 291RQBuUfXkTzTeSCSsIopw7XiwpHCC0Yt1pB3w73FgeiNsTU9EO/s4uc sbpCpBkR0UfqioCqw+uI/T5b5cLUzT5eJBrd9AEjm5+lUeFKEJYP3qPkW A==; X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="111937895" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Sep 2022 07:22:27 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Sep 2022 07:22:25 -0700 Received: from daire-X570.emdalo.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Sep 2022 07:22:22 -0700 From: To: , , , , , , , , , , , , CC: , , , , "Daire McNamara" Subject: [PATCH v1 1/4] dt-bindings: PCI: microchip: add fabric address translation properties Date: Fri, 2 Sep 2022 15:21:59 +0100 Message-ID: <20220902142202.2437658-2-daire.mcnamara@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902142202.2437658-1-daire.mcnamara@microchip.com> References: <20220902142202.2437658-1-daire.mcnamara@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220902_072234_434448_00DD008D X-CRM114-Status: GOOD ( 16.96 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley On PolarFire SoC both in- & out-bound address translations occur in two stages. The specific translations are tightly coupled to the FPGA designs and supplement the {dma-,}ranges properties. The first stage of the translation is done by the FPGA fabric & the second by the root port. Add two properties so that the translation tables in the root port's bridge layer can be configured to account for the translation done by the FPGA fabric. Signed-off-by: Conor Dooley Signed-off-by: Daire McNamara --- .../bindings/pci/microchip,pcie-host.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml b/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml index 23d95c65acff..29bb1fe99a2e 100644 --- a/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml +++ b/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml @@ -71,6 +71,113 @@ properties: minItems: 1 maxItems: 6 + microchip,outbound-fabric-translation-ranges: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 1 + maxItems: 32 + description: | + The CPU-to-PCIe (outbound) address translation takes place in two stages. + Depending on the FPGA bitstream, the outbound address translation tables + in the PCIe root port's bridge layer will need to be configured to account + for only its part of the overall outbound address translation. + + The first stage of outbound address translation occurs between the CPU address + and an intermediate "FPGA address". The second stage of outbound address + translation occurs between this FPGA address and the PCIe address. Use this + property, in conjunction with the ranges property, to divide the overall + address translation into these two stages so that the PCIe address + translation tables can be correctly configured. + + If this property is present, one entry is required per range. This is so + FPGA designers can choose to route different address ranges through different + Fabric Interface Controllers and other logic as they see fit. + + If this property is not present, the entire address translation + in any ranges property is attempted by the root port driver via its outbound + address translation tables. + + Each element in this property has three components. The first is a + PCIe address, the second is an FPGA address, and the third is a size. + These properties may be 32 or 64 bit values. + + In operation, the driver will expect a one-to-one correspondance between + range properties and this property. For each pair of range and + outbound-fabric-translation-range properties, the root port driver will + subtract the FPGA address in this property from the CPU address in the + corresponding range property and use the remainder to program its + outbound address translation tables. + + For each range, take its PCIe address and size - these are the PCIe + address & size for the element. The FPGA address is derived from a given + FPGA fabric design and is the address delivered by that FPGA fabric + design to the Core Complex. For a trivial configuration, it is likely to be the + lower 32 bits of the PCIe address in the range property and the upper + bits of the base address of the Fabric Interface Controller the design uses. + Otherwise, it is tightly coupled with the data path configured in the + FPGA fabric between the root port and the Core Complex. + + For more information on the tables, see Section 1.3.3, + "PCIe/AXI4 Address Translation" of the PolarFire SoC PCIe User Guide: + https://www.microsemi.com/document-portal/doc_download/1245812-polarfire-fpga-and-polarfire-soc-fpga-pci-express-user-guide + + items: + minItems: 3 + maxItems: 6 + + microchip,inbound-fabric-translation-ranges: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 1 + maxItems: 32 + description: | + The PCIe-to-CPU (inbound) address translation takes place in two stages. + Depending on the FPGA bitstream, the inbound address translation tables + in the PCIe root port's bridge layer will need to be configured to account + for only its part of the overall inbound address translation. + + The first stage of address translation occurs between the PCIe address and + an intermediate FPGA address. The second stage of address translation + occurs between the FPGA address and the CPU address. Use this property + in conjunction with the dma-ranges property to divide the address + translation into these two stages. + + If this property is present, one entry is required per dma-range. This is so + FPGA designers can choose to route different address ranges through different + Fabric Interface Controllers and other logic as they see fit. + + If this property is not present, the entire address translation + in any dma-ranges property is attempted by the root port driver via its + inbound address translation tables. + + Each element in this property has three components. The first is a + PCIe address, the second is an FPGA address, and the third is a size. + These properties may be 32 or 64 bit values. + + In operation, the driver will expect a one-to-one correspondance between + dma-range properties and this property. For each pair of dma-range and + inbound-fabric-translation-range properties, the root port driver will + subtract the FPGA address in this property from the CPU address in the + corresponding dma-range property and use the remainder to program its + inbound address translation tables. + + From each dma-range, take its PCIe address and size - these are the PCIe + address & size for the element. The FPGA address is derived from a given + FPGA fabric design and is the address delivered by that FPGA fabric + design to the Core Complex. For a trivial configuration, this property + is unlikely to be required (i.e. no fabric translation on the inbound + interface). Otherwise, it is tightly coupled with the inbound data path + configured in the FPGA fabric between the root port and the Core Complex. + It is expected that more than one translation range may be added to + an FPGA fabric design, e.g. to deliver data to cached or non-cached + DDR. + + For more information on the tables, see Section 1.3.3, + "PCIe/AXI4 Address Translation" of the PolarFire SoC PCIe User Guide: + https://www.microsemi.com/document-portal/doc_download/1245812-polarfire-fpga-and-polarfire-soc-fpga-pci-express-user-guide + + items: + minItems: 4 + maxItems: 7 + msi-controller: description: Identifies the node as an MSI controller. From patchwork Fri Sep 2 14:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daire McNamara X-Patchwork-Id: 12964277 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 42497C38145 for ; Fri, 2 Sep 2022 14:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=75acsT4z4JUYTuaaJA3jG4H43NHnrzLxXydgsMcWxX0=; b=oHHffuZNUPrNSz +/hWTh94Lmovp30yRg1500bri/Syy7sLDoOFNr3Yrqa4zSEcKpfhWUd7PqoHSPsx/2DpkyEXSBhOv 4Dtvx0LEhnGsxkb2oDIg/p7DlnkFl8ze9lA99wQeAukBIt0lHP9SOzI9DeojFlMGcYMjhKONXA8Si T7ogoeYvEYmGQj3SGbOr+RAXiS/0RHxQn00xwGrx2QK/m/jeHB1DIGx+2Sf8JfyflmZOSoAbI4R+a 5UjfGmw8KTl9BlkUBIBQgB+vDwW1lV5LGEA/lGVVHSjvn/9VE39uxdr/M0dvLxNuNIe9qo0nM5RFg lvyN5HVENF5K+ug5JrUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7ZE-005VtG-1W; Fri, 02 Sep 2022 14:22:44 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7ZB-005Vr3-7K for linux-riscv@lists.infradead.org; Fri, 02 Sep 2022 14:22:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1662128561; x=1693664561; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A0wOjkGsQ3icV4sYzW6juzBiZor0CRzjl5/cGd/VbdU=; b=BThAM74/oZooTVHZhT6iqXBluB9Jgb1D/LVVdiUeXxgFdpTJFvmxQPNz fkItxkzH3KKc34rXjjH+udTD0iOURbs1PGOp3vQTa6Zlqo28xAyPAweP0 wlid1Ey9XbhlaHM/SZUefnNDRP6MbiKMiq1RKwBoY+J9eNY4zlPlEIVL5 Qmt6j/x7G5KqTvRt47rz3L3xFE4mSNrAgTuETsZqZrphd0y2RPk9y4+en 111nPDzbE5TZRQhZ1pbzH2eF7dLA6UNZeVb2bsZUm98rY0fHVyKadlJi2 D/sYqqisFh3is+jt8UDGm6QwnC1bBx+q63SoGwbjnzwtvk0s11n/B1y6i Q==; X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="175388520" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Sep 2022 07:22:34 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Sep 2022 07:22:31 -0700 Received: from daire-X570.emdalo.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Sep 2022 07:22:28 -0700 From: To: , , , , , , , , , , , , CC: , , , , "Daire McNamara" Subject: [PATCH v1 2/4] riscv: dts: microchip: add fabric address translation properties Date: Fri, 2 Sep 2022 15:22:00 +0100 Message-ID: <20220902142202.2437658-3-daire.mcnamara@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902142202.2437658-1-daire.mcnamara@microchip.com> References: <20220902142202.2437658-1-daire.mcnamara@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220902_072241_355758_F6532ADD X-CRM114-Status: UNSURE ( 9.01 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Daire McNamara On PolarFire SoC both in- & out-bound address translations occur in two stages. The specific translations are tightly coupled to the FPGA designs and supplement the {dma-,}ranges properties. The first stage of the translation is done by the FPGA fabric & the second by the root port. Add outbound address translation information so that the translation tables in the root port's bridge layer can be configured to account for the translation done by the FPGA fabric on Icicle Kit reference design. Signed-off-by: Daire McNamara --- arch/riscv/boot/dts/microchip/mpfs-icicle-kit-fabric.dtsi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/riscv/boot/dts/microchip/mpfs-icicle-kit-fabric.dtsi b/arch/riscv/boot/dts/microchip/mpfs-icicle-kit-fabric.dtsi index 98f04be0dc6b..6839650e7d1b 100644 --- a/arch/riscv/boot/dts/microchip/mpfs-icicle-kit-fabric.dtsi +++ b/arch/riscv/boot/dts/microchip/mpfs-icicle-kit-fabric.dtsi @@ -57,7 +57,11 @@ pcie: pcie@3000000000 { interrupt-map-mask = <0 0 0 7>; clocks = <&fabric_clk1>, <&fabric_clk3>; clock-names = "fic1", "fic3"; - ranges = <0x3000000 0x0 0x8000000 0x30 0x8000000 0x0 0x80000000>; + ranges = <0x0000000 0x0 0x0000000 0x30 0x0000000 0x0 0x8000000>, + <0x3000000 0x0 0x8000000 0x30 0x8000000 0x0 0x80000000>; + microchip,outbound-fabric-translation-ranges = + <0x0000000 0x0 0x0000000 0x30 0x0000000 0x0 0x8000000>, + <0x3000000 0x0 0x8000000 0x30 0x8000000 0x0 0x80000000>; dma-ranges = <0x02000000 0x0 0x00000000 0x0 0x00000000 0x1 0x00000000>; msi-parent = <&pcie>; msi-controller; From patchwork Fri Sep 2 14:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daire McNamara X-Patchwork-Id: 12964276 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 83101C38145 for ; Fri, 2 Sep 2022 14:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fjPNCCggEF6siZecN+n4uwgj8cjokC21p2O1MrgF2es=; b=M4KfIKiPx/wt0V hv3xdjJ48/yJNFWx2TzuzPUfW6vxMUcbHxzBlv6vFxGjoPIKfN659TbbtGCd8Q3b7iF4S/qR+Jl2L Ifrxb/QEGKR7EUjBEFR6Ao2cvqrwmK9Gq+SZ7Zd0Cb1omnX+3c8LJo5dyl07mzaq1tanwWYDVwMoJ GsC3AoeLHue2sVPQoc4hARv8UX7bGKKpATsG5FIPPq6N/zR2lJqJZGAx34D4t5NlY7qaiuDh2wSI6 1wAE6tVrarthPCwNqMmgZJjK4ql/dwGDXwrqwjqmeibpiueqRD0PbWtyzJtAWm3OCPtXvpSRM5zel 10XSyqj5vxHGpy2hM48Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7ZA-005Vqr-Ox; Fri, 02 Sep 2022 14:22:40 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7Z8-005Vp2-42 for linux-riscv@lists.infradead.org; Fri, 02 Sep 2022 14:22:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1662128557; x=1693664557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Obajmxu5RArASYmlyf62HbTUThXup5Mw1+gmQJFUCgI=; b=d6YKtR98ssdpcbztL0CDFMuGi1gJNqiBFlswx8XMCILe/qGgfYPaH1zK xMQrYUeoUH71by4xBFYIMAv1nrM7FELwwYKzTqd5Ki6g1a+9V8mBC/4jQ O46HUjn+FwiQrAsykPDTTqoZj1aEuYSoKAIp1xkU2vG6VwXTOQjoCXLcA RovohpSHOw9URqfVJ+dvGveCIEK4egnTh7SYkw76G4CM3O18KBTv2BBRj OurQUvKaZT4euzE1hVYbhXqNMzofLyhY9M5RgVHu5wW1p6BNLIm6Fnl+u qTH2hjEQAH1IHGxcBlMy4rferrC4/6kbH6WSWAtUJZvO+RVYHQWeGjBL/ A==; X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="178942567" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Sep 2022 07:22:37 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Sep 2022 07:22:36 -0700 Received: from daire-X570.emdalo.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Sep 2022 07:22:33 -0700 From: To: , , , , , , , , , , , , CC: , , , , "Daire McNamara" Subject: [PATCH v1 3/4] PCI: microchip: add fabric address translation properties Date: Fri, 2 Sep 2022 15:22:01 +0100 Message-ID: <20220902142202.2437658-4-daire.mcnamara@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902142202.2437658-1-daire.mcnamara@microchip.com> References: <20220902142202.2437658-1-daire.mcnamara@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220902_072238_246756_A3A6421A X-CRM114-Status: GOOD ( 15.84 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Daire McNamara On PolarFire SoC both in- & out-bound address translations occur in two stages. The specific translations are tightly coupled to the FPGA designs and supplement the {dma-,}ranges properties. The first stage of the translation is done by the FPGA fabric & the second by the root port. Use outbound address translation information so that the translation tables in the root port's bridge layer can be configured to account for any translation done by the FPGA fabric, for example, on Icicle Kit reference design. Signed-off-by: Daire McNamara --- drivers/pci/controller/pcie-microchip-host.c | 59 +++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c index 7263d175b5ad..d78745eaa4b4 100644 --- a/drivers/pci/controller/pcie-microchip-host.c +++ b/drivers/pci/controller/pcie-microchip-host.c @@ -269,6 +269,8 @@ struct mc_pcie { struct irq_domain *event_domain; raw_spinlock_t lock; struct mc_msi msi; + u32 num_outbound_ranges; + u64 outbound_range_adjustments[32]; }; struct cause { @@ -964,6 +966,37 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } +static void mc_pcie_parse_outbound_range_adjustments(struct mc_pcie *port, struct device_node *np) +{ + const __be32 *range; + int range_len, num_ranges, range_size, i; + + range = of_get_property(np, "microchip,outbound-fabric-translation-ranges", &range_len); + if (!range) + return; + + num_ranges = of_n_addr_cells(np); + range_size = range_len / sizeof(__be32) / num_ranges; + + for (i = 0; i < num_ranges; i++, range += range_size) { + u64 pcieaddr = of_read_number(range + 1, 2); + u64 cpuaddr = of_read_number(range + 3, 2); + + port->outbound_range_adjustments[i] = cpuaddr - pcieaddr; + port->num_outbound_ranges++; + } +} + +static inline u64 mc_pcie_adjust_axi(struct mc_pcie *port, int index, u64 axi_addr) +{ + u64 offset = 0; + + if (index < port->num_outbound_ranges) + offset = port->outbound_range_adjustments[index]; + + return axi_addr - offset; +} + static int mc_pcie_setup_windows(struct platform_device *pdev, struct mc_pcie *port) { @@ -971,14 +1004,28 @@ static int mc_pcie_setup_windows(struct platform_device *pdev, port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; + u64 axi_addr; u64 pci_addr; - u32 index = 1; + u32 index = 0; + u32 num_outbound_ranges = 0; + + resource_list_for_each_entry(entry, &bridge->windows) { + if (resource_type(entry->res) == IORESOURCE_MEM || resource_type(entry->res) == 0) + num_outbound_ranges++; + } + + if (port->num_outbound_ranges && port->num_outbound_ranges != num_outbound_ranges) { + dev_err(&pdev->dev, "Mismatches in outbound range adjustment\n"); + return -EINVAL; + } resource_list_for_each_entry(entry, &bridge->windows) { - if (resource_type(entry->res) == IORESOURCE_MEM) { + if (resource_type(entry->res) == IORESOURCE_MEM || resource_type(entry->res) == 0) { + axi_addr = entry->res->start; + axi_addr = mc_pcie_adjust_axi(port, index, axi_addr); pci_addr = entry->res->start - entry->offset; mc_pcie_setup_window(bridge_base_addr, index, - entry->res->start, pci_addr, + axi_addr, pci_addr, resource_size(entry->res)); index++; } @@ -1005,6 +1052,8 @@ static int mc_platform_init(struct pci_config_window *cfg) return -ENOMEM; port->dev = dev; + mc_pcie_parse_outbound_range_adjustments(port, dev->of_node); + ret = mc_pcie_init_clks(dev); if (ret) { dev_err(dev, "failed to get clock resources, error %d\n", ret); @@ -1099,10 +1148,6 @@ static int mc_platform_init(struct pci_config_window *cfg) writel_relaxed(0, bridge_base_addr + IMASK_HOST); writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); - /* Configure Address Translation Table 0 for PCIe config space */ - mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start & 0xffffffff, - cfg->res.start, resource_size(&cfg->res)); - return mc_pcie_setup_windows(pdev, port); } From patchwork Fri Sep 2 14:22:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daire McNamara X-Patchwork-Id: 12964278 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 0AA03ECAAD5 for ; Fri, 2 Sep 2022 14:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XP63qgElCMKdGMxwHbyiiHHU/JsMxQXQ0Hpos1hAUrE=; b=RVi1fMkDeKKUo7 rtwLiP/NoJl6KHn4vgUBZDsJ4auNJEA1AxizckSCmqxq2p1LEZSi8pN+oG8TfaqnYi6YWprVUSQPK +7TzqLCfAxYdU4WdP4WedJKaIIW6zQPRJl4C58lh0qETIY0kN9SjE18yaz43U7CS9wWq67Uj50ckw O3sqM9AB00djHkj6tuvJ3bECues7ju90g59g1gehcavN/LjC+V3lISs1zNsTBl/aN0o3f68o/Os/4 1aCaNX6FKJn6U7ir/vFnjnuMUvs6CkuUv3c7zuFA6NTc3y0N9fNBYUOLZLplRar7b6IdMbSqyQ2/b 18xrzEe+e8JzAAqQxPaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7ZH-005Vw7-Ks; Fri, 02 Sep 2022 14:22:47 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7ZF-005Vr3-1Y for linux-riscv@lists.infradead.org; Fri, 02 Sep 2022 14:22:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1662128565; x=1693664565; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R3HtVnqEsyT5IIIglu00zj/GyzVDepT1pc5XEOwby8Y=; b=o07NoKWN2AlBJbBISl+HniGD/Uumaf/aJn0/yXj+fpAS8dZIBN+FQpDU fK7c62sqXgTD2wCm/ipfbNKj3YjGeFBOSA3CyvtMeaZB019KWQTL+1DaA dkEoVF/734dtBo8uj8/5o0wa5dwgQ0j6uo5GSXdVuToMMAEF1LEAMpIx4 32J1hGjnclqoGvtEa3wCTW8siZn7tFfxcGwMn1L6Ak8RRdWNvUhA7aW9q b/7ieoOoMOfVzWo//AY2tVqbSav+QCtfB3Mn+Mbu2rQkB5nFveL0eBvBX J19ANzihAeGU2piksrBR6Xe8Kg3cbnaj+aR1Ns05BGZBS8PyeQM59ogq6 g==; X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="175388545" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Sep 2022 07:22:44 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Sep 2022 07:22:43 -0700 Received: from daire-X570.emdalo.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 2 Sep 2022 07:22:39 -0700 From: To: , , , , , , , , , , , , CC: , , , , "Daire McNamara" Subject: [PATCH v1 4/4] of: PCI: tidy up logging of ranges containing configuration space type Date: Fri, 2 Sep 2022 15:22:02 +0100 Message-ID: <20220902142202.2437658-5-daire.mcnamara@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902142202.2437658-1-daire.mcnamara@microchip.com> References: <20220902142202.2437658-1-daire.mcnamara@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220902_072245_177316_081D678B X-CRM114-Status: UNSURE ( 7.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Daire McNamara PCI ranges can contain addresses where phys.high part can have a type of 0, signifying 'configuration space'. Change devm_of_pci_get_host_bridge_resources() to print 'CFG' instead of 'err' for a PCI range containing such a 'configuration space' type. Signed-off-by: Daire McNamara --- drivers/pci/of.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 196834ed44fe..d782ad8c7dce 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -319,6 +319,8 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev, range_type = "IO"; else if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM) range_type = "MEM"; + else if ((range.flags & IORESOURCE_TYPE_BITS) == 0) + range_type = "CFG"; else range_type = "err"; dev_info(dev, " %6s %#012llx..%#012llx -> %#012llx\n",