Skip to contentSkip to conversation

PCI: xgene: Restore working PCIe functionnality

PATCH Applied Marc Zyngier 6 participants 20 messages Mar 21, 2022 – Mar 22, 2022

Subsystems (6)
lore
Share & tools
lore
#2 lore raw

PATCH v2 2/2 PCI: xgene: Revert "PCI: xgene: Fix IB window setup"

In reply to Marc Zyngier

Commit c7a75d07827a ("PCI: xgene: Fix IB window setup") tried to fix the damages that 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") caused, but actually didn't improve anything for some plarforms (at least Mustang and m400 are still broken).

Given that 6dce5aa59e0b has been reverted, revert this patch as well, restoring the PCIe support on XGene to its pre-5.5, working state.

Cc Rob Herring <[email protected]>
Cc Toan Le <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Krzysztof Wilczyński <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Stéphane Graber <[email protected]>
Cc dann frazier <[email protected]>
Fixes c7a75d07827a ("PCI: xgene: Fix IB window setup")
---
 drivers/pci/controller/pci-xgene.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-xgene.c +1 -1
index aa41ceaf031f..7c763d820c52 100644
@@ -465,7 +465,7 @@ static int xgene_pcie_select_ib_reg(u8 *ib_reg_mask, u64 size)
 		return 1;
 	}
 
-	if ((size > SZ_1K) && (size < SZ_4G) && !(*ib_reg_mask & (1 << 0))) {
+	if ((size > SZ_1K) && (size < SZ_1T) && !(*ib_reg_mask & (1 << 0))) {
 		*ib_reg_mask |= (1 << 0);
 		return 0;
 	}
Signature · 1 line
2.34.1
#0 lore raw

v2 cover PCI: xgene: Restore working PCIe functionnality

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

Given that, revert both changes and let people enjoy their XGene boxes once again.

* From v1 [1]:
- Also revert c7a75d07827a ("PCI: xgene: Fix IB window setup")

[1] https://lore.kernel.org/r/[email protected]

Marc Zyngier (2):
PCI: xgene: Revert "PCI: xgene: Use inbound resources for setup"
PCI: xgene: Revert "PCI: xgene: Fix IB window setup"

 drivers/pci/controller/pci-xgene.c | 35 ++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 12 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/2 PCI: xgene: Revert "PCI: xgene: Use inbound resources for setup"

Commit 6dce5aa59e0b ("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.

Cc Rob Herring <[email protected]>
Cc Toan Le <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Krzysztof Wilczyński <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Stéphane Graber <[email protected]>
Cc dann frazier <[email protected]>
Fixes 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup")
---
 drivers/pci/controller/pci-xgene.c | 33 ++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/pci/controller/pci-xgene.c +22 -11
index 0d5acbfc7143..aa41ceaf031f 100644
@@ -479,28 +479,27 @@ static int xgene_pcie_select_ib_reg(u8 *ib_reg_mask, u64 size)
 }
 
 static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port,
-				    struct resource_entry *entry,
-				    u8 *ib_reg_mask)
+				    struct of_pci_range *range, u8 *ib_reg_mask)
 {
 	void __iomem *cfg_base = port->cfg_base;
 	struct device *dev = port->dev;
 	void __iomem *bar_addr;
 	u32 pim_reg;
-	u64 cpu_addr = entry->res->start;
-	u64 pci_addr = cpu_addr - entry->offset;
-	u64 size = resource_size(entry->res);
+	u64 cpu_addr = range->cpu_addr;
+	u64 pci_addr = range->pci_addr;
+	u64 size = range->size;
 	u64 mask = ~(size - 1) | EN_REG;
 	u32 flags = PCI_BASE_ADDRESS_MEM_TYPE_64;
 	u32 bar_low;
 	int region;
 
-	region = xgene_pcie_select_ib_reg(ib_reg_mask, size);
+	region = xgene_pcie_select_ib_reg(ib_reg_mask, range->size);
 	if (region < 0) {
 		dev_warn(dev, "invalid pcie dma-range config\n");
 		return;
 	}
 
-	if (entry->res->flags & IORESOURCE_PREFETCH)
+	if (range->flags & IORESOURCE_PREFETCH)
 		flags |= PCI_BASE_ADDRESS_MEM_PREFETCH;
 
 	bar_low = pcie_bar_low_val((u32)cpu_addr, flags);
@@ -531,13 +530,25 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port,
 
 static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie *port)
 {
-	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port);
-	struct resource_entry *entry;
+	struct device_node *np = port->node;
+	struct of_pci_range range;
+	struct of_pci_range_parser parser;
+	struct device *dev = port->dev;
 	u8 ib_reg_mask = 0;
 
-	resource_list_for_each_entry(entry, &bridge->dma_ranges)
-		xgene_pcie_setup_ib_reg(port, entry, &ib_reg_mask);
+	if (of_pci_dma_range_parser_init(&parser, np)) {
+		dev_err(dev, "missing dma-ranges property\n");
+		return -EINVAL;
+	}
+
+	/* Get the dma-ranges from DT */
+	for_each_of_pci_range(&parser, &range) {
+		u64 end = range.cpu_addr + range.size - 1;
 
+		dev_dbg(dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n",
+			range.flags, range.cpu_addr, end, range.pci_addr);
+		xgene_pcie_setup_ib_reg(port, &range, &ib_reg_mask);
+	}
 	return 0;
 }
 
Signature · 1 line
2.34.1
#3 lore raw
In reply to Marc Zyngier
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

[...]

Applied to pci/xgene, thanks!

[1/2] PCI: xgene: Revert "PCI: xgene: Use inbound resources for setup"

      https://git.kernel.org/lpieralisi/pci/c/1874b6d7ab
[2/2] PCI: xgene: Revert "PCI: xgene: Fix IB window setup"
      https://git.kernel.org/lpieralisi/pci/c/825da4e9ce

Thanks,
Lorenzo

reviewer
#4 lore raw
In reply to Marc Zyngier
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map). Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Rob

P.S. We're carrying ACPI and DT support for these platforms. It seems the few users are using DT, so can we drop the ACPI support? Or do I need to break it first and wait a year? ;)

#5 lore raw
Quoted 33 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map). Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
Quoted 8 lines

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases.

Happy to provide that for the m400 if told how :)

-dann

Quoted 4 lines

I'm not
saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

reviewer
#6 lore raw
Quoted 36 lines · dann frazier
Quoted 35 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map). Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

Quoted 8 lines
Quoted 6 lines

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases.

Happy to provide that for the m400 if told how :)

Something like the below patch. This should be with the 'dma-ranges' DT change and only c7a75d07827a reverted.

8<-------------------------------------------------------------------

drivers/pci/controller/pci-xgene.c +3 -0
index 0d5acbfc7143..6a435c31f45e 100644
@@ -78,6 +78,7 @@ static u32 xgene_pcie_readl(struct xgene_pcie *port, u32 reg)
 
 static void xgene_pcie_writel(struct xgene_pcie *port, u32 reg, u32 val)
 {
+	dev_info(port->dev, "0x%04x <- 0x%08x\n", reg, val);
 	writel(val, port->csr_base + reg);
 }
 
@@ -508,7 +509,9 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port,
 	case 0:
 		xgene_pcie_set_ib_mask(port, BRIDGE_CFG_4, flags, size);
 		bar_addr = cfg_base + PCI_BASE_ADDRESS_0;
+		dev_info(port->dev, "BAR0L <- 0x%08x\n", bar_low);
 		writel(bar_low, bar_addr);
+		dev_info(port->dev, "BAR0H <- 0x%08x\n", upper_32_bits(cpu_addr));
 		writel(upper_32_bits(cpu_addr), bar_addr + 0x4);
 		pim_reg = PIM1_1L;
 		break;
#10 lore raw
In reply to Rob Herring
Quoted 16 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

Quoted 3 lines

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map).

We have, and we added the required exceptions for the legacy platforms that the code base supported until then. We didn't leave things broken just because we didn't like the way things were done a long time ago.

Quoted 20 lines

Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

Quoted 6 lines

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Reverting 6dce5aa59e0b was enough for me, without changing anything else. m400 probably uses an even older firmware (AFAIR, it was stuck with an ancient version of u-boot that HP never updated, while Mustang had a few updates). In any case, that DT cannot be changed.

Quoted 6 lines

Rob

P.S. We're carrying ACPI and DT support for these platforms. It seems the few users are using DT, so can we drop the ACPI support? Or do I need to break it first and wait a year? ;)

I'm not sure people on the list are representative of all the users, and I didn't realise the plan was "let's break everything we don't like and see if someone wakes up" either. That definitely puts things in a different perspective.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
reviewer
#11 lore raw
Quoted 54 lines · Marc Zyngier
Quoted 16 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

Quoted 3 lines

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map).

We have, and we added the required exceptions for the legacy platforms that the code base supported until then. We didn't leave things broken just because we didn't like the way things were done a long time ago.

Quoted 20 lines

Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

Quoted 6 lines

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Quoted 2 lines

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Can you tell me what 'dma-ranges' contains on your system?

Quoted 3 lines

m400 probably uses an even older firmware (AFAIR, it was stuck with an ancient version of u-boot that HP never updated, while Mustang had a few updates). In any case, that DT cannot be changed.

How is Dann changing it then? I assume he's not changing the firmware, but overriding it. That could be a possible solution.

Do the DT's in the kernel tree correspond to anything anyone is using? I ask because at some point someone will need to address all the warnings they have or we should drop the dts files if they aren't close to reality. The same thing applies to Seattle BTW.

Quoted 10 lines
Quoted 5 lines

Rob

P.S. We're carrying ACPI and DT support for these platforms. It seems the few users are using DT, so can we drop the ACPI support? Or do I need to break it first and wait a year? ;)

I'm not sure people on the list are representative of all the users, and I didn't realise the plan was "let's break everything we don't like and see if someone wakes up" either. That definitely puts things in a different perspective.

I wasn't really suggesting breaking things on purpose. However, there is a cost to keeping code and it would be nice to know what's being used or not. The cost isn't *that* big, but it is not zero for what's not many users.

At least for Stéphane, using ACPI didn't even work. I'm assuming there is some version of h/w and f/w out there that did work with the ACPI support in the kernel? That may have never been seen by anyone but APM and Jon Masters (his Tested-by is on the patch from APM adding ACPI support). It's not hard to imagine there was a version of firmware just to shut Jon up.

Rob

#12 lore raw
Quoted 15 lines · Rob Herring
Quoted 13 lines · Marc Zyngier
Quoted 9 lines · Rob Herring
Quoted 1 line · Marc Zyngier

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Quoted 6 lines
Quoted 2 lines

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Can you tell me what 'dma-ranges' contains on your system?

Each pcie node (all 5 of them) has:

dma-ranges = <0x42000000 0x80 0x00 0x80 0x00 0x00 0x80000000

              0x42000000 0x00 0x00 0x00 0x00 0x80 0x00>;
Quoted 7 lines
Quoted 4 lines

m400 probably uses an even older firmware (AFAIR, it was stuck with an ancient version of u-boot that HP never updated, while Mustang had a few updates). In any case, that DT cannot be changed.

How is Dann changing it then? I assume he's not changing the firmware, but overriding it. That could be a possible solution.

I don't know about you, but changing DT is not an acceptable solution for me. If I'm bisecting something and have to pick the right DT based on the kernel revision I'm using, that's a huge regression. And I'm not even mentioning the poor sod who simply updates their distro, only to find that the box doesn't boot anymore thanks to a kernel upgrade.

We're not talking about a closed embedded device here, but a fully functional desktop/server box that still run rings around your average RPi.

Quoted 4 lines

Do the DT's in the kernel tree correspond to anything anyone is using? I ask because at some point someone will need to address all the warnings they have or we should drop the dts files if they aren't close to reality. The same thing applies to Seattle BTW.

I'd be perfectly happy to see both of these go. The last time I used the kernel DT on my Seattle was some time in 2015, at which point I got a firmware correctly describing the SMMUs. Oh, and ACPI works just fine on Seattle.

Quoted 14 lines
Quoted 8 lines
Quoted 3 lines

P.S. We're carrying ACPI and DT support for these platforms. It seems the few users are using DT, so can we drop the ACPI support? Or do I need to break it first and wait a year? ;)

I'm not sure people on the list are representative of all the users, and I didn't realise the plan was "let's break everything we don't like and see if someone wakes up" either. That definitely puts things in a different perspective.

I wasn't really suggesting breaking things on purpose. However, there is a cost to keeping code and it would be nice to know what's being used or not. The cost isn't *that* big, but it is not zero for what's not many users.

Quoted 6 lines

At least for Stéphane, using ACPI didn't even work. I'm assuming there is some version of h/w and f/w out there that did work with the ACPI support in the kernel? That may have never been seen by anyone but APM and Jon Masters (his Tested-by is on the patch from APM adding ACPI support). It's not hard to imagine there was a version of firmware just to shut Jon up.

Well, you can ask Jon. ACPI doesn't work on my box as it doesn't (properly) describe a console, but my FW is rather old, as explained in the release notes:

Version 3.06.25 (10/17/2016)
Mustang Tianocore (UEFI BIOS) Firmware Features:
- TianoCore tag linaro-edk2-2014.07 with custom changes

Yes, 2014. Good vintage. But is that the latest and greatest? I have no idea, and the APM website is long gone.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
maintainer
#13 lore raw
Quoted 20 lines · Marc Zyngier
Quoted 18 lines · Rob Herring
Quoted 15 lines · Marc Zyngier
Quoted 9 lines · Rob Herring
Quoted 1 line · Marc Zyngier

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Quoted 8 lines
Quoted 3 lines

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Can you tell me what 'dma-ranges' contains on your system?

Each pcie node (all 5 of them) has:

dma-ranges = <0x42000000 0x80 0x00 0x80 0x00 0x00 0x80000000

               0x42000000 0x00 0x00 0x00 0x00 0x80 0x00>;

Hmm, is there anyone other than iommu-dma who actually depends on the resource list being sorted in ascending order of bus address? I recall at the time I pushed for creating the list in sorted order as it was the simplest and most efficient option, but there's no technical reason we couldn't create it in as-found order and defer the sorting until iova_reserve_pci_windows() (at worst that could even operate on a temporary copy if need be). It's just more code, which didn't need to exist without a good reason, but if this is one then exist it certainly may.

Cheers,
Robin.

#18 lore raw
In reply to Rob Herring
Quoted 60 lines · Rob Herring
Quoted 54 lines · Marc Zyngier
Quoted 16 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

Quoted 3 lines

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map).

We have, and we added the required exceptions for the legacy platforms that the code base supported until then. We didn't leave things broken just because we didn't like the way things were done a long time ago.

Quoted 20 lines

Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

Quoted 6 lines

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Quoted 2 lines

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Quoted 8 lines

Can you tell me what 'dma-ranges' contains on your system?

Quoted 3 lines

m400 probably uses an even older firmware (AFAIR, it was stuck with an ancient version of u-boot that HP never updated, while Mustang had a few updates). In any case, that DT cannot be changed.

How is Dann changing it then? I assume he's not changing the firmware, but overriding it. That could be a possible solution.

Correct, I'm just overriding it for testing. I'm using the pxelinux emulation provided by the m400's u-boot, which supports an FDT field:

---------

$ cat /srv/tftp/pxelinux.cfg/default
DEFAULT default

LABEL default
KERNEL uImage
APPEND initrd=uInitrd console=ttyS0,9600n8r ro root=LABEL=cloudimg-rootfs FDT m400.dtb
---------

This loads the specified file into ${fdt_addr_r}, overriding the blob that the firmware had already loaded there.

Quoted 2 lines

Do the DT's in the kernel tree correspond to anything anyone is using?

Upstream apm-mustang.dtb is what Ubuntu uses for Mustang boards w/ u-boot firmware. That used to work fine, but I haven't tried lately.

-dann

#7 lore raw
In reply to Rob Herring
Quoted 40 lines · Rob Herring
Quoted 39 lines · dann frazier
Quoted 38 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map). Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases.

Happy to provide that for the m400 if told how :)

Something like the below patch. This should be with the 'dma-ranges' DT change and only c7a75d07827a reverted.

https://paste.ubuntu.com/p/RHzBd5jT6v/

Note that networking does come up with this setup. That surprised me because I thought I'd tested this combo before, but apparently what I'd tested before was 6dce5aa59e0b reverted + the dtb change:
https://lore.kernel.org/linux-pci/[email protected]/

-dann

Quoted 14 lines

8<-------------------------------------------------------------------

drivers/pci/controller/pci-xgene.c +1 -0
index 0d5acbfc7143..6a435c31f45e 100644
@@ -78,6 +78,7 @@ static u32 xgene_pcie_readl(struct xgene_pcie *port, u32 reg)
 
 static void xgene_pcie_writel(struct xgene_pcie *port, u32 reg, u32 val)
 {
+	dev_info(port->dev, "0x%04x <- 0x%08x\n", reg, val);
 	writel(val, port->csr_base + reg);
 }
 

drivers/pci/controller/pci-xgene.c static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port, · line 517

Quoted 9 lines
drivers/pci/controller/pci-xgene.c +2 -0
@@ -508,7 +509,9 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port,
 	case 0:
 		xgene_pcie_set_ib_mask(port, BRIDGE_CFG_4, flags, size);
 		bar_addr = cfg_base + PCI_BASE_ADDRESS_0;
+		dev_info(port->dev, "BAR0L <- 0x%08x\n", bar_low);
 		writel(bar_low, bar_addr);
+		dev_info(port->dev, "BAR0H <- 0x%08x\n", upper_32_bits(cpu_addr));
 		writel(upper_32_bits(cpu_addr), bar_addr + 0x4);
 		pim_reg = PIM1_1L;
 		break;

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#14 lore raw
In reply to Robin Murphy
Quoted 23 lines · Robin Murphy
Quoted 22 lines · Marc Zyngier
Quoted 20 lines · Rob Herring
Quoted 13 lines · Marc Zyngier
Quoted 9 lines · Rob Herring
Quoted 1 line · Marc Zyngier

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Quoted 2 lines

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Can you tell me what 'dma-ranges' contains on your system?

Each pcie node (all 5 of them) has:

dma-ranges = <0x42000000 0x80 0x00 0x80 0x00 0x00 0x80000000 0x42000000 0x00 0x00 0x00 0x00 0x80 0x00>;

Hmm, is there anyone other than iommu-dma who actually depends on the resource list being sorted in ascending order of bus address? I recall at the time I pushed for creating the list in sorted order as it was the simplest and most efficient option, but there's no technical reason we couldn't create it in as-found order and defer the sorting until iova_reserve_pci_windows() (at worst that could even operate on a temporary copy if need be). It's just more code, which didn't need to exist without a good reason, but if this is one then exist it certainly may.

Taking a closer look, the Cadence driver is already re-sorting the list for its own setup, so iommu-dma can't assume the initial sort is preserved and needs to do its own anyway. Does the (untested) diff below end up helping X-Gene also?

Robin.

----->8-----

drivers/iommu/dma-iommu.c +10 -0
index b22034975301..8ef603c9ca3e 100644
@@ -20,6 +20,7 @@
 #include <linux/iommu.h>
 #include <linux/iova.h>
 #include <linux/irq.h>
+#include <linux/list_sort.h>
 #include <linux/mm.h>
 #include <linux/mutex.h>
 #include <linux/pci.h>
@@ -414,6 +415,14 @@ static int cookie_init_hw_msi_region(struct iommu_dma_cookie *cookie,
 	return 0;
 }
 
+static int iommu_dma_ranges_sort(void *priv, const struct list_head *a, const struct list_head *b)
+{
+	struct resource_entry *res_a = list_entry(a, typeof(*res_a), node);
+	struct resource_entry *res_b = list_entry(b, typeof(*res_b), node);
+
+	return res_a->res->start > res_b->res->start;
+}
+
 static int iova_reserve_pci_windows(struct pci_dev *dev,
 		struct iova_domain *iovad)
 {
@@ -432,6 +441,7 @@ static int iova_reserve_pci_windows(struct pci_dev *dev,
 	}
 
 	/* Get reserved DMA windows from host bridge */
+	list_sort(NULL, &bridge->dma_ranges, iommu_dma_ranges_sort);
 	resource_list_for_each_entry(window, &bridge->dma_ranges) {
 		end = window->res->start - window->offset;
 resv_iova:
drivers/pci/of.c +1 -6
index cb2e8351c2cc..d176b4bc6193 100644
@@ -393,12 +393,7 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev,
 			goto failed;
 		}
 
-		/* Keep the resource list sorted */
-		resource_list_for_each_entry(entry, ib_resources)
-			if (entry->res->start > res->start)
-				break;
-
-		pci_add_resource_offset(&entry->node, res,
+		pci_add_resource_offset(ib_resources, res,
 					res->start - range.pci_addr);
 	}
 
reviewer
#15 lore raw
Quoted 22 lines · Robin Murphy
Quoted 21 lines · Robin Murphy
Quoted 20 lines · Marc Zyngier
Quoted 18 lines · Rob Herring
Quoted 15 lines · Marc Zyngier
Quoted 9 lines · Rob Herring
Quoted 1 line · Marc Zyngier

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Can you tell me what 'dma-ranges' contains on your system?

Each pcie node (all 5 of them) has:

dma-ranges = <0x42000000 0x80 0x00 0x80 0x00 0x00 0x80000000 0x42000000 0x00 0x00 0x00 0x00 0x80 0x00>;

This is the same as what Stéphane has for Merlin. So c7a75d07827a ("PCI:
xgene: Fix IB window setup") should have fixed Mustang.

Quoted 11 lines
Quoted 10 lines

Hmm, is there anyone other than iommu-dma who actually depends on the resource list being sorted in ascending order of bus address? I recall at the time I pushed for creating the list in sorted order as it was the simplest and most efficient option, but there's no technical reason we couldn't create it in as-found order and defer the sorting until iova_reserve_pci_windows() (at worst that could even operate on a temporary copy if need be). It's just more code, which didn't need to exist without a good reason, but if this is one then exist it certainly may.

Quoted 4 lines

Taking a closer look, the Cadence driver is already re-sorting the list for its own setup, so iommu-dma can't assume the initial sort is preserved and needs to do its own anyway. Does the (untested) diff below end up helping X-Gene also?

There's no IOMMU on X-Gene 1 or 2 based on the upstream dts files, so how would this matter?

Rob

maintainer
#16 lore raw
Quoted 27 lines · Rob Herring
Quoted 26 lines · Robin Murphy
Quoted 25 lines · Robin Murphy
Quoted 24 lines · Marc Zyngier
Quoted 21 lines · Rob Herring
Quoted 13 lines · Marc Zyngier
Quoted 9 lines · Rob Herring
Quoted 1 line · Marc Zyngier

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Quoted 2 lines

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Can you tell me what 'dma-ranges' contains on your system?

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Each pcie node (all 5 of them) has:

dma-ranges = <0x42000000 0x80 0x00 0x80 0x00 0x00 0x80000000 �������������� 0x42000000 0x00 0x00 0x00 0x00 0x80 0x00>;

This is the same as what St�phane has for Merlin. So c7a75d07827a ("PCI:
xgene: Fix IB window setup") should have fixed Mustang.

Unless XGene 1 has some weird implicit requirement on the order in which the registers are programmed, that XGene 2 doesn't. And from looking at the code, I don't see any obvious less-mad possibility to explain the breakage.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

Hmm, is there anyone other than iommu-dma who actually depends on the resource list being sorted in ascending order of bus address? I recall at the time I pushed for creating the list in sorted order as it was the simplest and most efficient option, but there's no technical reason we couldn't create it in as-found order and defer the sorting until iova_reserve_pci_windows() (at worst that could even operate on a temporary copy if need be). It's just more code, which didn't need to exist without a good reason, but if this is one then exist it certainly may.

Quoted 7 lines
Quoted 4 lines

Taking a closer look, the Cadence driver is already re-sorting the list for its own setup, so iommu-dma can't assume the initial sort is preserved and needs to do its own anyway. Does the (untested) diff below end up helping X-Gene also?

There's no IOMMU on X-Gene 1 or 2 based on the upstream dts files, so how would this matter?

Because devm_of_pci_get_host_bridge_resources() is forcing the dma_ranges list to be in a different order from the original DT for iommu-dma's benefit, but whether iommu-dma actually consumes it or not later is immaterial.

Robin.

#17 lore raw
In reply to Rob Herring
Quoted 28 lines · Rob Herring
Quoted 26 lines · Robin Murphy
Quoted 25 lines · Robin Murphy
Quoted 24 lines · Marc Zyngier
Quoted 21 lines · Rob Herring
Quoted 13 lines · Marc Zyngier
Quoted 9 lines · Rob Herring
Quoted 1 line · Marc Zyngier

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases. I'm not saying changing 'dma-ranges' in the firmware is going to be required here. There's a couple of other ways we could fix that without a firmware change, but first I need to understand why it broke.

Quoted 2 lines

Reverting 6dce5aa59e0b was enough for me, without changing anything else.

Meaning c7a75d07827a didn't matter for you. I'm not sure that it would.

Can you tell me what 'dma-ranges' contains on your system?

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Each pcie node (all 5 of them) has:

dma-ranges = <0x42000000 0x80 0x00 0x80 0x00 0x00 0x80000000 0x42000000 0x00 0x00 0x00 0x00 0x80 0x00>;

This is the same as what Stéphane has for Merlin. So c7a75d07827a ("PCI:
xgene: Fix IB window setup") should have fixed Mustang.

Should, but didn't. The DT also carries additional properties:

ib-ranges = <0x42000000 0x40 0x00 0x40 0x00 0x40 0x00

             0x00 0x00 0x79000000 0x00 0x79000000 0x00 0x800000>;

which the driver ignores, but that could be relevant. FWIW, I've stashed the DT at [1].

	M.

[1] http://www.loen.fr/tmp/mustang.dts

Signature · 1 line
Without deviation from the norm, progress is not possible.
reviewer
#8 lore raw
In reply to dann frazier
Quoted 50 lines · dann frazier
Quoted 40 lines · Rob Herring
Quoted 39 lines · dann frazier
Quoted 38 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map). Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases.

Happy to provide that for the m400 if told how :)

Something like the below patch. This should be with the 'dma-ranges' DT change and only c7a75d07827a reverted.

Quoted 6 lines

https://paste.ubuntu.com/p/RHzBd5jT6v/

Note that networking does come up with this setup. That surprised me because I thought I'd tested this combo before, but apparently what I'd tested before was 6dce5aa59e0b reverted + the dtb change:
https://lore.kernel.org/linux-pci/[email protected]/

That doesn't make sense. I just noticed there's an error in what I told you to do for dma-ranges. I fixed the wrong cell as it should be:

- dma-ranges = <0x42000000 0x40 0x00 0x40 0x00 0x40 0x00 0x00 0x00 0x79000000 0x00 0x79000000 0x00 0x800000>;
+ dma-ranges = <0x42000000 0x40 0x00 0x40 0x00 0x40 0x00 0x42000000 0x00 0x79000000 0x00 0x79000000 0x00 0x800000>;

Rob

#9 lore raw
Quoted 58 lines · Rob Herring
Quoted 50 lines · dann frazier
Quoted 40 lines · Rob Herring
Quoted 39 lines · dann frazier
Quoted 38 lines · Rob Herring
Quoted 8 lines · Marc Zyngier

Since 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") was merged in the 5.5 time frame, PCIe on the venerable XGene platform has been unusable: 6dce5aa59e0b broke both XGene-1 (Mustang and m400) and XGene-2 (Merlin), while the addition of c7a75d07827a ("PCI: xgene: Fix IB window setup") fixed XGene-2, but left the rest of the zoo unusable.

Quoted 5 lines

It is understood that this systems come with "creative" DTs that don't match the expectations of modern kernels. However, there is little to be gained by forcing these changes on users -- the firmware is not upgradable, and the current owner of the IP will deny that these machines have ever existed.

The gain for fixing this properly is not having drivers do their own dma-ranges parsing. We've seen what happens when drivers do their own parsing of standard properties (e.g. interrupt-map). Currently, we don't have any drivers doing their own parsing:

$ git grep of_pci_dma_range_parser_init
drivers/of/address.c:int of_pci_dma_range_parser_init(struct
of_pci_range_parser *parser,
drivers/of/address.c:EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
drivers/of/address.c:#define of_dma_range_parser_init
of_pci_dma_range_parser_init
drivers/of/unittest.c:  if (of_pci_dma_range_parser_init(&parser, np)) {
drivers/pci/of.c:       err = of_pci_dma_range_parser_init(&parser, dev_node);
include/linux/of_address.h:extern int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
include/linux/of_address.h:static inline int
of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,

And we can probably further refactor this to be private to drivers/pci/of.c.

For XGene-2 the issue is simply that the driver depends on the order of dma-ranges entries.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

For XGene-1, I'd still like to understand what the issue is. Reverting the first fix and fixing 'dma-ranges' should have fixed it. I need a dump of how the IB registers are initialized in both cases.

Happy to provide that for the m400 if told how :)

Something like the below patch. This should be with the 'dma-ranges' DT change and only c7a75d07827a reverted.

Quoted 6 lines

https://paste.ubuntu.com/p/RHzBd5jT6v/

Note that networking does come up with this setup. That surprised me because I thought I'd tested this combo before, but apparently what I'd tested before was 6dce5aa59e0b reverted + the dtb change:
https://lore.kernel.org/linux-pci/[email protected]/

Quoted 5 lines

That doesn't make sense. I just noticed there's an error in what I told you to do for dma-ranges. I fixed the wrong cell as it should be:

- dma-ranges = <0x42000000 0x40 0x00 0x40 0x00 0x40 0x00 0x00 0x00 0x79000000 0x00 0x79000000 0x00 0x800000>;
+ dma-ranges = <0x42000000 0x40 0x00 0x40 0x00 0x40 0x00 0x42000000 0x00 0x79000000 0x00 0x79000000 0x00 0x800000>;

OK, thanks Rob. Here's an updated log:

https://paste.ubuntu.com/p/FmSTbM6Zq3/

-dann

#19 lore raw
In reply to Rob Herring
Quoted 1 line · Rob Herring

...

Quoted 6 lines

Do the DT's in the kernel tree correspond to anything anyone is using? I ask because at some point someone will need to address all the warnings they have or we should drop the dts files if they aren't close to reality. The same thing applies to Seattle BTW.

I sent these a while ago to sync the Seattle kernel DT with the version that is in the Tianocore tree, and is built into the open version of the Seattle firmware

https://lore.kernel.org/all/[email protected]/

I wouldn't mind dropping them entirely, btw.