Skip to content

Commit cf342cb

Browse files
Marc Zyngiergregkh
authored andcommitted
PCI: xgene: Revert "PCI: xgene: Use inbound resources for setup"
commit 1874b6d upstream. Commit 6dce5aa ("PCI: xgene: Use inbound resources for setup") killed PCIe on my XGene-1 box (a Mustang board). The machine itself is still alive, but half of its storage (over NVMe) is gone, and the NVMe driver just times out. Note that this machine boots with a device tree provided by the UEFI firmware (2016 vintage), which could well be non conformant with the spec, hence the breakage. With the patch reverted, the box boots 5.17-rc8 with flying colors. Link: https://lore.kernel.org/all/Yf2wTLjmcRj+AbDv@xps13.dannf Link: https://lore.kernel.org/r/20220321104843.949645-2-maz@kernel.org Fixes: 6dce5aa ("PCI: xgene: Use inbound resources for setup") Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: stable@vger.kernel.org Cc: Rob Herring <robh@kernel.org> Cc: Toan Le <toan@os.amperecomputing.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Krzysztof Wilczyński <kw@linux.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Stéphane Graber <stgraber@ubuntu.com> Cc: dann frazier <dann.frazier@canonical.com> [dannf: minor context adjustment] Signed-off-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a25864c commit cf342cb

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

drivers/pci/controller/pci-xgene.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,28 +481,27 @@ static int xgene_pcie_select_ib_reg(u8 *ib_reg_mask, u64 size)
481481
}
482482

483483
static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port,
484-
struct resource_entry *entry,
485-
u8 *ib_reg_mask)
484+
struct of_pci_range *range, u8 *ib_reg_mask)
486485
{
487486
void __iomem *cfg_base = port->cfg_base;
488487
struct device *dev = port->dev;
489488
void *bar_addr;
490489
u32 pim_reg;
491-
u64 cpu_addr = entry->res->start;
492-
u64 pci_addr = cpu_addr - entry->offset;
493-
u64 size = resource_size(entry->res);
490+
u64 cpu_addr = range->cpu_addr;
491+
u64 pci_addr = range->pci_addr;
492+
u64 size = range->size;
494493
u64 mask = ~(size - 1) | EN_REG;
495494
u32 flags = PCI_BASE_ADDRESS_MEM_TYPE_64;
496495
u32 bar_low;
497496
int region;
498497

499-
region = xgene_pcie_select_ib_reg(ib_reg_mask, size);
498+
region = xgene_pcie_select_ib_reg(ib_reg_mask, range->size);
500499
if (region < 0) {
501500
dev_warn(dev, "invalid pcie dma-range config\n");
502501
return;
503502
}
504503

505-
if (entry->res->flags & IORESOURCE_PREFETCH)
504+
if (range->flags & IORESOURCE_PREFETCH)
506505
flags |= PCI_BASE_ADDRESS_MEM_PREFETCH;
507506

508507
bar_low = pcie_bar_low_val((u32)cpu_addr, flags);
@@ -533,13 +532,25 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port,
533532

534533
static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port)
535534
{
536-
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port);
537-
struct resource_entry *entry;
535+
struct device_node *np = port->node;
536+
struct of_pci_range range;
537+
struct of_pci_range_parser parser;
538+
struct device *dev = port->dev;
538539
u8 ib_reg_mask = 0;
539540

540-
resource_list_for_each_entry(entry, &bridge->dma_ranges)
541-
xgene_pcie_setup_ib_reg(port, entry, &ib_reg_mask);
541+
if (of_pci_dma_range_parser_init(&parser, np)) {
542+
dev_err(dev, "missing dma-ranges property\n");
543+
return -EINVAL;
544+
}
545+
546+
/* Get the dma-ranges from DT */
547+
for_each_of_pci_range(&parser, &range) {
548+
u64 end = range.cpu_addr + range.size - 1;
542549

550+
dev_dbg(dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n",
551+
range.flags, range.cpu_addr, end, range.pci_addr);
552+
xgene_pcie_setup_ib_reg(port, &range, &ib_reg_mask);
553+
}
543554
return 0;
544555
}
545556

0 commit comments

Comments
 (0)