From: Star Zeng Date: Thu, 13 Sep 2018 02:07:30 +0000 (+0800) Subject: IntelSiliconPkg IntelVTdDxe: Optimize when func 0 is not implemented X-Git-Tag: edk2-stable201903~1025 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=e69d7e99e77d2f7aa1390502d8b42d61f9aeb99a IntelSiliconPkg IntelVTdDxe: Optimize when func 0 is not implemented REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1169 PCI spec: They are also required to always implement function 0 in the device. Implementing other functions is optional and may be assigned in any order (i.e., a two-function device must respond to function 0 but can choose any of the other possible function numbers (1-7) for the second function). This patch updates ScanPciBus() to not scan other functions if function 0 is not implemented. Test done: Added debug code below in the second loop of ScanPciBus(), compared the debug logs with and without this patch, many non-0 unimplemented functions are skipped correctly. DEBUG (( DEBUG_INFO, "%a() B%02xD%02xF%02x VendorId: %04x DeviceId: %04x\n", __FUNCTION__, Bus, Device, Function, VendorID, DeviceID )); Cc: Jiewen Yao Cc: Rangasai V Chaganty Cc: Tomson Chang Cc: Jenny Huang Cc: Amy Chan Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Ruiyu Ni Reviewed-by: Jiewen Yao --- diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c index 36750b3f1d..305995de03 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -247,6 +247,12 @@ ScanPciBus ( 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) { + if (Function == 0) { + // + // If function 0 is not implemented, do not scan other functions. + // + break; + } continue; }