HomeFreeBSD

pci_pci: Support growing windows in bus_adjust_resource for NEW_PCIB

Description

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

Details

Provenance
jrtc27Authored on Aug 7 2021, 6:27 PM
Reviewer
jhb
Differential Revision
D31035: pci_pci: Support growing windows in bus_adjust_resource for NEW_PCIB
Parents
rG896e217a0eae: fu740_pci_dw: Add SiFive FU740 PCIe controller driver
Branches
Unknown
Tags
Unknown