From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 0237481FC3 for ; Mon, 13 Feb 2017 18:15:47 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 13 Feb 2017 18:15:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,158,1484035200"; d="scan'208";a="64358707" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 13 Feb 2017 18:15:46 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 13 Feb 2017 18:15:46 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 13 Feb 2017 18:15:45 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0248.002; Tue, 14 Feb 2017 10:15:43 +0800 From: "Wei, David" To: "Lu, ShifeiX A" , "edk2-devel@lists.01.org" CC: "Wei, David" Thread-Topic: [Patch][edk2-platforms/devel-MinnowBoard3] Fixed Map-r issue. Thread-Index: AQHShmf4M2AZmjvV6E+SZtxe0pPt5qFnw3jw Date: Tue, 14 Feb 2017 02:15:42 +0000 Message-ID: <89954A0B46707A448411A627AD4EEE3468EF95A3@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch][edk2-platforms/devel-MinnowBoard3] Fixed Map-r issue. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Feb 2017 02:15:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: David Wei Thanks, David Wei =20 -----Original Message----- From: Lu, ShifeiX A=20 Sent: Tuesday, February 14, 2017 10:14 AM To: edk2-devel@lists.01.org Cc: Wei, David Subject: [Patch][edk2-platforms/devel-MinnowBoard3] Fixed Map-r issue. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: lushifex --- .../SouthCluster/Include/MediaDeviceDriver.h | 22 ++- .../Sdio/Dxe/MMC/MmcMediaDeviceDxe/MMCSDTransfer.c | 4 +- .../Dxe/MMC/MmcMediaDeviceDxe/MediaDeviceDriver.c | 219 ++++++++++++++---= ---- 3 files changed, 169 insertions(+), 76 deletions(-) diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDevi= ceDriver.h b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDevi= ceDriver.h index 243ee9a..1c9ad1c 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDeviceDrive= r.h +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDeviceDrive= r.h @@ -1,7 +1,7 @@ /** @file Media Device Driver header. =20 - Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -172,6 +172,7 @@ MediaDeviceDriverEntryPoint ( /** MediaDeviceDriverInstallBlockIo =20 + @param[in] This @param[in] CardData =20 @retval EFI_STATUS @@ -179,23 +180,38 @@ MediaDeviceDriverEntryPoint ( **/ EFI_STATUS MediaDeviceDriverInstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData ); =20 /** MediaDeviceDriverUninstallBlockIo =20 + @param[in] This @param[in] CardData + @param[in] Handle =20 @retval EFI_STATUS =20 **/ EFI_STATUS MediaDeviceDriverUninstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData, + IN EFI_HANDLE Handle ); =20 /** + MediaDeviceDriverAllPartitionNotPresent + + @param[in] CardData + +**/ +BOOLEAN +MediaDeviceDriverAllPartitionNotPresent ( + IN CARD_DATA *CardData + ); +/** MediaDeviceComponentNameGetDriverName =20 @param[in] This diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcM= ediaDeviceDxe/MMCSDTransfer.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluste= r/Sdio/Dxe/MMC/MmcMediaDeviceDxe/MMCSDTransfer.c index a6280a5..d367326 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MMCSDTransfer.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MMCSDTransfer.c @@ -1,7 +1,7 @@ /** @file SMMC transfer specific functions. =20 - Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -2268,7 +2268,7 @@ SetEmmcWpOnEvent( // // Enable the eMMC protection // - if (TRUE) { + if (FALSE) { if (!WriteProtectDone) { Status =3D MmcReadExtCsd (CardData); if (EFI_ERROR (Status)) { diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcM= ediaDeviceDxe/MediaDeviceDriver.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCl= uster/Sdio/Dxe/MMC/MmcMediaDeviceDxe/MediaDeviceDriver.c index 36c6e13..7f5bd11 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MediaDeviceDriver.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MediaDeviceDriver.c @@ -1,7 +1,7 @@ /** @file UEFI Driver Entry and Binding support. =20 - Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -28,6 +28,7 @@ EFI_DRIVER_BINDING_PROTOCOL gMediaDeviceDriverBinding =3D= { NULL }; =20 +EFI_EMMC_CARD_INFO_PROTOCOL *gEfiEmmcCardInfo =3D NULL; =20 /** Entry point for EFI drivers. @@ -229,7 +230,7 @@ MediaDeviceDriverBindingStart ( } =20 =20 - Status =3D MediaDeviceDriverInstallBlockIo (CardData); + Status =3D MediaDeviceDriverInstallBlockIo (This, CardData); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "MediaDeviceDriverBindingStart: Fail to install g= EfiBlockIoProtocolGuid \n")); goto Exit; @@ -246,7 +247,20 @@ MediaDeviceDriverBindingStart ( ); if (EFI_ERROR (Status)) { Status =3D EFI_OUT_OF_RESOURCES; - MediaDeviceDriverUninstallBlockIo (CardData); + for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Loop++) { + if (!CardData->Partitions[Loop].Present) { + continue; + } + gBS->UninstallMultipleProtocolInterfaces ( + CardData->Partitions[Loop].Handle, + &gEfiBlockIoProtocolGuid, + &CardData->Partitions[Loop].BlockIo, + &gEfiDevicePathProtocolGuid, + CardData->Partitions[Loop].DevPath, + NULL + ); + } + goto Exit; } if (EfiEmmcCardInfoRegister !=3D NULL) { =20 @@ -263,9 +277,24 @@ MediaDeviceDriverBindingStart ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "MediaDeviceDriverBindingStart: Install eMMC Ca= rd info protocol failed\n")); - MediaDeviceDriverUninstallBlockIo (CardData); + for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Loop++) { + if (!CardData->Partitions[Loop].Present) { + continue; + } + gBS->UninstallMultipleProtocolInterfaces ( + CardData->Partitions[Loop].Handle, + &gEfiBlockIoProtocolGuid, + &CardData->Partitions[Loop].BlockIo, + &gEfiDevicePathProtocolGuid, + CardData->Partitions[Loop].DevPath, + NULL + ); + } + goto Exit; } + + gEfiEmmcCardInfo =3D EfiEmmcCardInfoRegister; } =20 DEBUG ((DEBUG_INFO, "MediaDeviceDriverBindingStart: Started\n")); @@ -275,7 +304,7 @@ Exit: DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStart: End with failure\= n")); if (CardData !=3D NULL && MmcHostIo !=3D NULL) { if (CardData->RawBufferPointer !=3D NULL) { - gBS->FreePages ((EFI_PHYSICAL_ADDRESS) CardData->RawBufferPointer,= EFI_SIZE_TO_PAGES (MmcHostIo->HostCapability.BoundarySize * 2)); + gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) CardData->RawBuffer= Pointer, EFI_SIZE_TO_PAGES (MmcHostIo->HostCapability.BoundarySize * 2)); } FreePool (CardData); } @@ -314,70 +343,102 @@ MediaDeviceDriverBindingStop ( { EFI_STATUS Status; CARD_DATA *CardData; - EFI_BLOCK_IO_PROTOCOL *BlockIo; + BOOLEAN AllChildrenStopped; + UINTN Index; + UINTN Pages =3D 0; =20 - // - // First find BlockIo Protocol - // - Status =3D gBS->OpenProtocol ( - Controller, - &gEfiBlockIoProtocolGuid, - (VOID**) &BlockIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + Status =3D EFI_SUCCESS; + CardData =3D gEfiEmmcCardInfo->CardData; =20 - if (EFI_ERROR (Status)) { - return Status; - } + if (NumberOfChildren =3D=3D 0) { + Status =3D gBS->UninstallMultipleProtocolInterfaces ( + Controller, + &gEfiEmmcCardInfoProtocolGuid, + gEfiEmmcCardInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStop: UNINSTALL gEfiEm= mcCardInfoProtocolGuid FAILURE\n")); + return Status; + } =20 - gBS->CloseProtocol ( + FreeUnicodeStringTable (CardData->ControllerNameTable); + + Pages =3D (2 * (CardData->MmcHostIo->HostCapability.BoundarySize)); + if (CardData->RawBufferPointer !=3D NULL) { + FreePages (CardData->RawBufferPointer, EFI_SIZE_TO_PAGES(Pages)); + } + + Status =3D gBS->CloseProtocol ( Controller, &gEfiMmcHostIoProtocolGuid, This->DriverBindingHandle, Controller ); =20 - CardData =3D CARD_DATA_FROM_THIS (BlockIo); + if (MediaDeviceDriverAllPartitionNotPresent(CardData)) { + FreePool (CardData); + FreePool (gEfiEmmcCardInfo); + gEfiEmmcCardInfo =3D NULL; + } =20 - // - // Uninstall Block I/O protocol from the device handle - // - Status =3D MediaDeviceDriverUninstallBlockIo (CardData); - if (EFI_ERROR (Status)) { return Status; } =20 - if (CardData !=3D NULL) { - FreeUnicodeStringTable (CardData->ControllerNameTable); - if (CardData->RawBufferPointer !=3D NULL) { - FreePool (CardData->RawBufferPointer); + AllChildrenStopped =3D TRUE; + for (Index =3D 0; Index < NumberOfChildren; Index++) { + Status =3D MediaDeviceDriverUninstallBlockIo(This, CardData, ChildHand= leBuffer[Index]); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStop: UNINSTALL block = io FAILURE\n")); + AllChildrenStopped =3D FALSE; + break; } - FreePool (CardData); } =20 return Status; } =20 =20 +BOOLEAN +MediaDeviceDriverAllPartitionNotPresent ( + IN CARD_DATA *CardData + ) +{ + BOOLEAN AllPartitionNotPresent; + UINTN Loop; + MMC_PARTITION_DATA *Partition; + + Partition =3D CardData->Partitions; + + AllPartitionNotPresent =3D TRUE; + + for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Partition++, Loop++) { + if (Partition->Present) { + AllPartitionNotPresent =3D FALSE; + break; + } + } + + return AllPartitionNotPresent; +} + + STATIC struct { - CONTROLLER_DEVICE_PATH Controller; + DEVICE_LOGICAL_UNIT_DEVICE_PATH LogicalUnit; EFI_DEVICE_PATH_PROTOCOL End; -} ControllerDevPathTemplate =3D { +} EmmcDevPathTemplate =3D { { { - HARDWARE_DEVICE_PATH, - HW_CONTROLLER_DP, + MESSAGING_DEVICE_PATH, + MSG_DEVICE_LOGICAL_UNIT_DP, { - sizeof (CONTROLLER_DEVICE_PATH), + sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH), 0 }, }, 0 }, - { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, @@ -392,6 +453,7 @@ struct { /** MediaDeviceDriverInstallBlockIo =20 + @param[in] This Pointer to the EFI_DRIVER_BINDING_PR= OTOCOL. @param[in] CardData Pointer to CARD_DATA =20 @retval EFI_INVALID_PARAMETER @@ -401,13 +463,15 @@ struct { **/ EFI_STATUS MediaDeviceDriverInstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData ) { EFI_STATUS Status; - UINTN Loop; + UINT8 Loop; MMC_PARTITION_DATA *Partition; EFI_DEVICE_PATH_PROTOCOL *MainPath; + EFI_MMC_HOST_IO_PROTOCOL *MmcHostIo =3D NULL; =20 Partition =3D CardData->Partitions; =20 @@ -430,13 +494,12 @@ MediaDeviceDriverInstallBlockIo ( Partition->Handle =3D NULL; Partition->CardData =3D CardData; =20 - ControllerDevPathTemplate.Controller.ControllerNumber =3D (UINT32) Loo= p; + EmmcDevPathTemplate.LogicalUnit.Lun =3D Loop; Partition->DevPath =3D AppendDevicePath ( MainPath, - (EFI_DEVICE_PATH_PROTOCOL *) &ControllerDevPathTemplate + (EFI_DEVICE_PATH_PROTOCOL *) &EmmcDevPathTemplate ); - if (Partition->DevPath =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; break; @@ -460,29 +523,16 @@ MediaDeviceDriverInstallBlockIo ( ); =20 // - // Handle Boot partitions + // Open parent controller by child // - if (CardData->CardType =3D=3D MMCCard) { - // - // skip unbootable partitions display on boot manager - // - // Loop [0] OS boot partition - // Loop [1] BIOS LBP1 - // Loop [2] BIOS LBP2 - // Loop [3] GPP1 - // Loop [4] GPP2 - // Loop [5] GPP3 - // Loop [6] GPP4 - // - if (Loop !=3D 0) { - Status =3D gBS->InstallProtocolInterface ( - &(Partition->Handle), - &gEfiUnbootablePartitionGuid, - EFI_NATIVE_INTERFACE, - NULL - ); - } - } + Status =3D gBS->OpenProtocol ( + CardData->Handle, + &gEfiMmcHostIoProtocolGuid, + (VOID **) &MmcHostIo, + This->DriverBindingHandle, + Partition->Handle, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER + ); } =20 return Status; @@ -492,7 +542,9 @@ MediaDeviceDriverInstallBlockIo ( /** MediaDeviceDriverUninstallBlockIo =20 + @param[in] This Pointer to the EFI_DRIVER_BINDING_P= ROTOCOL. @param[in] CardData Pointer to CARD_DATA + @param[in] Handle Handle of Partition =20 @retval EFI_INVALID_PARAMETER @retval EFI_UNSUPPORTED @@ -501,7 +553,9 @@ MediaDeviceDriverInstallBlockIo ( **/ EFI_STATUS MediaDeviceDriverUninstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData, + IN EFI_HANDLE Handle ) { EFI_STATUS Status; @@ -512,17 +566,40 @@ MediaDeviceDriverUninstallBlockIo ( Status =3D EFI_SUCCESS; =20 for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Partition++, Loop++) { - if (!Partition->Present) { - continue; + if (!Partition->Present || Partition->Handle !=3D Handle) { + continue; } =20 - Status =3D gBS->UninstallProtocolInterface ( + // + // Close MmcHostIoProtocol by child + // + Status =3D gBS->CloseProtocol ( + CardData->Handle, + &gEfiMmcHostIoProtocolGuid, + This->DriverBindingHandle, + Partition->Handle + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "CloseProtocol gEfiMmcHostIoProtocolGuid FAILUR= E \n")); + return Status; + } + + Status =3D gBS->UninstallMultipleProtocolInterfaces ( Partition->Handle, &gEfiBlockIoProtocolGuid, - &Partition->BlockIo + &Partition->BlockIo, + &gEfiDevicePathProtocolGuid, + Partition->DevPath, + NULL ); + Partition->Present =3D FALSE; + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStop gEfiBlockIoProtocol= Guid removed. %x\n", Status)); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverUninstallBlockIo UNISTALL FAI= LURE \n")); + } + return Status; } =20 - return Status; + return EFI_INVALID_PARAMETER; } =20 --=20 2.7.0.windows.1