From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 8855D2112DF43 for ; Wed, 12 Sep 2018 20:09:59 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2018 20:09:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,367,1531810800"; d="scan'208";a="83082664" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.8]) ([10.239.9.8]) by orsmga003.jf.intel.com with ESMTP; 12 Sep 2018 20:09:52 -0700 To: Star Zeng , edk2-devel@lists.01.org Cc: Tomson Chang , Jiewen Yao , Jenny Huang , Amy Chan References: <1536804602-13240-1-git-send-email-star.zeng@intel.com> From: "Ni, Ruiyu" Message-ID: <7a0c6bc9-eb4d-6e84-8bd1-fac8bab6e1ed@Intel.com> Date: Thu, 13 Sep 2018 11:10:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1536804602-13240-1-git-send-email-star.zeng@intel.com> Subject: Re: [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 03:09:59 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 9/13/2018 10:10 AM, Star Zeng wrote: > 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; > } > > Reviewed-by: Ruiyu Ni -- Thanks, Ray