audk/MdeModulePkg/Bus/Pci
Foster Nong 4aa7e66c06 MdeModulePkg: Fixed extra 1 SR-IOV reserved bus
Below code will calculate the reserved bus number for the each PF.

Based on the VF routing ID algorithm, PFRid and LastVF in below code
already sure that "All VFs and PFs must have distinct Routing IDs".
PF will be assigned Routing ID based on secBusNumber, ReservedBusNum
will add into SubBusNumber directly. So the SR-IOV device will be
assigned bus range as SecBusNumber ~ (SubBusNumber=(SecBusNumber +
ReservedBusNum)).
Thus "+1" in below code will cause extra 1 bus, and introduce a bus hole.

 PFRid  = EFI_PCI_RID (Bus, Device, Func);
 LastVF = PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride;
 PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) -
 Bus + 1);

In SR-IOV spec, there is a note in section 2.1.2:
Note: Bus Numbers are a constrained resource. Devices are strongly
encouraged to avoid leaving ?holes? in their Bus Number usage to avoid
wasting Bus Numbers

So the issue can be fixed with below code change.
  PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) -
  Bus);

https://bugzilla.tianocore.org/show_bug.cgi?id=4069

Signed-off-by: Foster Nong <foster.nong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
2022-10-14 07:07:01 +00:00
..
EhciDxe MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
EhciPei MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
IdeBusPei MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
IncompatiblePciDeviceSupportDxe MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
NonDiscoverablePciDeviceDxe MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer 2022-10-01 10:44:30 +00:00
NvmExpressDxe MdeModulePkg/NvmExpressDxe: fix check for Cap.Css 2022-03-25 00:59:04 +00:00
NvmExpressPei MdeModulePkg: Fix imbalanced debug macros 2022-09-09 01:42:39 +00:00
PciBusDxe MdeModulePkg: Fixed extra 1 SR-IOV reserved bus 2022-10-14 07:07:01 +00:00
PciHostBridgeDxe MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
PciSioSerialDxe MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SataControllerDxe MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SdMmcPciHcDxe MdeModulePkg: Fix imbalanced debug macros 2022-09-09 01:42:39 +00:00
SdMmcPciHcPei MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
UfsPciHcDxe MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
UfsPciHcPei MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
UhciDxe MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue 2021-12-09 02:36:30 +00:00
UhciPei MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
XhciDxe MdeModulePkg/XhciDxe: Input context update for Evaluate Context command 2022-09-27 02:44:24 +00:00
XhciPei MdeModulePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00