summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorFoster Nong <foster.nong@intel.com>2022-09-29 17:20:01 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-10-08 08:58:05 +0000
commitde103f1981cfca90dd19296d4b20449a2b93dc26 (patch)
treef2a73739697736d1cf6c9dd58fa13afcc3524c79 /MdeModulePkg/Bus
parent4364d661685d4806b8fb66ff76eaece7ea6a4426 (diff)
downloadedk2-de103f1981cfca90dd19296d4b20449a2b93dc26.tar.gz
edk2-de103f1981cfca90dd19296d4b20449a2b93dc26.tar.bz2
edk2-de103f1981cfca90dd19296d4b20449a2b93dc26.zip
MdeModulePkg: Handle InitialVFs=0 case for SR-IOV
Per the section 3.3.5 SR-IOV spec v1.1, InitialVFs (0ch). InitialVFs indicates to SR-PCIM the number of VFs that are initially associated with the PF. The minimum value of InitialVFs is 0. Below code is used to calculate SR-IOV reserved bus number, if InitialVFs =0, it maybe calculate the wrong bus number in this case. LastVF = PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride we can fix it with below code: if (PciIoDevice->InitialVFs == 0) { PciIoDevice->ReservedBusNum = 0; } else { PFRid = EFI_PCI_RID (Bus, Device, Func); LastVF = PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride; // // Calculate ReservedBusNum for this PF // PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus + 1); // // Calculate ReservedBusNum for this PF // PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus + 1); } 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>
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index 509f828b62..eb250f6f7b 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -2416,13 +2416,17 @@ CreatePciIoDevice (
//
// Calculate LastVF
//
- PFRid = EFI_PCI_RID (Bus, Device, Func);
- LastVF = PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride;
+ if (PciIoDevice->InitialVFs == 0) {
+ PciIoDevice->ReservedBusNum = 0;
+ } else {
+ PFRid = EFI_PCI_RID (Bus, Device, Func);
+ LastVF = PFRid + FirstVFOffset + (PciIoDevice->InitialVFs - 1) * VFStride;
- //
- // Calculate ReservedBusNum for this PF
- //
- PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus + 1);
+ //
+ // Calculate ReservedBusNum for this PF
+ //
+ PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus + 1);
+ }
DEBUG ((
DEBUG_INFO,