From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.17946.1646036246913914182 for ; Mon, 28 Feb 2022 00:17:27 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=G3zCtXUu; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646036246; x=1677572246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HD3/TAUpw2MuukTMYKsrFPScFSat60qdPJcGcL3DbjU=; b=G3zCtXUuNgMQPzJc1QM6PWqAZhyKTo8nKChA6x8HCpj/UMxDs9l6O1nj QmzXb9PuA1AamM6QND4aK2aRVenrZSPzfujX8RXWnyoU7WZKUneGFkqzC Hi36o0DvFXt0AaD3FXyFVMTIA6JsuUdxp9wAQxYbhmLGJvjZWFtEhwY+T XaaewbQGaTEcJ0YfTRt3xX+W3CAQQDWeO00dET4P4Y5fpub9CNvFDOio3 2HX/XEkrQFs8eVwH9ZcuzaDI/F2lwQSv9LHjHe4M4H922ES63Qd2tRpMs tuB8iynwlGZqD6/o6++g5cPhM1xvudt4AsOtxUw50MYdwn6M+/5PGrAX4 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="339269015" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="339269015" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 00:17:26 -0800 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="550140217" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.2.184]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 00:17:23 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Jian J Wang , Liming Gao , Hao A Wu , Ray Ni , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH V4 09/10] MdeModulePkg: Update PciEnumeratorSupport to ignore OptionRom if needed Date: Mon, 28 Feb 2022 16:16:30 +0800 Message-Id: <20220228081631.681-10-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20220228081631.681-1-min.m.xu@intel.com> References: <20220228081631.681-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Function of UpdatePciInfo() in PciEnumeratorSupport.c is used to update the bar information for those incompatible PCI device. It is the right place to check if the OptionRom need to be ignored. According to "Table 20. ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage" in PI Spec 1.7, Type-specific flags can be set to 0 when Address Translation Offset == 6 to skip device option ROM (do not probe option rom BAR). Cc: Jian J Wang Cc: Liming Gao Cc: Hao A Wu Cc: Ray Ni Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Signed-off-by: Min Xu --- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 23 +++++++++++++++---- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.h | 4 +++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index 9251388bc268..509f828b621d 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -220,8 +220,10 @@ PciSearchDevice ( ) { PCI_IO_DEVICE *PciIoDevice; + BOOLEAN IgnoreOptionRom; - PciIoDevice = NULL; + PciIoDevice = NULL; + IgnoreOptionRom = FALSE; DEBUG (( DEBUG_INFO, @@ -285,7 +287,7 @@ PciSearchDevice ( // // Update the bar information for this PCI device so as to support some specific device // - UpdatePciInfo (PciIoDevice); + UpdatePciInfo (PciIoDevice, &IgnoreOptionRom); if (PciIoDevice->DevicePath == NULL) { return EFI_OUT_OF_RESOURCES; @@ -295,7 +297,7 @@ PciSearchDevice ( // Detect this function has option rom // if (gFullEnumeration) { - if (!IS_CARDBUS_BRIDGE (Pci)) { + if (!IS_CARDBUS_BRIDGE (Pci) && !IgnoreOptionRom) { GetOpRomInfo (PciIoDevice); } @@ -1310,6 +1312,7 @@ DetermineDeviceAttribute ( @param PciIoDevice Input Pci device instance. Output Pci device instance with updated Bar information. + @param IgnoreOptionRom Output If the option rom of incompatible device need to be ignored. @retval EFI_SUCCESS Successfully updated bar information. @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list. @@ -1317,7 +1320,8 @@ DetermineDeviceAttribute ( **/ EFI_STATUS UpdatePciInfo ( - IN OUT PCI_IO_DEVICE *PciIoDevice + IN OUT PCI_IO_DEVICE *PciIoDevice, + OUT BOOLEAN *IgnoreOptionRom ) { EFI_STATUS Status; @@ -1374,6 +1378,17 @@ UpdatePciInfo ( break; } + // + // According to "Table 20. ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage" + // in PI Spec 1.7, Type-specific flags can be set to 0 when Address Translation + // Offset == 6 to skip device option ROM (do not probe option rom BAR). + // + if (((Ptr->AddrTranslationOffset == PCI_MAX_BAR) && (Ptr->SpecificFlag == 0))) { + *IgnoreOptionRom = TRUE; + Ptr++; + continue; + } + for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) { if ((Ptr->AddrTranslationOffset != MAX_UINT64) && (Ptr->AddrTranslationOffset != MAX_UINT8) && diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h index 0ded4bea4f89..7daa6e020d09 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h @@ -262,6 +262,7 @@ DetermineDeviceAttribute ( @param PciIoDevice Input Pci device instance. Output Pci device instance with updated Bar information. + @param IgnoreOptionRom Output If the option rom of incompatible device need to be ignored. @retval EFI_SUCCESS Successfully updated bar information. @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list. @@ -269,7 +270,8 @@ DetermineDeviceAttribute ( **/ EFI_STATUS UpdatePciInfo ( - IN OUT PCI_IO_DEVICE *PciIoDevice + IN OUT PCI_IO_DEVICE *PciIoDevice, + OUT BOOLEAN *IgnoreOptionRom ); /** -- 2.29.2.windows.2