summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2018-09-13 14:27:47 +0800
committerStar Zeng <star.zeng@intel.com>2018-11-07 22:07:01 +0800
commitc924df7ccf6df287035728b65d6f29283b517437 (patch)
treef4d946c2bde1d4938c74276d4cdfc07ef8148f76
parent935c402311f6f46df8265725c8fc3c5b13d4982a (diff)
downloadedk2-c924df7ccf6df287035728b65d6f29283b517437.tar.gz
edk2-c924df7ccf6df287035728b65d6f29283b517437.tar.bz2
edk2-c924df7ccf6df287035728b65d6f29283b517437.zip
IntelSiliconPkg IntelVTdDxe: Check HeaderType if func 0 is implemented
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1169 Current code checks HeaderType of Function 0 even Function 0 is not implemented. HeaderType value will be 0xFF if Function 0 is not implemented, then MaxFunction will be set to PCI_MAX_FUNC + 1. The code can be optimized to only check HeaderType if Function 0 is implemented. Test done: With this patch, the result is same with the result after the patch at https://lists.01.org/pipermail/edk2-devel/2018-September/029623.html. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Cc: Tomson Chang <tomson.chang@intel.com> Cc: Jenny Huang <jenny.huang@intel.com> Cc: Amy Chan <amy.chan@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> (cherry picked from commit b06dfd40bb5cf9fdd626a79a300253f193b600ae)
-rw-r--r--IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c
index 305995de03..6ae5df589c 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c
@@ -231,19 +231,13 @@ ScanPciBus (
UINT8 HeaderType;
UINT8 BaseClass;
UINT8 SubClass;
- UINT32 MaxFunction;
UINT16 VendorID;
UINT16 DeviceID;
EFI_STATUS Status;
// Scan the PCI bus for devices
- for (Device = 0; Device < PCI_MAX_DEVICE + 1; Device++) {
- HeaderType = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, 0, PCI_HEADER_TYPE_OFFSET));
- MaxFunction = PCI_MAX_FUNC + 1;
- if ((HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00) {
- MaxFunction = 1;
- }
- for (Function = 0; Function < MaxFunction; Function++) {
+ for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {
+ for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
VendorID = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_VENDOR_ID_OFFSET));
DeviceID = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_DEVICE_ID_OFFSET));
if (VendorID == 0xFFFF && DeviceID == 0xFFFF) {
@@ -275,6 +269,16 @@ ScanPciBus (
}
}
}
+
+ if (Function == 0) {
+ HeaderType = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, 0, PCI_HEADER_TYPE_OFFSET));
+ if ((HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00) {
+ //
+ // It is not a multi-function device, do not scan other functions.
+ //
+ break;
+ }
+ }
}
}