]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
pci_pci: Support growing windows in bus_adjust_resource for NEW_PCIB
authorJessica Clarke <jrtc27@FreeBSD.org>
Sat, 7 Aug 2021 18:27:32 +0000 (19:27 +0100)
committerJessica Clarke <jrtc27@FreeBSD.org>
Sat, 7 Aug 2021 18:27:32 +0000 (19:27 +0100)
commit262459806433f838bb2e54cc4733c0887328a170
tree9293d00f254839a85d03c586e32a29d19eec3aa8
parent896e217a0eae692b1fe3de5d1354478541fb13ff
pci_pci: Support growing windows in bus_adjust_resource for NEW_PCIB

If we allocate a new window for a bridge rather than reusing an existing
one set up by firmware to cover all the devices then the new window only
includes the range needed for the first device to allocate the resource.
If a request comes in to adjust this resource in order to extend a
downstream window for another device then this will fail as the rman
doesn't have any space, so we must first grow the bridge's own window.

This is needed to support successfully attaching more than one PCI
device on SiFive's HiFive Unmatched, which has the following topology:

  Root Port <---> Bridge <---> Bridge <-+-> Bridge <---> (Unused)
   (pcib0)        (pcib1)      (pcib2)  |   (pcib3)
                                        +-> Bridge <---> xHCI
                                        |   (pcib4)
                                        +-> Bridge <---> M.2 E-key
                                        |   (pcib5)
                                        +-> Bridge <---> M.2 M-key
                                        |   (pcib6)
                                        +-> Bridge <---> x16 slot
                                            (pcib7)

Without this, the xHCI endpoint successfully attaches but NVMe M.2 M-key
endpoint fails to attach as, when its adjacent bridge (pcib6) attempts
to allocate a window from its parent (pcib2) on the other side of the
switch, its parent attempts to grow its own window by calling
bus_adjust_resource on its own parent (pcib1) which fails to call the
root port device (pcib0) to request more memory to grow its own window.
Had the root port been directly connected to the switch without the
bridge in the middle then the existing code would have worked, but the
extra hop broke it.

Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31035
sys/dev/pci/pci_pci.c