2930cf3
From patchwork Sat Sep 23 06:17:40 2017
2930cf3
Content-Type: text/plain; charset="utf-8"
2930cf3
MIME-Version: 1.0
2930cf3
Content-Transfer-Encoding: 7bit
2930cf3
Subject: PCI: tegra: Use different MSI target address for Tegra20
2930cf3
From: Thierry Reding <thierry.reding@gmail.com>
2930cf3
X-Patchwork-Id: 9967397
2930cf3
Message-Id: <20170923061740.6012-1-treding@nvidia.com>
2930cf3
To: Bjorn Helgaas <bhelgaas@google.com>
2930cf3
Cc: Thierry Reding <thierry.reding@gmail.com>,
2930cf3
 Jonathan Hunter <jonathanh@nvidia.com>,
2930cf3
 linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org
2930cf3
Date: Fri, 22 Sep 2017 23:17:40 -0700
2930cf3
2930cf3
The Tegra20 PCIe controller has a different address range for MSI, so
2930cf3
select a different target address.
2930cf3
2930cf3
Fixes: d7bd554f27c9 ("PCI: tegra: Do not allocate MSI target memory")
2930cf3
Signed-off-by: Thierry Reding <treding@nvidia.com>
2930cf3
---
2930cf3
 drivers/pci/host/pci-tegra.c | 12 +++++++++++-
2930cf3
 1 file changed, 11 insertions(+), 1 deletion(-)
2930cf3
2930cf3
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
2930cf3
index e8e1ddbaabc9..5b02ea59524b 100644
2930cf3
--- a/drivers/pci/host/pci-tegra.c
2930cf3
+++ b/drivers/pci/host/pci-tegra.c
2930cf3
@@ -1563,8 +1563,18 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie)
2930cf3
 	 * none of the Tegra SoCs that contain this PCI host bridge can
2930cf3
 	 * address more than 16 GiB of system memory, the last 4 KiB of
2930cf3
 	 * these 1012 GiB is a good candidate.
2930cf3
+	 *
2930cf3
+	 * Unfortunately, Tegra20 is slightly different in that the physical
2930cf3
+	 * address for this MSI region is limited to the lower 32 bits of the
2930cf3
+	 * address map, so the address that we pick is going to have to be
2930cf3
+	 * located somewhere within the region addressable by the CPU and
2930cf3
+	 * on-SoC controllers. To be on the safe side, we select an address
2930cf3
+	 * from a region that is marked unused (0xf0010000 - 0xfffeffff).
2930cf3
 	 */
2930cf3
-	msi->phys = 0xfcfffff000;
2930cf3
+	if (soc->msi_base_shift > 0)
2930cf3
+		msi->phys = 0xfcfffff000;
2930cf3
+	else
2930cf3
+		msi->phys = 0x00f0010000;
2930cf3
 
2930cf3
 	afi_writel(pcie, msi->phys >> soc->msi_base_shift, AFI_MSI_FPCI_BAR_ST);
2930cf3
 	afi_writel(pcie, msi->phys, AFI_MSI_AXI_BAR_ST);