Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9
@ 2020-08-15 12:51 Marc Zyngier
  2020-08-15 12:51 ` [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT Marc Zyngier
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Marc Zyngier @ 2020-08-15 12:51 UTC (permalink / raw)
  To: linux-pci, linux-rockchip, linux-arm-kernel, linux-kernel
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, Shawn Lin,
	Bjorn Helgaas, kernel-team

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(-)

-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-15 12:51 [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Marc Zyngier
@ 2020-08-15 12:51 ` Marc Zyngier
  2020-08-15 23:22   ` Bjorn Helgaas
  2020-08-15 12:51 ` [PATCH 2/2] arm64: dts: rockchip: Fix PCIe DT properties Marc Zyngier
  2021-01-09 15:39 ` (subset) [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Heiko Stuebner
  2 siblings, 1 reply; 13+ messages in thread
From: Marc Zyngier @ 2020-08-15 12:51 UTC (permalink / raw)
  To: linux-pci, linux-rockchip, linux-arm-kernel, linux-kernel
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, Shawn Lin,
	Roh Herring, Bjorn Helgaas, kernel-team

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")
Suggested-by: Roh Herring <robh+dt@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pci/controller/pcie-rockchip-host.c | 29 +++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c
index 0bb2fb3e8a0b..d7dd04430a99 100644
--- a/drivers/pci/controller/pcie-rockchip-host.c
+++ b/drivers/pci/controller/pcie-rockchip-host.c
@@ -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;
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] arm64: dts: rockchip: Fix PCIe DT properties
  2020-08-15 12:51 [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Marc Zyngier
  2020-08-15 12:51 ` [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT Marc Zyngier
@ 2020-08-15 12:51 ` Marc Zyngier
  2021-01-09 15:39 ` (subset) [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Heiko Stuebner
  2 siblings, 0 replies; 13+ messages in thread
From: Marc Zyngier @ 2020-08-15 12:51 UTC (permalink / raw)
  To: linux-pci, linux-rockchip, linux-arm-kernel, linux-kernel
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, Shawn Lin,
	Bjorn Helgaas, kernel-team

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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index ada724b12f01..a80fc4d563b5 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -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>,
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-15 12:51 ` [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT Marc Zyngier
@ 2020-08-15 23:22   ` Bjorn Helgaas
  2020-08-16 10:39     ` Marc Zyngier
  0 siblings, 1 reply; 13+ messages in thread
From: Bjorn Helgaas @ 2020-08-15 23:22 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, linux-pci,
	Shawn Lin, linux-kernel, linux-rockchip, Roh Herring,
	Bjorn Helgaas, kernel-team, linux-arm-kernel

On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
> 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.

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

> Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> Suggested-by: Roh Herring <robh+dt@kernel.org>

s/Roh/Rob/ (similarly)

> Signed-off-by: Marc Zyngier <maz@kernel.org>

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?

> ---
>  drivers/pci/controller/pcie-rockchip-host.c | 29 +++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c
> index 0bb2fb3e8a0b..d7dd04430a99 100644
> --- a/drivers/pci/controller/pcie-rockchip-host.c
> +++ b/drivers/pci/controller/pcie-rockchip-host.c
> @@ -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;
> -- 
> 2.27.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-15 23:22   ` Bjorn Helgaas
@ 2020-08-16 10:39     ` Marc Zyngier
  2020-08-17 16:12       ` Rob Herring
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Zyngier @ 2020-08-16 10:39 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, linux-pci,
	Shawn Lin, linux-kernel, linux-rockchip, Roh Herring,
	Bjorn Helgaas, kernel-team, linux-arm-kernel

On Sun, 16 Aug 2020 00:22:28 +0100,
Bjorn Helgaas <helgaas@kernel.org> wrote:
> 
> On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
> > 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.
> 
> s/insentive/incentive/ (Lorenzo or I can fix this up)
> 
> > Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> > Suggested-by: Roh Herring <robh+dt@kernel.org>
> 
> 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.

> 
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> 
> This looks like a candidate for v5.9, since 2f96593ecc37 was merged
> during the v5.9 merge window, right?

Absolutely.

> 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.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-16 10:39     ` Marc Zyngier
@ 2020-08-17 16:12       ` Rob Herring
  2020-08-18  7:35         ` Marc Zyngier
  0 siblings, 1 reply; 13+ messages in thread
From: Rob Herring @ 2020-08-17 16:12 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Lorenzo Pieralisi, Heiko Stuebner, PCI, Shawn Lin, linux-kernel,
	open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Sun, Aug 16, 2020 at 4:40 AM Marc Zyngier <maz@kernel.org> wrote:
>
> On Sun, 16 Aug 2020 00:22:28 +0100,
> Bjorn Helgaas <helgaas@kernel.org> wrote:
> >
> > On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
> > > 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.
> >
> > s/insentive/incentive/ (Lorenzo or I can fix this up)
> >
> > > Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> > > Suggested-by: Roh Herring <robh+dt@kernel.org>
> >
> > 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.
>
> >
> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> >
> > This looks like a candidate for v5.9, since 2f96593ecc37 was merged
> > during the v5.9 merge window, right?
>
> Absolutely.
>
> > 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?

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.

> - 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].

> 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-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-17 16:12       ` Rob Herring
@ 2020-08-18  7:35         ` Marc Zyngier
  2020-08-18 14:23           ` Rob Herring
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Zyngier @ 2020-08-18  7:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: Lorenzo Pieralisi, Heiko Stuebner, PCI, Shawn Lin, linux-kernel,
	open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On 2020-08-17 17:12, Rob Herring wrote:
> On Sun, Aug 16, 2020 at 4:40 AM Marc Zyngier <maz@kernel.org> wrote:
>> 
>> On Sun, 16 Aug 2020 00:22:28 +0100,
>> Bjorn Helgaas <helgaas@kernel.org> wrote:
>> >
>> > On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
>> > > 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.
>> >
>> > s/insentive/incentive/ (Lorenzo or I can fix this up)
>> >
>> > > Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
>> > > Suggested-by: Roh Herring <robh+dt@kernel.org>
>> >
>> > 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.
>> 
>> >
>> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
>> >
>> > This looks like a candidate for v5.9, since 2f96593ecc37 was merged
>> > during the v5.9 merge window, right?
>> 
>> Absolutely.
>> 
>> > 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?
> 
> 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.

>> - 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).

> 
>> 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.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-18  7:35         ` Marc Zyngier
@ 2020-08-18 14:23           ` Rob Herring
  2020-08-18 17:34             ` Marc Zyngier
  0 siblings, 1 reply; 13+ messages in thread
From: Rob Herring @ 2020-08-18 14:23 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Lorenzo Pieralisi, Heiko Stuebner, PCI, Shawn Lin, linux-kernel,
	open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Aug 18, 2020 at 1:35 AM Marc Zyngier <maz@kernel.org> wrote:
>
> On 2020-08-17 17:12, Rob Herring wrote:
> > On Sun, Aug 16, 2020 at 4:40 AM Marc Zyngier <maz@kernel.org> wrote:
> >>
> >> On Sun, 16 Aug 2020 00:22:28 +0100,
> >> Bjorn Helgaas <helgaas@kernel.org> wrote:
> >> >
> >> > On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
> >> > > 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.
> >> >
> >> > s/insentive/incentive/ (Lorenzo or I can fix this up)
> >> >
> >> > > Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> >> > > Suggested-by: Roh Herring <robh+dt@kernel.org>
> >> >
> >> > 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.
> >>
> >> >
> >> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> >> >
> >> > This looks like a candidate for v5.9, since 2f96593ecc37 was merged
> >> > during the v5.9 merge window, right?
> >>
> >> Absolutely.
> >>
> >> > 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?
> >
> > 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.
>
> >> - 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).
>
> >
> >> 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?).

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. :(

> 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-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-18 14:23           ` Rob Herring
@ 2020-08-18 17:34             ` Marc Zyngier
  2020-08-18 17:48               ` Saravana Kannan
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Zyngier @ 2020-08-18 17:34 UTC (permalink / raw)
  To: Rob Herring
  Cc: Lorenzo Pieralisi, Heiko Stuebner, PCI, Shawn Lin, linux-kernel,
	open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On 2020-08-18 15:23, Rob Herring wrote:
> On Tue, Aug 18, 2020 at 1:35 AM Marc Zyngier <maz@kernel.org> wrote:
>> 
>> On 2020-08-17 17:12, Rob Herring wrote:
>> > On Sun, Aug 16, 2020 at 4:40 AM Marc Zyngier <maz@kernel.org> wrote:
>> >>
>> >> On Sun, 16 Aug 2020 00:22:28 +0100,
>> >> Bjorn Helgaas <helgaas@kernel.org> wrote:
>> >> >
>> >> > On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
>> >> > > 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.
>> >> >
>> >> > s/insentive/incentive/ (Lorenzo or I can fix this up)
>> >> >
>> >> > > Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
>> >> > > Suggested-by: Roh Herring <robh+dt@kernel.org>
>> >> >
>> >> > 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.
>> >>
>> >> >
>> >> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
>> >> >
>> >> > This looks like a candidate for v5.9, since 2f96593ecc37 was merged
>> >> > during the v5.9 merge window, right?
>> >>
>> >> Absolutely.
>> >>
>> >> > 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?
>> >
>> > 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.
>> 
>> >> - 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).
>> 
>> >
>> >> 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?).
> 
> 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?

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 590493e04b01..a7a6ee599b14 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -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.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-18 17:34             ` Marc Zyngier
@ 2020-08-18 17:48               ` Saravana Kannan
  2020-08-18 19:02                 ` Marc Zyngier
  0 siblings, 1 reply; 13+ messages in thread
From: Saravana Kannan @ 2020-08-18 17:48 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, PCI, Shawn Lin,
	LKML, open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Aug 18, 2020 at 10:34 AM Marc Zyngier <maz@kernel.org> wrote:
>
> On 2020-08-18 15:23, Rob Herring wrote:
> > On Tue, Aug 18, 2020 at 1:35 AM Marc Zyngier <maz@kernel.org> wrote:
> >>
> >> On 2020-08-17 17:12, Rob Herring wrote:
> >> > On Sun, Aug 16, 2020 at 4:40 AM Marc Zyngier <maz@kernel.org> wrote:
> >> >>
> >> >> On Sun, 16 Aug 2020 00:22:28 +0100,
> >> >> Bjorn Helgaas <helgaas@kernel.org> wrote:
> >> >> >
> >> >> > On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
> >> >> > > 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.
> >> >> >
> >> >> > s/insentive/incentive/ (Lorenzo or I can fix this up)
> >> >> >
> >> >> > > Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> >> >> > > Suggested-by: Roh Herring <robh+dt@kernel.org>
> >> >> >
> >> >> > 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.
> >> >>
> >> >> >
> >> >> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> >> >> >
> >> >> > This looks like a candidate for v5.9, since 2f96593ecc37 was merged
> >> >> > during the v5.9 merge window, right?
> >> >>
> >> >> Absolutely.
> >> >>
> >> >> > 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?
> >> >
> >> > 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.
> >>
> >> >> - 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).
> >>
> >> >
> >> >> 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?).
> >
> > 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?
>
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 590493e04b01..a7a6ee599b14 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -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"));

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-18 17:48               ` Saravana Kannan
@ 2020-08-18 19:02                 ` Marc Zyngier
  2020-08-18 19:06                   ` Rob Herring
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Zyngier @ 2020-08-18 19:02 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Rob Herring, Lorenzo Pieralisi, Heiko Stuebner, PCI, Shawn Lin,
	LKML, open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On 2020-08-18 18:48, Saravana Kannan wrote:
> On Tue, Aug 18, 2020 at 10:34 AM Marc Zyngier <maz@kernel.org> wrote:

[...]

>> OK. So how about something like this?
>> 
>> diff --git a/drivers/of/address.c b/drivers/of/address.c
>> index 590493e04b01..a7a6ee599b14 100644
>> --- a/drivers/of/address.c
>> +++ b/drivers/of/address.c
>> @@ -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"));
> 
> 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.

> 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.

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 590493e04b01..b37bd9cc2810 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -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...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
  2020-08-18 19:02                 ` Marc Zyngier
@ 2020-08-18 19:06                   ` Rob Herring
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2020-08-18 19:06 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Lorenzo Pieralisi, Heiko Stuebner, Saravana Kannan, PCI,
	Shawn Lin, LKML, open list:ARM/Rockchip SoC...,
	Bjorn Helgaas, Bjorn Helgaas, Android Kernel Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Aug 18, 2020 at 1:03 PM Marc Zyngier <maz@kernel.org> wrote:
>
> On 2020-08-18 18:48, Saravana Kannan wrote:
> > On Tue, Aug 18, 2020 at 10:34 AM Marc Zyngier <maz@kernel.org> wrote:
>
> [...]
>
> >> OK. So how about something like this?
> >>
> >> diff --git a/drivers/of/address.c b/drivers/of/address.c
> >> index 590493e04b01..a7a6ee599b14 100644
> >> --- a/drivers/of/address.c
> >> +++ b/drivers/of/address.c
> >> @@ -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"));
> >
> > 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.
>
> > 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.

LGTM.

>          M.
>
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 590493e04b01..b37bd9cc2810 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -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...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (subset) [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9
  2020-08-15 12:51 [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Marc Zyngier
  2020-08-15 12:51 ` [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT Marc Zyngier
  2020-08-15 12:51 ` [PATCH 2/2] arm64: dts: rockchip: Fix PCIe DT properties Marc Zyngier
@ 2021-01-09 15:39 ` Heiko Stuebner
  2 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2021-01-09 15:39 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, linux-pci, linux-rockchip, Marc Zyngier
  Cc: Lorenzo Pieralisi, Heiko Stuebner, Shawn Lin, Bjorn Helgaas, kernel-team

On Sat, 15 Aug 2020 13:51:10 +0100, Marc Zyngier wrote:
> 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,
-- 
Heiko Stuebner <heiko@sntech.de>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-15 12:51 [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Marc Zyngier
2020-08-15 12:51 ` [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT Marc Zyngier
2020-08-15 23:22   ` Bjorn Helgaas
2020-08-16 10:39     ` Marc Zyngier
2020-08-17 16:12       ` Rob Herring
2020-08-18  7:35         ` Marc Zyngier
2020-08-18 14:23           ` Rob Herring
2020-08-18 17:34             ` Marc Zyngier
2020-08-18 17:48               ` Saravana Kannan
2020-08-18 19:02                 ` Marc Zyngier
2020-08-18 19:06                   ` Rob Herring
2020-08-15 12:51 ` [PATCH 2/2] arm64: dts: rockchip: Fix PCIe DT properties Marc Zyngier
2021-01-09 15:39 ` (subset) [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Heiko Stuebner

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git