Skip to content

Commit 42f9c66

Browse files
floatiousbjorn-helgaas
authored andcommitted
PCI: tegra194: Reset BARs when running in PCIe endpoint mode
Tegra already defines all BARs except BAR0 as BAR_RESERVED. This is sufficient for pci-epf-test to not allocate backing memory and to not call set_bar() for those BARs. However, marking a BAR as BAR_RESERVED does not mean that the BAR gets disabled. The host side driver, pci_endpoint_test, simply does an ioremap for all enabled BARs and will run tests against all enabled BARs, so it will run tests against the BARs marked as BAR_RESERVED. After running the BAR tests (which will write to all enabled BARs), the inbound address translation is broken. This is because the tegra controller exposes the ATU Port Logic Structure in BAR4, so when BAR4 is written, the inbound address translation settings get overwritten. To avoid this, implement the dw_pcie_ep_ops .init() callback and start off by disabling all BARs (pci-epf-test will later enable/configure BARs that are not defined as BAR_RESERVED). This matches the behavior of other PCIe endpoint drivers: dra7xx, imx6, layerscape-ep, artpec6, dw-rockchip, qcom-ep, rcar-gen4, and uniphier-ep. With this, the PCI endpoint kselftest test case CONSECUTIVE_BAR_TEST (which was specifically made to detect address translation issues) passes. Fixes: c57247f ("PCI: tegra: Add support for PCIe endpoint mode in Tegra194") Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected]
1 parent 82f1cc1 commit 42f9c66

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,15 @@ static irqreturn_t tegra_pcie_ep_pex_rst_irq(int irq, void *arg)
19411941
return IRQ_HANDLED;
19421942
}
19431943

1944+
static void tegra_pcie_ep_init(struct dw_pcie_ep *ep)
1945+
{
1946+
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
1947+
enum pci_barno bar;
1948+
1949+
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++)
1950+
dw_pcie_ep_reset_bar(pci, bar);
1951+
};
1952+
19441953
static int tegra_pcie_ep_raise_intx_irq(struct tegra_pcie_dw *pcie, u16 irq)
19451954
{
19461955
/* Tegra194 supports only INTA */
@@ -2016,6 +2025,7 @@ tegra_pcie_ep_get_features(struct dw_pcie_ep *ep)
20162025
}
20172026

20182027
static const struct dw_pcie_ep_ops pcie_ep_ops = {
2028+
.init = tegra_pcie_ep_init,
20192029
.raise_irq = tegra_pcie_ep_raise_irq,
20202030
.get_features = tegra_pcie_ep_get_features,
20212031
};

0 commit comments

Comments
 (0)