From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 B354120958BFC for ; Thu, 31 Aug 2017 23:21:29 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 31 Aug 2017 23:24:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,456,1498546800"; d="scan'208";a="306836483" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 31 Aug 2017 23:24:13 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 31 Aug 2017 23:24:13 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 31 Aug 2017 23:24:13 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.168]) with mapi id 14.03.0319.002; Fri, 1 Sep 2017 14:24:11 +0800 From: "Wu, Hao A" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make sure alloc physical mem Thread-Index: AQHTIjksTzB/yNkJ502XJK4OlpkbXqKfkWOg Date: Fri, 1 Sep 2017 06:24:11 +0000 Message-ID: References: <1504170679-7412-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1504170679-7412-1-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make sure alloc physical mem 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, 01 Sep 2017 06:21:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of St= ar > Zeng > Sent: Thursday, August 31, 2017 5:11 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu; Wu, Hao A; Zeng, Star > Subject: [edk2] [PATCH] SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make > sure alloc physical mem >=20 > PI 1.6 has supported pre permanent memory page allocation, > to make sure the allocated memory is physical memory for DMA, > the patch is to check memory discovered PPI installed or not first > before calling AllocatePages. >=20 > Cc: Ruiyu Ni > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > .../DebugCommunicationLibUsb3Pei.c | 28 +++++++++++++++-= ------ > .../DebugCommunicationLibUsb3Pei.inf | 5 +++- > 2 files changed, 24 insertions(+), 9 deletions(-) >=20 > diff --git > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.c > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.c > index be3174e75fd6..902a3b626acc 100644 > --- > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.c > +++ > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.c > @@ -1,7 +1,7 @@ > /** @file > Debug Port Library implementation based on usb3 debug port. >=20 > - Copyright (c) 2014, Intel Corporation. All rights reserved.
> + Copyright (c) 2014 - 2017, 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 > @@ -14,6 +14,7 @@ >=20 > #include > #include > +#include > #include "DebugCommunicationLibUsb3Internal.h" >=20 > /** > @@ -32,13 +33,24 @@ AllocateAlignBuffer ( > VOID *Buf; > EFI_PHYSICAL_ADDRESS Address; > EFI_STATUS Status; > - > - Buf =3D NULL; > - Status =3D PeiServicesAllocatePages (EfiACPIMemoryNVS, EFI_SIZE_TO_PAG= ES > (BufferSize), &Address); > - if (EFI_ERROR (Status)) { > - Buf =3D NULL; > - } else { > - Buf =3D (VOID *)(UINTN) Address; > + VOID *MemoryDiscoveredPpi; > + > + Buf =3D NULL; > + > + // > + // Make sure the allocated memory is physical memory. > + // > + Status =3D PeiServicesLocatePpi ( > + &gEfiPeiMemoryDiscoveredPpiGuid, > + 0, > + NULL, > + (VOID **) &MemoryDiscoveredPpi > + ); > + if (!EFI_ERROR (Status)) { > + Status =3D PeiServicesAllocatePages (EfiACPIMemoryNVS, > EFI_SIZE_TO_PAGES (BufferSize), &Address); > + if (!EFI_ERROR (Status)) { > + Buf =3D (VOID *)(UINTN) Address; > + } > } > return Buf; > } > diff --git > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.inf > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.inf > index 74dcdd124b47..6cd5e1068333 100644 > --- > a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.inf > +++ > b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommun > icationLibUsb3Pei.inf > @@ -1,7 +1,7 @@ > ## @file > # Debug Communication Library instance based on usb3 debug port. > # > -# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved. > +# Copyright (c) 2014 - 2017, 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 > @@ -40,6 +40,9 @@ [Packages] > IntelFrameworkPkg/IntelFrameworkPkg.dec > SourceLevelDebugPkg/SourceLevelDebugPkg.dec >=20 > +[Ppis] > + gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES > + > [Pcd] > # The memory BAR of ehci host controller, in which usb debug feature i= s > enabled. > # Note that the memory BAR address is only used before Pci bus resourc= e > allocation. > -- > 2.7.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel