]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
PCI: Tolerate hierarchies with no Root Port
authorYijing Wang <wangyijing@huawei.com>
Mon, 17 Aug 2015 10:47:58 +0000 (18:47 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 19 Aug 2015 22:23:17 +0000 (17:23 -0500)
commitb35b1df5e6c213b0b0322e6c231b7111efe4a390
treedd689a3ffc5e6e3cf6c7e56ab339c14f9cd43ebf
parentc9ddbac9c89110f77cb0fa07e634aaf1194899aa
PCI: Tolerate hierarchies with no Root Port

We should not assume any particular hardware topology.  Commit d0751b98dfa3
("PCI: Add dev->has_secondary_link to track downstream PCIe links") relied
on the assumption that every PCIe hierarchy is rooted at a Root Port.  But
we can't rely on any assumption about what hardware we will find; we just
have to deal with the world as it is.

On some platforms, PCIe devices (endpoints, switch upstream ports, etc.)
appear directly on the root bus, and there is no Root Port in the PCI bus
hierarchy.  For example, Meelis observed these top-level devices on a
Sparc V245:

  0000:02:00.0 PCI bridge to [bus 03-0d]    Switch Upstream Port
  0001:02:00.0 PCI bridge to [bus 03]       PCIe to PCI/PCI-X Bridge

These devices *look* like they have links going upstream, but there really
are no upstream devices.

In set_pcie_port_type(), we used the parent device to figure out which side
of a switch port has a link, so if the parent device did not exist, we
dereferenced a NULL parent pointer.

Check whether the parent device exists before dereferencing it.

Meelis observed this oops on Sparc V245 and T2000.  Ben Herrenschmidt says
this is also possible on IBM PowerVM guests on PowerPC.

[bhelgaas: changelog, comment]
Link: http://lkml.kernel.org/r/alpine.LRH.2.20.1508122118210.18637@math.ut.ee
Reported-by: Meelis Roos <mroos@linux.ee>
Tested-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: David S. Miller <davem@davemloft.net>
drivers/pci/probe.c