MdeModulePkg: Fix a PciBusDxe hot plug bug

For a hot plug bridge with device attached, PciBusDxe driver reserves
the resources which equal to the total amount of padding resource
returned from HotPlug->GetResourcePadding() and the actual occupied
resource by the attached device. The behavior is incorrect.
Correct behavior is to reserve the bigger one between the padding
resource and the actual occupied resource.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18719 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni
2015-11-03 02:34:21 +00:00
committed by niruiyu
parent f67bd32dda
commit c7e7613e09
2 changed files with 48 additions and 25 deletions

View File

@@ -976,7 +976,8 @@ PciScanBus (
UINT8 Device;
UINT8 Func;
UINT64 Address;
UINTN SecondBus;
UINT8 SecondBus;
UINT8 PaddedSubBus;
UINT16 Register;
UINTN HpIndex;
PCI_IO_DEVICE *PciDevice;
@@ -1210,7 +1211,7 @@ PciScanBus (
Status = PciScanBus (
PciDevice,
(UINT8) (SecondBus),
SecondBus,
SubBusNumber,
PaddedBusRange
);
@@ -1226,12 +1227,16 @@ PciScanBus (
if ((Attributes == EfiPaddingPciRootBridge) &&
(State & EFI_HPC_STATE_ENABLED) != 0 &&
(State & EFI_HPC_STATE_INITIALIZED) != 0) {
*PaddedBusRange = (UINT8) ((UINT8) (BusRange) +*PaddedBusRange);
*PaddedBusRange = (UINT8) ((UINT8) (BusRange) + *PaddedBusRange);
} else {
Status = PciAllocateBusNumber (PciDevice, *SubBusNumber, (UINT8) (BusRange), SubBusNumber);
//
// Reserve the larger one between the actual occupied bus number and padded bus number
//
Status = PciAllocateBusNumber (PciDevice, StartBusNumber, (UINT8) (BusRange), &PaddedSubBus);
if (EFI_ERROR (Status)) {
return Status;
}
*SubBusNumber = MAX (PaddedSubBus, *SubBusNumber);
}
}