Skip to contentSkip to conversation

PCI: rockchip: Fix PCIe probing in 5.9

PATCH Applied Marc Zyngier 5 participants 13 messages Aug 15, 2020 – Jan 9, 2021

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

cover PCI: rockchip: Fix PCIe probing in 5.9

Recent changes to the way PCI DT nodes are parsed are now enforcing the presence of a "device_type" property, which has been mandated since... forever. This has the unfortunate effect of breaking non-compliant systems, and those using the Rockchip PCIe driver are amongst the victims. Oh well.

In order to keep users happy as well as my own machines up and running, let's paper over the problem by detecting a broken DT from the driver itself, and inserting the missing property at runtime.

For a good measure, a second patch fixes the DT, but the chances of such a fix being deployed at this stage are pretty slim, so the above hack is in for the long run.

Marc Zyngier (2):
PCI: rockchip: Work around missing device_type property in DT
arm64: dts: rockchip: Fix PCIe DT properties

 arch/arm64/boot/dts/rockchip/rk3399.dtsi    |  2 +-
 drivers/pci/controller/pcie-rockchip-host.c | 29 +++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
Signature · 7 lines
2.27.0


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#1 lore raw

PATCH 1/2 PCI: rockchip: Work around missing device_type property in DT

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
---
 drivers/pci/controller/pcie-rockchip-host.c | 29 +++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/pci/controller/pcie-rockchip-host.c +29 -0
index 0bb2fb3e8a0b..d7dd04430a99 100644
@@ -949,6 +949,35 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
 	if (!dev->of_node)
 		return -ENODEV;
 
+	/*
+	 * Most rk3399 DTs are missing the 'device_type = "pci"' property,
+	 * potentially leading to PCIe probing failure. Be kind to the
+	 * users and fix it up for them. Upgrading is recommended.
+	 */
+	if (!of_find_property(dev->of_node, "device_type", NULL)) {
+		const char dtype[] = "pci";
+		struct property *prop;
+
+		dev_warn(dev, "Working around missing device_type property\n");
+
+		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+		if (!prop)
+			return -ENOMEM;
+
+		prop->name	= kstrdup("device_type", GFP_KERNEL);
+		prop->value	= kstrdup(dtype, GFP_KERNEL);
+		prop->length	= ARRAY_SIZE(dtype);
+		if (!prop->name || !prop->value) {
+			kfree(prop->name);
+			kfree(prop->value);
+			kfree(prop);
+			return -ENOMEM;
+		}
+
+		if (of_add_property(dev->of_node, prop))
+			dev_warn(dev, "Failed to add property, probing may fail");
+	}
+
 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rockchip));
 	if (!bridge)
 		return -ENOMEM;
Signature · 7 lines
2.27.0


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#2 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Quoted 1 line

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

Quoted 52 lines
---
 drivers/pci/controller/pcie-rockchip-host.c | 29 +++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/pci/controller/pcie-rockchip-host.c +29 -0
index 0bb2fb3e8a0b..d7dd04430a99 100644
@@ -949,6 +949,35 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
 	if (!dev->of_node)
 		return -ENODEV;
 
+	/*
+	 * Most rk3399 DTs are missing the 'device_type = "pci"' property,
+	 * potentially leading to PCIe probing failure. Be kind to the
+	 * users and fix it up for them. Upgrading is recommended.
+	 */
+	if (!of_find_property(dev->of_node, "device_type", NULL)) {
+		const char dtype[] = "pci";
+		struct property *prop;
+
+		dev_warn(dev, "Working around missing device_type property\n");
+
+		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+		if (!prop)
+			return -ENOMEM;
+
+		prop->name	= kstrdup("device_type", GFP_KERNEL);
+		prop->value	= kstrdup(dtype, GFP_KERNEL);
+		prop->length	= ARRAY_SIZE(dtype);
+		if (!prop->name || !prop->value) {
+			kfree(prop->name);
+			kfree(prop->value);
+			kfree(prop);
+			return -ENOMEM;
+		}
+
+		if (of_add_property(dev->of_node, prop))
+			dev_warn(dev, "Failed to add property, probing may fail");
+	}
+
 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rockchip));
 	if (!bridge)
 		return -ENOMEM;
Signature · 7 lines
2.27.0


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

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 18 lines · Bjorn Helgaas
Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Quoted 6 lines

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Clearly not my day when it comes to proofreading commit messages. Thanks for pointing this out, and in advance for fixing it up.

Quoted 5 lines
Quoted 2 lines

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

Absolutely.

Quoted 2 lines

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

I've just managed to run the checker, which comes up with all kinds of goodies. Apart from the above, it also spots the following:

- arch/arm64/boot/dts/mediatek/mt7622.dtsi: Has a device_type property in its main PCIe node, but not in the child nodes. It isn't obvious to me whether that's a violation or not (the spec doesn't say whether the property should be set on a per-port basis). Rob?

- arch/arm64/boot/dts/qcom/msm8996.dtsi: Only one out of the three PCIe nodes has the device_type property, probably broken similarly to rk3399.

I could move the workaround to drivers/pci/of.c, and have it called from the individual drivers. I don't have the HW to test those though.

Thoughts?

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
maintainer
#4 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 42 lines · Marc Zyngier
Quoted 18 lines · Bjorn Helgaas
Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Quoted 6 lines

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Clearly not my day when it comes to proofreading commit messages. Thanks for pointing this out, and in advance for fixing it up.

Quoted 5 lines
Quoted 2 lines

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

Absolutely.

Quoted 2 lines

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

Quoted 7 lines

I've just managed to run the checker, which comes up with all kinds of goodies. Apart from the above, it also spots the following:

- arch/arm64/boot/dts/mediatek/mt7622.dtsi: Has a device_type property in its main PCIe node, but not in the child nodes. It isn't obvious to me whether that's a violation or not (the spec doesn't say whether the property should be set on a per-port basis). Rob?

The rule is bridge nodes should have 'device_type = "pci"'. But what's needed to fix these cases is setting device_type where we are parsing ranges or dma-ranges which we're not doing on the child ndes. Otherwise, I don't think it matters in this case unless you have child (grandchild here) nodes for PCI devices. If you did have child nodes, the address translation was already broken before this change.

Quoted 3 lines

- arch/arm64/boot/dts/qcom/msm8996.dtsi: Only one out of the three PCIe nodes has the device_type property, probably broken similarly to rk3399.

The only upstream board is DB820c, so probably not as wide an impact...

There are also 92 (lots of duplicates due to multiple boards) more cases in arch/arm/. A log is here[1].

Quoted 4 lines

I could move the workaround to drivers/pci/of.c, and have it called from the individual drivers. I don't have the HW to test those though.

Thoughts?

I think we should go with my other suggestion of looking at the node name. Looks like just checking 'pcie' is enough. We can skip 'pci' as I don't see any cases.

Rob

[1] https://gitlab.com/robherring/linux-dt-bindings/-/jobs/688752562

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

#5 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 51 lines · Rob Herring
Quoted 42 lines · Marc Zyngier
Quoted 18 lines · Bjorn Helgaas
Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Quoted 6 lines

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Clearly not my day when it comes to proofreading commit messages. Thanks for pointing this out, and in advance for fixing it up.

Quoted 5 lines
Quoted 2 lines

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

Absolutely.

Quoted 2 lines

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

Quoted 7 lines

I've just managed to run the checker, which comes up with all kinds of goodies. Apart from the above, it also spots the following:

- arch/arm64/boot/dts/mediatek/mt7622.dtsi: Has a device_type property in its main PCIe node, but not in the child nodes. It isn't obvious to me whether that's a violation or not (the spec doesn't say whether the property should be set on a per-port basis). Rob?

Quoted 6 lines

The rule is bridge nodes should have 'device_type = "pci"'. But what's needed to fix these cases is setting device_type where we are parsing ranges or dma-ranges which we're not doing on the child ndes. Otherwise, I don't think it matters in this case unless you have child (grandchild here) nodes for PCI devices. If you did have child nodes, the address translation was already broken before this change.

Fair enough.

Quoted 8 lines
Quoted 3 lines

- arch/arm64/boot/dts/qcom/msm8996.dtsi: Only one out of the three PCIe nodes has the device_type property, probably broken similarly to rk3399.

The only upstream board is DB820c, so probably not as wide an impact...

There are also 92 (lots of duplicates due to multiple boards) more cases in arch/arm/. A log is here[1].

Mostly Broadcom stuff, apparently. I'll see if I can have a stab at it (although someone will have to test it).

Quoted 9 lines
Quoted 5 lines

I could move the workaround to drivers/pci/of.c, and have it called from the individual drivers. I don't have the HW to test those though.

Thoughts?

I think we should go with my other suggestion of looking at the node name. Looks like just checking 'pcie' is enough. We can skip 'pci' as I don't see any cases.

I really dislike it.

Once we put this node name matching in, there is no incentive for people to write their DT correctly at all. It also sound pretty fragile (what if the PCIe node is named something else?).

My preference goes towards having point fixes in the affected drivers, clearly showing that this is addressing a firmware bug.

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
maintainer
#6 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 84 lines · Marc Zyngier
Quoted 51 lines · Rob Herring
Quoted 42 lines · Marc Zyngier
Quoted 18 lines · Bjorn Helgaas
Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Quoted 6 lines

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Clearly not my day when it comes to proofreading commit messages. Thanks for pointing this out, and in advance for fixing it up.

Quoted 5 lines
Quoted 2 lines

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

Absolutely.

Quoted 2 lines

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

Quoted 7 lines

I've just managed to run the checker, which comes up with all kinds of goodies. Apart from the above, it also spots the following:

- arch/arm64/boot/dts/mediatek/mt7622.dtsi: Has a device_type property in its main PCIe node, but not in the child nodes. It isn't obvious to me whether that's a violation or not (the spec doesn't say whether the property should be set on a per-port basis). Rob?

Quoted 6 lines

The rule is bridge nodes should have 'device_type = "pci"'. But what's needed to fix these cases is setting device_type where we are parsing ranges or dma-ranges which we're not doing on the child ndes. Otherwise, I don't think it matters in this case unless you have child (grandchild here) nodes for PCI devices. If you did have child nodes, the address translation was already broken before this change.

Fair enough.

Quoted 8 lines
Quoted 3 lines

- arch/arm64/boot/dts/qcom/msm8996.dtsi: Only one out of the three PCIe nodes has the device_type property, probably broken similarly to rk3399.

The only upstream board is DB820c, so probably not as wide an impact...

There are also 92 (lots of duplicates due to multiple boards) more cases in arch/arm/. A log is here[1].

Mostly Broadcom stuff, apparently. I'll see if I can have a stab at it (although someone will have to test it).

Quoted 9 lines
Quoted 5 lines

I could move the workaround to drivers/pci/of.c, and have it called from the individual drivers. I don't have the HW to test those though.

Thoughts?

I think we should go with my other suggestion of looking at the node name. Looks like just checking 'pcie' is enough. We can skip 'pci' as I don't see any cases.

Quoted 5 lines

I really dislike it.

Once we put this node name matching in, there is no incentive for people to write their DT correctly at all. It also sound pretty fragile (what if the PCIe node is named something else?).

That would require 2 wrongs. Both missing device_type and wrong node name. You could still warn if we matched on node name.

This is just one possible error out of thousands. It's not the kernel's job to validate DTs (if it is, we're doing a horrible job). We have a solution for this with schema. The question is how to get to the point the schema checks are part of the main build flow. The primary issue is just getting to some platforms being warning free, and then they could opt in. There's effort around some platforms (Rockchip is not one), but I think we have a ways to go. The other aspect is what's the coverage with the schema. There's 2900 remaining bindings to convert to schema. We're doing about 100-200 a cycle, so that's what the next ~5 years looks like for me. :(

Quoted 2 lines

My preference goes towards having point fixes in the affected drivers, clearly showing that this is addressing a firmware bug.

I didn't filter down how many drivers all the failures equates to in terms of drivers. I guess all of Broadcom is just one. If you want to fixup all the drivers, then I'm fine with that.

Rob

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

#7 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 85 lines · Rob Herring
Quoted 84 lines · Marc Zyngier
Quoted 51 lines · Rob Herring
Quoted 42 lines · Marc Zyngier
Quoted 18 lines · Bjorn Helgaas
Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Quoted 6 lines

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Clearly not my day when it comes to proofreading commit messages. Thanks for pointing this out, and in advance for fixing it up.

Quoted 5 lines
Quoted 2 lines

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

Absolutely.

Quoted 2 lines

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

Quoted 7 lines

I've just managed to run the checker, which comes up with all kinds of goodies. Apart from the above, it also spots the following:

- arch/arm64/boot/dts/mediatek/mt7622.dtsi: Has a device_type property in its main PCIe node, but not in the child nodes. It isn't obvious to me whether that's a violation or not (the spec doesn't say whether the property should be set on a per-port basis). Rob?

Quoted 6 lines

The rule is bridge nodes should have 'device_type = "pci"'. But what's needed to fix these cases is setting device_type where we are parsing ranges or dma-ranges which we're not doing on the child ndes. Otherwise, I don't think it matters in this case unless you have child (grandchild here) nodes for PCI devices. If you did have child nodes, the address translation was already broken before this change.

Fair enough.

Quoted 8 lines
Quoted 3 lines

- arch/arm64/boot/dts/qcom/msm8996.dtsi: Only one out of the three PCIe nodes has the device_type property, probably broken similarly to rk3399.

The only upstream board is DB820c, so probably not as wide an impact...

There are also 92 (lots of duplicates due to multiple boards) more cases in arch/arm/. A log is here[1].

Mostly Broadcom stuff, apparently. I'll see if I can have a stab at it (although someone will have to test it).

Quoted 9 lines
Quoted 5 lines

I could move the workaround to drivers/pci/of.c, and have it called from the individual drivers. I don't have the HW to test those though.

Thoughts?

I think we should go with my other suggestion of looking at the node name. Looks like just checking 'pcie' is enough. We can skip 'pci' as I don't see any cases.

Quoted 8 lines
Quoted 5 lines

I really dislike it.

Once we put this node name matching in, there is no incentive for people to write their DT correctly at all. It also sound pretty fragile (what if the PCIe node is named something else?).

That would require 2 wrongs. Both missing device_type and wrong node name. You could still warn if we matched on node name.

OK. So how about something like this?

drivers/of/address.c +5 -1
index 590493e04b01..a7a6ee599b14 100644
@@ -134,9 +134,13 @@ static int of_bus_pci_match(struct device_node *np)
  	 * "pciex" is PCI Express
 	 * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
 	 * "ht" is hypertransport
+	 *
+	 * If none of the device_type match, and that the node name is
+	 * "pcie", accept the device as PCI (with a warning).
 	 */
 	return of_node_is_type(np, "pci") || of_node_is_type(np, "pciex") ||
-		of_node_is_type(np, "vci") || of_node_is_type(np, "ht");
+		of_node_is_type(np, "vci") || of_node_is_type(np, "ht") ||
+		WARN_ON_ONCE(of_node_name_eq(np, "pcie"));
 }
 
 static void of_bus_pci_count_cells(struct device_node *np,

It should address all the drivers in one go, and yet tell users that something is amiss.

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#8 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 104 lines · Marc Zyngier
Quoted 85 lines · Rob Herring
Quoted 84 lines · Marc Zyngier
Quoted 51 lines · Rob Herring
Quoted 42 lines · Marc Zyngier
Quoted 18 lines · Bjorn Helgaas
Quoted 10 lines · Marc Zyngier

Recent changes to the DT PCI bus parsing made it mandatory for device tree nodes describing a PCI controller to have the 'device_type = "pci"' property for the node to be matched.

Although this follows the letter of the specification, it breaks existing device-trees that have been working fine for years. Rockchip rk3399-based systems are a prime example of such collateral damage, and have stopped discovering their PCI bus.

Quoted 5 lines

In order to paper over the blunder, let's add a workaround to the pcie-rockchip driver, adding the missing property when none is found at boot time. A warning will hopefully nudge the user into updating their DT to a fixed version if they can, but the insentive is obviously pretty small.

Quoted 6 lines

s/insentive/incentive/ (Lorenzo or I can fix this up)

Quoted 2 lines
Fixes 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")

s/Roh/Rob/ (similarly)

Clearly not my day when it comes to proofreading commit messages. Thanks for pointing this out, and in advance for fixing it up.

Quoted 5 lines
Quoted 2 lines

This looks like a candidate for v5.9, since 2f96593ecc37 was merged during the v5.9 merge window, right?

Absolutely.

Quoted 2 lines

I wonder how many other DTs are similarly broken? Maybe Rob's DT checker has already looked?

Quoted 7 lines

I've just managed to run the checker, which comes up with all kinds of goodies. Apart from the above, it also spots the following:

- arch/arm64/boot/dts/mediatek/mt7622.dtsi: Has a device_type property in its main PCIe node, but not in the child nodes. It isn't obvious to me whether that's a violation or not (the spec doesn't say whether the property should be set on a per-port basis). Rob?

Quoted 6 lines

The rule is bridge nodes should have 'device_type = "pci"'. But what's needed to fix these cases is setting device_type where we are parsing ranges or dma-ranges which we're not doing on the child ndes. Otherwise, I don't think it matters in this case unless you have child (grandchild here) nodes for PCI devices. If you did have child nodes, the address translation was already broken before this change.

Fair enough.

Quoted 8 lines
Quoted 3 lines

- arch/arm64/boot/dts/qcom/msm8996.dtsi: Only one out of the three PCIe nodes has the device_type property, probably broken similarly to rk3399.

The only upstream board is DB820c, so probably not as wide an impact...

There are also 92 (lots of duplicates due to multiple boards) more cases in arch/arm/. A log is here[1].

Mostly Broadcom stuff, apparently. I'll see if I can have a stab at it (although someone will have to test it).

Quoted 9 lines
Quoted 5 lines

I could move the workaround to drivers/pci/of.c, and have it called from the individual drivers. I don't have the HW to test those though.

Thoughts?

I think we should go with my other suggestion of looking at the node name. Looks like just checking 'pcie' is enough. We can skip 'pci' as I don't see any cases.

Quoted 8 lines
Quoted 5 lines

I really dislike it.

Once we put this node name matching in, there is no incentive for people to write their DT correctly at all. It also sound pretty fragile (what if the PCIe node is named something else?).

That would require 2 wrongs. Both missing device_type and wrong node name. You could still warn if we matched on node name.

OK. So how about something like this?

drivers/of/address.c +0 -0
index 590493e04b01..a7a6ee599b14 100644
@@ -134,9 +134,13 @@ static int of_bus_pci_match(struct device_node *np)
         * "pciex" is PCI Express

drivers/of/address.c static int of_bus_pci_match(struct device_node *np) · line 143

Quoted 10 lines
drivers/of/address.c +5 -1
         * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
         * "ht" is hypertransport
+        *
+        * If none of the device_type match, and that the node name is
+        * "pcie", accept the device as PCI (with a warning).
         */
        return of_node_is_type(np, "pci") || of_node_is_type(np, "pciex") ||
-               of_node_is_type(np, "vci") || of_node_is_type(np, "ht");
+               of_node_is_type(np, "vci") || of_node_is_type(np, "ht") ||
+               WARN_ON_ONCE(of_node_name_eq(np, "pcie"));

I don't think we need the _ONCE. Otherwise, it'd warn only for the first device that has this problem.

How about?
WARN(of_node_name_eq(np, "pcie"), "Missing device type in %pOF", np)

That'll even tell them which node is bad.

-Saravana

#9 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 1 line · Saravana Kannan

On Tue, Aug 18, 2020 at 10:34 AM Marc Zyngier <[email protected]> wrote:

[...]

Quoted 17 lines
Quoted 17 lines

OK. So how about something like this?

drivers/of/address.c +3 -0
index 590493e04b01..a7a6ee599b14 100644
@@ -134,9 +134,13 @@ static int of_bus_pci_match(struct device_node 
 *np)
         * "pciex" is PCI Express
         * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
         * "ht" is hypertransport
+        *
+        * If none of the device_type match, and that the node name is
+        * "pcie", accept the device as PCI (with a warning).
         */
        return of_node_is_type(np, "pci") || of_node_is_type(np, 

"pciex") ||

Quoted 8 lines
Quoted 5 lines

- of_node_is_type(np, "vci") || of_node_is_type(np,
"ht");
+ of_node_is_type(np, "vci") || of_node_is_type(np,
"ht") ||
+ WARN_ON_ONCE(of_node_name_eq(np, "pcie"));

I don't think we need the _ONCE. Otherwise, it'd warn only for the first device that has this problem.

Because probing devices doesn't necessarily occur once. Case in point, it takes *10 to 15* attempts for a rk3399 system such as mine to finally probe its PCIe device, thanks to the wonderful -EPROBE_DEFER.

Do I want to see the same stack trace 10 (or more) times? No.

Quoted 4 lines

How about?
WARN(of_node_name_eq(np, "pcie"), "Missing device type in %pOF", np)

That'll even tell them which node is bad.

I explained my objections above. Spitting out the device node is useful, but there is no need to be exhaustive (if you're in a position to fix the DT, you can track all the broken instances for your device easily).

I'm actually minded to tone it down even more, because the stack trace is meaningless to most users. See below for a revised patch.

        M.
drivers/of/address.c +15 -1
index 590493e04b01..b37bd9cc2810 100644
@@ -128,15 +128,29 @@ static unsigned int of_bus_pci_get_flags(const __be32 *addr)
  * PCI bus specific translator
  */
 
+static bool of_node_is_pcie(struct device_node *np)
+{
+	bool is_pcie = of_node_name_eq(np, "pcie");
+
+	if (is_pcie)
+		pr_warn_once("%pOF: Missing device_type\n", np);
+
+	return is_pcie;
+}
+
 static int of_bus_pci_match(struct device_node *np)
 {
 	/*
  	 * "pciex" is PCI Express
 	 * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
 	 * "ht" is hypertransport
+	 *
+	 * If none of the device_type match, and that the node name is
+	 * "pcie", accept the device as PCI (with a warning).
 	 */
 	return of_node_is_type(np, "pci") || of_node_is_type(np, "pciex") ||
-		of_node_is_type(np, "vci") || of_node_is_type(np, "ht");
+		of_node_is_type(np, "vci") || of_node_is_type(np, "ht") ||
+		of_node_is_pcie(np);
 }
 
 static void of_bus_pci_count_cells(struct device_node *np,
Signature · 1 line
Jazz is not dead. It just smells funny...
maintainer
#10 lore raw

Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT

Quoted 43 lines · Marc Zyngier
Quoted 1 line · Saravana Kannan

On Tue, Aug 18, 2020 at 10:34 AM Marc Zyngier <[email protected]> wrote:

[...]

Quoted 17 lines
Quoted 17 lines

OK. So how about something like this?

drivers/of/address.c +3 -0
index 590493e04b01..a7a6ee599b14 100644
@@ -134,9 +134,13 @@ static int of_bus_pci_match(struct device_node
 *np)
         * "pciex" is PCI Express
         * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
         * "ht" is hypertransport
+        *
+        * If none of the device_type match, and that the node name is
+        * "pcie", accept the device as PCI (with a warning).
         */
        return of_node_is_type(np, "pci") || of_node_is_type(np,

"pciex") ||

Quoted 8 lines
Quoted 5 lines

- of_node_is_type(np, "vci") || of_node_is_type(np,
"ht");
+ of_node_is_type(np, "vci") || of_node_is_type(np,
"ht") ||
+ WARN_ON_ONCE(of_node_name_eq(np, "pcie"));

I don't think we need the _ONCE. Otherwise, it'd warn only for the first device that has this problem.

Because probing devices doesn't necessarily occur once. Case in point, it takes *10 to 15* attempts for a rk3399 system such as mine to finally probe its PCIe device, thanks to the wonderful -EPROBE_DEFER.

Do I want to see the same stack trace 10 (or more) times? No.

Quoted 4 lines

How about?
WARN(of_node_name_eq(np, "pcie"), "Missing device type in %pOF", np)

That'll even tell them which node is bad.

Quoted 7 lines

I explained my objections above. Spitting out the device node is useful, but there is no need to be exhaustive (if you're in a position to fix the DT, you can track all the broken instances for your device easily).

I'm actually minded to tone it down even more, because the stack trace is meaningless to most users. See below for a revised patch.

LGTM.

Quoted 41 lines
         M.
drivers/of/address.c +15 -1
index 590493e04b01..b37bd9cc2810 100644
@@ -128,15 +128,29 @@ static unsigned int of_bus_pci_get_flags(const
 __be32 *addr)
   * PCI bus specific translator
   */
 
+static bool of_node_is_pcie(struct device_node *np)
+{
+       bool is_pcie = of_node_name_eq(np, "pcie");
+
+       if (is_pcie)
+               pr_warn_once("%pOF: Missing device_type\n", np);
+
+       return is_pcie;
+}
+
  static int of_bus_pci_match(struct device_node *np)
  {
        /*
         * "pciex" is PCI Express
         * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
         * "ht" is hypertransport
+        *
+        * If none of the device_type match, and that the node name is
+        * "pcie", accept the device as PCI (with a warning).
         */
        return of_node_is_type(np, "pci") || of_node_is_type(np, "pciex") ||
-               of_node_is_type(np, "vci") || of_node_is_type(np, "ht");
+               of_node_is_type(np, "vci") || of_node_is_type(np, "ht") ||
+               of_node_is_pcie(np);
  }
 

static void of_bus_pci_count_cells(struct device_node *np,

--
Jazz is not dead. It just smells funny...

#11 lore raw

PATCH 2/2 arm64: dts: rockchip: Fix PCIe DT properties

In reply to Marc Zyngier

It recently became apparent that the lack of a 'device_type = "pci"' in the PCIe root complex node for rk3399 is a violation of the PCI binding, as documented in IEEE Std 1275-1994. Changes to the kernel's parsing of the DT made such violation fatal, as drivers cannot probe the controller anymore.

Add the missing property makes the PCIe node compliant. While we are at it, drop the pointless linux,pci-domain property, which only makes sense when there are multiple host bridges.

---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +1 -1
index ada724b12f01..a80fc4d563b5 100644
@@ -231,6 +231,7 @@ pcie0: pcie@f8000000 {
 		reg = <0x0 0xf8000000 0x0 0x2000000>,
 		      <0x0 0xfd000000 0x0 0x1000000>;
 		reg-names = "axi-base", "apb-base";
+		device_type = "pci";
 		#address-cells = <3>;
 		#size-cells = <2>;
 		#interrupt-cells = <1>;
@@ -249,7 +250,6 @@ pcie0: pcie@f8000000 {
 				<0 0 0 2 &pcie0_intc 1>,
 				<0 0 0 3 &pcie0_intc 2>,
 				<0 0 0 4 &pcie0_intc 3>;
-		linux,pci-domain = <0>;
 		max-link-speed = <1>;
 		msi-map = <0x0 &its 0x0 0x1000>;
 		phys = <&pcie_phy 0>, <&pcie_phy 1>,
Signature · 7 lines
2.27.0


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
maintainer Applied
#12 lore raw

Re: (subset) [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9

In reply to Marc Zyngier
Quoted 11 lines · Marc Zyngier

Recent changes to the way PCI DT nodes are parsed are now enforcing the presence of a "device_type" property, which has been mandated since... forever. This has the unfortunate effect of breaking non-compliant systems, and those using the Rockchip PCIe driver are amongst the victims. Oh well.

In order to keep users happy as well as my own machines up and running, let's paper over the problem by detecting a broken DT from the driver itself, and inserting the missing property at runtime.

[...]

Applied, thanks!

[2/2] arm64: dts: rockchip: Fix PCIe DT properties

      commit: 43f20b1c6140896916f4e91aacc166830a7ba849

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>