From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Zeng, Star" <star.zeng@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Chaganty, Rangasai V" <rangasai.v.chaganty@intel.com>,
"Chang, Tomson" <tomson.chang@intel.com>,
"Huang, Jenny" <jenny.huang@intel.com>,
"Chan, Amy" <amy.chan@intel.com>,
"Ni, Ruiyu" <ruiyu.ni@intel.com>
Subject: Re: [PATCH] IntelSiliconPkg IntelVTdDxe: Check HeaderType if func 0 is implemented
Date: Thu, 13 Sep 2018 13:37:43 +0000 [thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AD5A2B2@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1536820151-15264-1-git-send-email-star.zeng@intel.com>
Reviewed-by: jiewen.yao@intel.com
> -----Original Message-----
> From: Zeng, Star
> Sent: Thursday, September 13, 2018 2:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Chang, Tomson
> <tomson.chang@intel.com>; Huang, Jenny <jenny.huang@intel.com>; Chan,
> Amy <amy.chan@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [PATCH] 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>
> ---
> IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c | 20
> ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c
> b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c
> index 305995de032c..6ae5df589c1e 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;
> + }
> + }
> }
> }
>
> --
> 2.7.0.windows.1
prev parent reply other threads:[~2018-09-13 13:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-13 6:29 [PATCH] IntelSiliconPkg IntelVTdDxe: Check HeaderType if func 0 is implemented Star Zeng
2018-09-13 13:37 ` Yao, Jiewen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=74D8A39837DF1E4DA445A8C0B3885C503AD5A2B2@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox