From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B537421B02822 for ; Wed, 12 Sep 2018 19:10:06 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2018 19:10:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,367,1531810800"; d="scan'208";a="85529527" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga002.fm.intel.com with ESMTP; 12 Sep 2018 19:10:04 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Jiewen Yao , Rangasai V Chaganty , Tomson Chang , Jenny Huang , Amy Chan Date: Thu, 13 Sep 2018 10:10:02 +0800 Message-Id: <1536804602-13240-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH] IntelSiliconPkg IntelVTdDxe: Optimize when func 0 is not implemented X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2018 02:10:06 -0000 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 --- IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c index 36750b3f1d9c..305995de032c 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; } -- 2.7.0.windows.1