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.120; helo=mga04.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 7B788202E5E70 for ; Thu, 2 Nov 2017 22:57:02 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2017 23:00:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,337,1505804400"; d="scan'208";a="171430049" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 02 Nov 2017 23:00:56 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 2 Nov 2017 23:00:56 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 2 Nov 2017 23:00:56 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 3 Nov 2017 14:00:53 +0800 From: "Yao, Jiewen" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR table Thread-Index: AQHTVGYze/P+NZMCw02Lafg/M3UOIaMCKUkg Date: Fri, 3 Nov 2017 06:00:53 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AA0DC9C@shsmsx102.ccr.corp.intel.com> References: <1509687597-63876-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1509687597-63876-1-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTI1MmIzYjQtMWJhMi00MTg0LThkYzUtYzYwZmIyZDJjOTdlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJpdW90ZmprcFwvKzVXdTJSRXMxZTZ0a1p4eVEyTXZvQkprWHRIRTdJOUhqTUl4TFFKbk5vWGFUU0lHXC9kYXFLcTAifQ== x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR table X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Nov 2017 05:57:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Looks good to remove the dependency. Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Zeng, Star > Sent: Friday, November 3, 2017 1:40 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Yao, Jiewen > Subject: [PATCH] IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get= DMAR > table >=20 > Use ACPI table event to get DMAR table instead of using ACPI SDT > notification as ACPI SDT is optional and the default value of > PcdInstallAcpiSdtProtocol is FALSE in MdeModulePkg.dec. >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > .../Feature/VTd/IntelVTdDxe/DmaProtection.c | 55 > +++++++++++++--------- > .../Feature/VTd/IntelVTdDxe/DmaProtection.h | 1 - > .../Feature/VTd/IntelVTdDxe/DmarAcpiTable.c | 8 +++- > .../Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf | 12 +++-- > 4 files changed, 46 insertions(+), 30 deletions(-) >=20 > diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c > b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c > index 4a4d82e7f106..6052a0aebe45 100644 > --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c > +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c > @@ -13,7 +13,6 @@ >=20 > #include "DmaProtection.h" >=20 > -EFI_ACPI_SDT_PROTOCOL *mAcpiSdt; > UINT64 mBelow4GMemoryLimit; > UINT64 mAbove4GMemoryLimit; >=20 > @@ -350,11 +349,6 @@ SetupVtd ( > // > // 1. setup > // > - DEBUG ((DEBUG_INFO, "GetDmarAcpiTable\n")); > - Status =3D GetDmarAcpiTable (); > - if (EFI_ERROR (Status)) { > - return; > - } > DEBUG ((DEBUG_INFO, "ParseDmarAcpiTable\n")); > Status =3D ParseDmarAcpiTableDrhd (); > if (EFI_ERROR (Status)) { > @@ -399,27 +393,29 @@ SetupVtd ( > } >=20 > /** > - ACPI notification function. > + Notification function of ACPI Table change. > + > + This is a notification function registered on ACPI Table change event. >=20 > - @param[in] Table A pointer to the ACPI table header. > - @param[in] Version The ACPI table's version. > - @param[in] TableKey The table key for this ACPI table. > + @param Event Event whose notification function is being invoke= d. > + @param Context Pointer to the notification function's context. >=20 > - @retval EFI_SUCCESS The notification function is executed. > **/ > -EFI_STATUS > +VOID > EFIAPI > AcpiNotificationFunc ( > - IN EFI_ACPI_SDT_HEADER *Table, > - IN EFI_ACPI_TABLE_VERSION Version, > - IN UINTN TableKey > + IN EFI_EVENT Event, > + IN VOID *Context > ) > { > - if (Table->Signature =3D=3D EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE= ) > { > - DEBUG((DEBUG_INFO, "Vtd AcpiNotificationFunc\n")); > - SetupVtd (); > + EFI_STATUS Status; > + > + Status =3D GetDmarAcpiTable (); > + if (EFI_ERROR (Status)) { > + return; > } > - return EFI_SUCCESS; > + SetupVtd (); > + gBS->CloseEvent (Event); > } >=20 > /** > @@ -474,11 +470,26 @@ InitializeDmaProtection ( > EFI_STATUS Status; > EFI_EVENT ExitBootServicesEvent; > EFI_EVENT LegacyBootEvent; > - > - Status =3D gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID = **) > &mAcpiSdt); > + EFI_EVENT Event; > + > + Status =3D gBS->CreateEventEx ( > + EVT_NOTIFY_SIGNAL, > + TPL_CALLBACK, > + AcpiNotificationFunc, > + NULL, > + &gEfiAcpi10TableGuid, > + &Event > + ); > ASSERT_EFI_ERROR (Status); >=20 > - Status =3D mAcpiSdt->RegisterNotify (TRUE, AcpiNotificationFunc); > + Status =3D gBS->CreateEventEx ( > + EVT_NOTIFY_SIGNAL, > + TPL_CALLBACK, > + AcpiNotificationFunc, > + NULL, > + &gEfiAcpi20TableGuid, > + &Event > + ); > ASSERT_EFI_ERROR (Status); >=20 > Status =3D gBS->CreateEventEx ( > diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h > b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h > index f7b5292f23e8..0886647ea673 100644 > --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h > +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h > @@ -36,7 +36,6 @@ > #include > #include > #include > -#include > #include > #include >=20 > diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > index 39b70a134e1e..81dec109675b 100644 > --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > @@ -989,6 +989,10 @@ GetDmarAcpiTable ( > VOID *AcpiTable; > EFI_STATUS Status; >=20 > + if (mAcpiDmarTable !=3D NULL) { > + return EFI_SUCCESS; > + } > + > AcpiTable =3D NULL; > Status =3D EfiGetSystemConfigurationTable ( > &gEfiAcpi20TableGuid, > @@ -1006,10 +1010,10 @@ GetDmarAcpiTable ( >=20 > (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, > EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE > ); > - DEBUG ((DEBUG_INFO,"DMAR Table - 0x%08x\n", mAcpiDmarTable)); > if (mAcpiDmarTable =3D=3D NULL) { > - return EFI_UNSUPPORTED; > + return EFI_NOT_FOUND; > } > + DEBUG ((DEBUG_INFO,"DMAR Table - 0x%08x\n", mAcpiDmarTable)); > VtdDumpDmarTable(); >=20 > return EFI_SUCCESS; > diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf > b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf > index fde33bb224ca..bfb677704069 100644 > --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf > +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf > @@ -63,12 +63,15 @@ [LibraryClasses] >=20 > [Guids] > gEfiEventExitBootServicesGuid ## CONSUMES ## Event > - gEfiAcpi20TableGuid ## CONSUMES ## SystemTable > - gEfiAcpi10TableGuid ## CONSUMES ## SystemTable > + ## CONSUMES ## SystemTable > + ## CONSUMES ## Event > + gEfiAcpi20TableGuid > + ## CONSUMES ## SystemTable > + ## CONSUMES ## Event > + gEfiAcpi10TableGuid >=20 > [Protocols] > gEdkiiIoMmuProtocolGuid ## PRODUCES > - gEfiAcpiSdtProtocolGuid ## CONSUMES > gEfiPciIoProtocolGuid ## CONSUMES > gEfiPciEnumerationCompleteProtocolGuid ## CONSUMES > gEdkiiPlatformVTdPolicyProtocolGuid ## SOMETIMES_CONSUMES > @@ -77,8 +80,7 @@ [Pcd] > gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask ## > CONSUMES >=20 > [Depex] > - gEfiPciRootBridgeIoProtocolGuid AND > - gEfiAcpiSdtProtocolGuid > + gEfiPciRootBridgeIoProtocolGuid >=20 > [UserExtensions.TianoCore."ExtraFiles"] > IntelVTdDxeExtra.uni > -- > 2.7.0.windows.1