xen: workaround missing device_type property in pci/pcie nodes
authorStefano Stabellini <sstabellini@kernel.org>
Tue, 9 Feb 2021 19:53:34 +0000 (11:53 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 12 Feb 2021 01:52:36 +0000 (17:52 -0800)
commit5a4087004d1adbbb223925f3306db0e5824a2bdc
tree59bd0696b0e8f7e9de4b9b379151f87c84db8cfb
parentd66cf56fa26a052bce2f8c746dc0dbac9061b593
xen: workaround missing device_type property in pci/pcie nodes

PCI buses differ from default buses in a few important ways, so it is
important to detect them properly. Normally, PCI buses are expected to
have the following property:

    device_type = "pci"

In reality, it is not always the case. To handle PCI bus nodes that
don't have the device_type property, also consider the node name: if the
node name is "pcie" or "pci" then consider the bus as a PCI bus.

This commit is based on the Linux kernel commit
d1ac0002dd29 "of: address: Work around missing device_type property in
pcie nodes".

This fixes Xen boot on RPi4. Some RPi4 kernels have the following node
on their device trees:

&pcie0 {
pci@1,0 {
#address-cells = <3>;
#size-cells = <2>;
ranges;

reg = <0 0 0 0 0>;

usb@1,0 {
reg = <0x10000 0 0 0 0>;
resets = <&reset RASPBERRYPI_FIRMWARE_RESET_ID_USB>;
};
};
};

The pci@1,0 node is a PCI bus. If we parse the node and its children as
a default bus, the reg property under usb@1,0 would have to be
interpreted as an address range mappable by the CPU, which is not the
case and would break.

Link: https://lore.kernel.org/xen-devel/YBmQQ3Tzu++AadKx@mattapan.m5p.com/
[fix style on commit]
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Tested-by: Elliott Mitchell <ehem+xen@m5p.com>
Tested-by: Jukka Kaartinen <jukka.kaartinen@unikie.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/common/device_tree.c