From nobody Wed May 8 10:01:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490146117732192.78099289222666; Tue, 21 Mar 2017 18:28:37 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BB09580424; Tue, 21 Mar 2017 18:28:34 -0700 (PDT) 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 787D0803D2 for ; Tue, 21 Mar 2017 18:28:32 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 21 Mar 2017 18:28:32 -0700 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by orsmga002.jf.intel.com with ESMTP; 21 Mar 2017 18:28:31 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,202,1486454400"; d="scan'208";a="63424770" From: Hao Wu To: edk2-devel@lists.01.org Date: Wed, 22 Mar 2017 09:28:25 +0800 Message-Id: <20170322012826.13016-2-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170322012826.13016-1-hao.a.wu@intel.com> References: <20170322012826.13016-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 1/2] MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX' 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: , Cc: Hao Wu , Feng Tian MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Feng Tian --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 26 ++++---- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 70 ++++++++++------= ---- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 7c831e92d0..63b90de991 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -1,6 +1,6 @@ /** @file =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -784,7 +784,7 @@ UfsPassThruDriverBindingStart ( Private =3D NULL; UfsHcBase =3D 0; =20 - DEBUG ((EFI_D_INFO, "=3D=3DUfsPassThru Start=3D=3D Controller =3D %x\n",= Controller)); + DEBUG ((DEBUG_INFO, "=3D=3DUfsPassThru Start=3D=3D Controller =3D %x\n",= Controller)); =20 Status =3D gBS->OpenProtocol ( Controller, @@ -796,7 +796,7 @@ UfsPassThruDriverBindingStart ( ); =20 if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Open Ufs Host Controller Protocol Error, Status = =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "Open Ufs Host Controller Protocol Error, Status = =3D %r\n", Status)); goto Error; } =20 @@ -805,7 +805,7 @@ UfsPassThruDriverBindingStart ( // Status =3D UfsHc->GetUfsHcMmioBar (UfsHc, &UfsHcBase); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Get Ufs Host Controller Mmio Bar Error, Status = =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "Get Ufs Host Controller Mmio Bar Error, Status = =3D %r\n", Status)); goto Error; } =20 @@ -814,7 +814,7 @@ UfsPassThruDriverBindingStart ( // Private =3D AllocateCopyPool (sizeof (UFS_PASS_THRU_PRIVATE_DATA), &gUfs= PassThruTemplate); if (Private =3D=3D NULL) { - DEBUG ((EFI_D_ERROR, "Unable to allocate Ufs Pass Thru private data\n"= )); + DEBUG ((DEBUG_ERROR, "Unable to allocate Ufs Pass Thru private data\n"= )); Status =3D EFI_OUT_OF_RESOURCES; goto Error; } @@ -829,7 +829,7 @@ UfsPassThruDriverBindingStart ( // Status =3D UfsControllerInit (Private); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Ufs Host Controller Initialization Error, Status= =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "Ufs Host Controller Initialization Error, Status= =3D %r\n", Status)); goto Error; } =20 @@ -840,7 +840,7 @@ UfsPassThruDriverBindingStart ( // Status =3D UfsExecNopCmds (Private); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Ufs Sending NOP IN command Error, Status =3D %r\= n", Status)); + DEBUG ((DEBUG_ERROR, "Ufs Sending NOP IN command Error, Status =3D %r\= n", Status)); goto Error; } =20 @@ -849,7 +849,7 @@ UfsPassThruDriverBindingStart ( // Status =3D UfsSetFlag (Private, UfsFlagDevInit); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Ufs Set fDeviceInit Flag Error, Status =3D %r\n"= , Status)); + DEBUG ((DEBUG_ERROR, "Ufs Set fDeviceInit Flag Error, Status =3D %r\n"= , Status)); goto Error; } =20 @@ -858,7 +858,7 @@ UfsPassThruDriverBindingStart ( // Status =3D UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config,= sizeof (UFS_CONFIG_DESC)); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Ufs Get Configuration Descriptor Error, Status = =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = =3D %r\n", Status)); goto Error; } =20 @@ -869,7 +869,7 @@ UfsPassThruDriverBindingStart ( for (Index =3D 0; Index < 8; Index++) { if (Config.UnitDescConfParams[Index].LunEn !=3D 0) { Private->Luns.BitMask |=3D (BIT0 << Index); - DEBUG ((EFI_D_INFO, "Ufs Lun %d is enabled\n", Index)); + DEBUG ((DEBUG_INFO, "Ufs Lun %d is enabled\n", Index)); } } =20 @@ -884,7 +884,7 @@ UfsPassThruDriverBindingStart ( &Private->TimerEvent ); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Ufs Create Async Tasks Event Error, Status =3D %= r\n", Status)); + DEBUG ((DEBUG_ERROR, "Ufs Create Async Tasks Event Error, Status =3D %= r\n", Status)); goto Error; } =20 @@ -894,7 +894,7 @@ UfsPassThruDriverBindingStart ( UFS_HC_ASYNC_TIMER ); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Ufs Set Periodic Timer Error, Status =3D %r\n", = Status)); + DEBUG ((DEBUG_ERROR, "Ufs Set Periodic Timer Error, Status =3D %r\n", = Status)); goto Error; } =20 @@ -986,7 +986,7 @@ UfsPassThruDriverBindingStop ( LIST_ENTRY *Entry; LIST_ENTRY *NextEntry; =20 - DEBUG ((EFI_D_INFO, "=3D=3DUfsPassThru Stop=3D=3D Controller Controller = =3D %x\n", Controller)); + DEBUG ((DEBUG_INFO, "=3D=3DUfsPassThru Stop=3D=3D Controller Controller = =3D %x\n", Controller)); =20 Status =3D gBS->OpenProtocol ( Controller, diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 3dd8cbfe7a..822554cebb 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -157,34 +157,34 @@ DumpUicCmdExecResult ( case 0x00: break; case 0x01: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - INVALID_= MIB_ATTRIBUTE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - INVALID_= MIB_ATTRIBUTE\n")); break; case 0x02: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - INVALID_= MIB_ATTRIBUTE_VALUE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - INVALID_= MIB_ATTRIBUTE_VALUE\n")); break; case 0x03: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - READ_ONL= Y_MIB_ATTRIBUTE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - READ_ONL= Y_MIB_ATTRIBUTE\n")); break; case 0x04: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - WRITE_ON= LY_MIB_ATTRIBUTE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - WRITE_ON= LY_MIB_ATTRIBUTE\n")); break; case 0x05: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BAD_INDE= X\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BAD_INDE= X\n")); break; case 0x06: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - LOCKED_M= IB_ATTRIBUTE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - LOCKED_M= IB_ATTRIBUTE\n")); break; case 0x07: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BAD_TEST= _FEATURE_INDEX\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BAD_TEST= _FEATURE_INDEX\n")); break; case 0x08: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - PEER_COM= MUNICATION_FAILURE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - PEER_COM= MUNICATION_FAILURE\n")); break;=20 case 0x09: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BUSY\n")= ); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BUSY\n")= ); break; case 0x0A: - DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - DME_FAIL= URE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - DME_FAIL= URE\n")); break; =20 default : ASSERT (FALSE); @@ -195,7 +195,7 @@ DumpUicCmdExecResult ( case 0x00: break; case 0x01: - DEBUG ((EFI_D_VERBOSE, "UIC control command fails - FAILURE\n")); + DEBUG ((DEBUG_VERBOSE, "UIC control command fails - FAILURE\n")); break; =20 default : ASSERT (FALSE); @@ -217,34 +217,34 @@ DumpQueryResponseResult ( { switch (Result) { case 0xF6: - DEBUG ((EFI_D_VERBOSE, "Query Response with Parameter Not Readable\n= ")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Not Readable\n= ")); break; case 0xF7: - DEBUG ((EFI_D_VERBOSE, "Query Response with Parameter Not Writeable\= n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Not Writeable\= n")); break; case 0xF8: - DEBUG ((EFI_D_VERBOSE, "Query Response with Parameter Already Writte= n\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Already Writte= n\n")); break; case 0xF9: - DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Length\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Length\n")); break; case 0xFA: - DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Value\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Value\n")); break; case 0xFB: - DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Selector\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Selector\n")); break; case 0xFC: - DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Index\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Index\n")); break; case 0xFD: - DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Idn\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Idn\n")); break; case 0xFE: - DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Opcode\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Opcode\n")); break;=20 case 0xFF: - DEBUG ((EFI_D_VERBOSE, "Query Response with General Failure\n")); + DEBUG ((DEBUG_VERBOSE, "Query Response with General Failure\n")); break; default : ASSERT (FALSE); @@ -402,7 +402,7 @@ UfsInitUtpPrdt ( =20 if ((BufferSize & (BIT0 | BIT1)) !=3D 0) { BufferSize &=3D ~(BIT0 | BIT1); - DEBUG ((EFI_D_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-= aligned!\n", BufferSize)); + DEBUG ((DEBUG_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-= aligned!\n", BufferSize)); } =20 if (BufferSize =3D=3D 0) { @@ -1559,7 +1559,7 @@ UfsExecScsiCmds ( // Packet->TargetStatus =3D Response->Status; if (Response->Response !=3D 0) { - DEBUG ((EFI_D_ERROR, "UfsExecScsiCmds() fails with Target Failure\n")); + DEBUG ((DEBUG_ERROR, "UfsExecScsiCmds() fails with Target Failure\n")); Status =3D EFI_DEVICE_ERROR; goto Exit; } @@ -1717,7 +1717,7 @@ UfsExecUicCommands ( return EFI_NOT_FOUND; } =20 - DEBUG ((EFI_D_INFO, "UfsPassThruDxe: found a attached UFS device\n")); + DEBUG ((DEBUG_INFO, "UfsPassThruDxe: found a attached UFS device\n")); =20 return EFI_SUCCESS; } @@ -2084,29 +2084,29 @@ UfsControllerInit ( =20 Status =3D UfsEnableHostController (Private); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "UfsControllerInit: Enable Host Controller Fails,= Status =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "UfsControllerInit: Enable Host Controller Fails,= Status =3D %r\n", Status)); return Status; } =20 Status =3D UfsDeviceDetection (Private); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, Statu= s =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "UfsControllerInit: Device Detection Fails, Statu= s =3D %r\n", Status)); return Status; } =20 Status =3D UfsInitTaskManagementRequestList (Private); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "UfsControllerInit: Task management list initiali= zation Fails, Status =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "UfsControllerInit: Task management list initiali= zation Fails, Status =3D %r\n", Status)); return Status; } =20 Status =3D UfsInitTransferRequestList (Private); if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "UfsControllerInit: Transfer list initialization = Fails, Status =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "UfsControllerInit: Transfer list initialization = Fails, Status =3D %r\n", Status)); return Status; } =20 - DEBUG ((EFI_D_INFO, "UfsControllerInit Finished\n")); + DEBUG ((DEBUG_INFO, "UfsControllerInit Finished\n")); return EFI_SUCCESS; } =20 @@ -2167,7 +2167,7 @@ UfsControllerStop ( return EFI_DEVICE_ERROR; } =20 - DEBUG ((EFI_D_INFO, "UfsController is stopped\n")); + DEBUG ((DEBUG_INFO, "UfsController is stopped\n")); =20 return EFI_SUCCESS; } @@ -2274,7 +2274,7 @@ ProcessAsyncTaskList ( // case. // Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHA= SE_ERROR; - DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p Uf= sMmioRead32() Error.\n", TransReq->CallerEvent)); + DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p Uf= sMmioRead32() Error.\n", TransReq->CallerEvent)); SignalCallerEvent (Private, TransReq); continue; } @@ -2291,7 +2291,7 @@ ProcessAsyncTaskList ( // Timeout occurs. // Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_T= IMEOUT_COMMAND; - DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p = EFI_TIMEOUT.\n", TransReq->CallerEvent)); + DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p = EFI_TIMEOUT.\n", TransReq->CallerEvent)); SignalCallerEvent (Private, TransReq); continue; } @@ -2316,7 +2316,7 @@ ProcessAsyncTaskList ( // Packet->TargetStatus =3D Response->Status; if (Response->Response !=3D 0) { - DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p = Target Failure.\n", TransReq->CallerEvent)); + DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p = Target Failure.\n", TransReq->CallerEvent)); SignalCallerEvent (Private, TransReq); continue; } @@ -2336,12 +2336,12 @@ ProcessAsyncTaskList ( } } } else { - DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p = Target Device Error.\n", TransReq->CallerEvent)); + DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p = Target Device Error.\n", TransReq->CallerEvent)); SignalCallerEvent (Private, TransReq); continue; } =20 - DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p Su= ccess.\n", TransReq->CallerEvent)); + DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p Su= ccess.\n", TransReq->CallerEvent)); SignalCallerEvent (Private, TransReq); } } --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 8 10:01:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490146120173573.974405197137; Tue, 21 Mar 2017 18:28:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F2FEC80421; Tue, 21 Mar 2017 18:28:36 -0700 (PDT) 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 05ACD80421 for ; Tue, 21 Mar 2017 18:28:34 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 21 Mar 2017 18:28:33 -0700 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by orsmga002.jf.intel.com with ESMTP; 21 Mar 2017 18:28:32 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,202,1486454400"; d="scan'208";a="63424782" From: Hao Wu To: edk2-devel@lists.01.org Date: Wed, 22 Mar 2017 09:28:26 +0800 Message-Id: <20170322012826.13016-3-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170322012826.13016-1-hao.a.wu@intel.com> References: <20170322012826.13016-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 2/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init 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: , Cc: Hao Wu , Feng Tian , Mateusz Albecki MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the origin codes, the host sets the fDeviceInit flag to initiate device initialization, but does not check whether the device resets this flag to indicate the device initialization is completed. Details can be referred at UFS 2.0 Spec Section 14.2 - Flags. Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Mateusz Albecki Signed-off-by: Hao Wu Reviewed-by: Feng Tian --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 69 +++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 53 ++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 401 ++++++++-------= ----- 3 files changed, 267 insertions(+), 256 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 63b90de991..68a44367b5 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -730,6 +730,48 @@ UfsPassThruDriverBindingSupported ( } =20 /** + Finishes device initialization by setting fDeviceInit flag and waiting u= ntill device responds by + clearing it. + + @param[in] Private Pointer to the UFS_PASS_THRU_PRIVATE_DATA. + + @retval EFI_SUCCESS The operation succeeds. + @retval Others The operation fails. + +**/ +EFI_STATUS +UfsFinishDeviceInitialization ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private + ) +{ + EFI_STATUS Status; + UINT8 DeviceInitStatus; + UINT8 Timeout; + + DeviceInitStatus =3D 0xFF; + + // + // The host enables the device initialization completion by setting fDev= iceInit flag. + // + Status =3D UfsSetFlag (Private, UfsFlagDevInit); + if (EFI_ERROR (Status)) { + return Status; + } + + Timeout =3D 5; + do { + Status =3D UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus); + if (EFI_ERROR (Status)) { + return Status; + } + MicroSecondDelay (1); + Timeout--; + } while (DeviceInitStatus !=3D 0 && Timeout !=3D 0); + + return EFI_SUCCESS; +} + +/** Starts a device controller or a bus controller. =20 The Start() function is designed to be invoked from the EFI boot service= ConnectController(). @@ -777,7 +819,7 @@ UfsPassThruDriverBindingStart ( UFS_PASS_THRU_PRIVATE_DATA *Private; UINTN UfsHcBase; UINT32 Index; - UFS_CONFIG_DESC Config; + UFS_UNIT_DESC UnitDescriptor; =20 Status =3D EFI_SUCCESS; UfsHc =3D NULL; @@ -844,21 +886,9 @@ UfsPassThruDriverBindingStart ( goto Error; } =20 - // - // The host enables the device initialization completion by setting fDev= iceInit flag. - // - Status =3D UfsSetFlag (Private, UfsFlagDevInit); + Status =3D UfsFinishDeviceInitialization (Private); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Ufs Set fDeviceInit Flag Error, Status =3D %r\n"= , Status)); - goto Error; - } - - // - // Get Ufs Device's Lun Info by reading Configuration Descriptor. - // - Status =3D UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config,= sizeof (UFS_CONFIG_DESC)); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = =3D %r\n", Status)); + DEBUG ((DEBUG_ERROR, "Device failed to finish initialization, Status = =3D %r\n", Status)); goto Error; } =20 @@ -867,9 +897,14 @@ UfsPassThruDriverBindingStart ( // TODO: Parse device descriptor to decide if exposing RPMB LUN to upper= layer for authentication access. // for (Index =3D 0; Index < 8; Index++) { - if (Config.UnitDescConfParams[Index].LunEn !=3D 0) { + Status =3D UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8) Index,= 0, &UnitDescriptor, sizeof (UFS_UNIT_DESC)); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to read unit descriptor, index =3D %X, = status =3D %r\n", Index, Status)); + continue; + } + if (UnitDescriptor.LunEn =3D=3D 0x1) { + DEBUG ((DEBUG_INFO, "UFS LUN %X is enabled\n", Index)); Private->Luns.BitMask |=3D (BIT0 << Index); - DEBUG ((DEBUG_INFO, "Ufs Lun %d is enabled\n", Index)); } } =20 diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index 7fc82bae7a..bdc64f7793 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -1,6 +1,6 @@ /** @file =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -122,16 +122,13 @@ typedef struct { =20 typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET { UINT64 Timeout; - VOID *InDataBuffer; - VOID *OutDataBuffer; + VOID *DataBuffer; UINT8 Opcode; UINT8 DescId; UINT8 Index; UINT8 Selector; - UINT32 InTransferLength; - UINT32 OutTransferLength; + UINT32 TransferLength; UINT8 DataDirection; - UINT8 Ocs; } UFS_DEVICE_MANAGEMENT_REQUEST_PACKET; =20 // @@ -717,6 +714,25 @@ UfsSetFlag ( ); =20 /** + Read specified flag from a UFS device. + + @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_D= ATA data structure. + @param[in] FlagId The ID of flag to be read. + @param[out] Value The flag's value. + + @retval EFI_SUCCESS The flag was read successfully. + @retval EFI_DEVICE_ERROR A device error occurred while attempting t= o read the flag. + @retval EFI_TIMEOUT A timeout occurred while waiting for the c= ompletion of reading the flag. + +**/ +EFI_STATUS +UfsReadFlag ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private, + IN UINT8 FlagId, + OUT UINT8 *Value + ); + +/** Read or write specified device descriptor of a UFS device. =20 @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_D= ATA data structure. @@ -744,6 +760,31 @@ UfsRwDeviceDesc ( ); =20 /** + Read or write specified attribute of a UFS device. + + @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_D= ATA data structure. + @param[in] Read The boolean variable to show r/w direction. + @param[in] AttrId The ID of Attribute. + @param[in] Index The Index of Attribute. + @param[in] Selector The Selector of Attribute. + @param[in, out] Attributes The value of Attribute to be read or writt= en. + + @retval EFI_SUCCESS The Attribute was read/written successfull= y. + @retval EFI_DEVICE_ERROR A device error occurred while attempting t= o r/w the Attribute. + @retval EFI_TIMEOUT A timeout occurred while waiting for the c= ompletion of r/w the Attribute. + +**/ +EFI_STATUS +UfsRwAttributes ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private, + IN BOOLEAN Read, + IN UINT8 AttrId, + IN UINT8 Index, + IN UINT8 Selector, + IN OUT UINT32 *Attributes + ); + +/** Sends NOP IN cmd to a UFS device for initialization process request. For more details, please refer to UFS 2.0 spec Figure 13.3. =20 diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 822554cebb..a19bdcc3cc 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -602,32 +602,13 @@ UfsCreateDMCommandDesc ( } =20 DataDirection =3D Packet->DataDirection; - if (DataDirection =3D=3D UfsDataIn) { - DataSize =3D Packet->InTransferLength; - Data =3D Packet->InDataBuffer; - } else if (DataDirection =3D=3D UfsDataOut) { - DataSize =3D Packet->OutTransferLength; - Data =3D Packet->OutDataBuffer; - } else { - DataSize =3D 0; - Data =3D NULL; - } - - if (((Opcode !=3D UtpQueryFuncOpcodeSetFlag) && (Opcode !=3D UtpQueryFun= cOpcodeClrFlag) && (Opcode !=3D UtpQueryFuncOpcodeTogFlag)) - && ((DataSize =3D=3D 0) || (Data =3D=3D NULL))) { - return EFI_INVALID_PARAMETER; - } - - if (((Opcode =3D=3D UtpQueryFuncOpcodeSetFlag) || (Opcode =3D=3D UtpQuer= yFuncOpcodeClrFlag) || (Opcode =3D=3D UtpQueryFuncOpcodeTogFlag)) - && ((DataSize !=3D 0) || (Data !=3D NULL))) { - return EFI_INVALID_PARAMETER; - } - - if ((Opcode =3D=3D UtpQueryFuncOpcodeWrAttr) && (DataSize !=3D sizeof (U= INT32))) { - return EFI_INVALID_PARAMETER; - } + DataSize =3D Packet->TransferLength; + Data =3D Packet->DataBuffer; =20 if ((Opcode =3D=3D UtpQueryFuncOpcodeWrDesc) || (Opcode =3D=3D UtpQueryF= uncOpcodeRdDesc)) { + if (DataSize =3D=3D 0 || Data =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } TotalLen =3D ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (sizeof= (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize); } else { TotalLen =3D ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (sizeof= (UTP_QUERY_RESP_UPIU)); @@ -868,60 +849,84 @@ UfsStopExecCmd ( } =20 /** - Read or write specified device descriptor of a UFS device. + Extracts return data from query response upiu. =20 - @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_D= ATA data structure. - @param[in] Read The boolean variable to show r/w direction. - @param[in] DescId The ID of device descriptor. - @param[in] Index The Index of device descriptor. - @param[in] Selector The Selector of device descriptor. - @param[in, out] Descriptor The buffer of device descriptor to be read= or written. - @param[in] DescSize The size of device descriptor buffer. + @param[in] Packet Pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKE= T. + @param[in] QueryResp Pointer to the query response. =20 - @retval EFI_SUCCESS The device descriptor was read/written suc= cessfully. - @retval EFI_DEVICE_ERROR A device error occurred while attempting t= o r/w the device descriptor. - @retval EFI_TIMEOUT A timeout occurred while waiting for the c= ompletion of r/w the device descriptor. + @retval EFI_INVALID_PARAMETER Packet or QueryResp are empty or opcode is= invalid. + @retval EFI_SUCCESS Data extracted. =20 **/ EFI_STATUS -UfsRwDeviceDesc ( - IN UFS_PASS_THRU_PRIVATE_DATA *Private, - IN BOOLEAN Read, - IN UINT8 DescId, - IN UINT8 Index, - IN UINT8 Selector, - IN OUT VOID *Descriptor, - IN UINT32 DescSize +UfsGetReturnDataFromQueryResponse ( + IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet, + IN UTP_QUERY_RESP_UPIU *QueryResp ) { - EFI_STATUS Status; - UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet; - UINT8 Slot; - UTP_TRD *Trd; - UTP_QUERY_RESP_UPIU *QueryResp; - UINT32 CmdDescSize; - UINT16 ReturnDataSize; - VOID *CmdDescHost; - VOID *CmdDescMapping; - EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; + UINT16 ReturnDataSize; + UINT32 ReturnData; =20 - ZeroMem (&Packet, sizeof (UFS_DEVICE_MANAGEMENT_REQUEST_PACKET)); + if (Packet =3D=3D NULL || QueryResp =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } =20 - if (Read) { - Packet.DataDirection =3D UfsDataIn; - Packet.InDataBuffer =3D Descriptor; - Packet.InTransferLength =3D DescSize; - Packet.Opcode =3D UtpQueryFuncOpcodeRdDesc; - } else { - Packet.DataDirection =3D UfsDataOut; - Packet.OutDataBuffer =3D Descriptor; - Packet.OutTransferLength =3D DescSize; - Packet.Opcode =3D UtpQueryFuncOpcodeWrDesc; + switch (Packet->Opcode) { + case UtpQueryFuncOpcodeRdDesc: + ReturnDataSize =3D QueryResp->Tsf.Length; + SwapLittleEndianToBigEndian ((UINT8*)&ReturnDataSize, sizeof (UINT16= )); + CopyMem (Packet->DataBuffer, (QueryResp + 1), ReturnDataSize); + Packet->TransferLength =3D ReturnDataSize; + break; + case UtpQueryFuncOpcodeWrDesc: + ReturnDataSize =3D QueryResp->Tsf.Length; + SwapLittleEndianToBigEndian ((UINT8*)&ReturnDataSize, sizeof (UINT16= )); + Packet->TransferLength =3D ReturnDataSize; + break; + case UtpQueryFuncOpcodeRdFlag: + case UtpQueryFuncOpcodeSetFlag: + case UtpQueryFuncOpcodeClrFlag: + case UtpQueryFuncOpcodeTogFlag: + CopyMem (Packet->DataBuffer, &QueryResp->Tsf.Value, sizeof (UINT8)); + break; + case UtpQueryFuncOpcodeRdAttr: + case UtpQueryFuncOpcodeWrAttr: + ReturnData =3D QueryResp->Tsf.Value; + SwapLittleEndianToBigEndian ((UINT8*) &ReturnData, sizeof (UINT32)); + CopyMem (Packet->DataBuffer, &ReturnData, sizeof (UINT32)); + break; + default: + return EFI_INVALID_PARAMETER; } - Packet.DescId =3D DescId; - Packet.Index =3D Index; - Packet.Selector =3D Selector; - Packet.Timeout =3D UFS_TIMEOUT; + + return EFI_SUCCESS; +} + +/** + Creates Transfer Request descriptor and sends Query Request to the devic= e. + + @param[in] Private Pointer to the UFS_PASS_THRU_PRIVATE_DATA. + @param[in] Packet Pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET. + + @retval EFI_SUCCESS The device descriptor was read/written suc= cessfully. + @retval EFI_DEVICE_ERROR A device error occurred while attempting t= o r/w the device descriptor. + @retval EFI_TIMEOUT A timeout occurred while waiting for the c= ompletion of r/w the device descriptor. + +**/ +EFI_STATUS +UfsSendDmRequestRetry ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private, + IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet + ) +{ + UINT8 Slot; + UTP_TRD *Trd; + VOID *CmdDescHost; + VOID *CmdDescMapping; + UINT32 CmdDescSize; + EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; + UTP_QUERY_RESP_UPIU *QueryResp; + EFI_STATUS Status; =20 // // Find out which slot of transfer request list is available. @@ -935,14 +940,12 @@ UfsRwDeviceDesc ( // // Fill transfer request descriptor to this slot. // - Status =3D UfsCreateDMCommandDesc (Private, &Packet, Trd, &CmdDescHost, = &CmdDescMapping); + Status =3D UfsCreateDMCommandDesc (Private, Packet, Trd, &CmdDescHost, &= CmdDescMapping); if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to create DM command descriptor\n")); return Status; } =20 - // - // Check the transfer request result. - // UfsHc =3D Private->UfsHostController; QueryResp =3D (UTP_QUERY_RESP_UPIU*)((UINT8*)CmdDescHost + Trd->RuO * = sizeof (UINT32)); ASSERT (QueryResp !=3D NULL); @@ -955,30 +958,23 @@ UfsRwDeviceDesc ( =20 // // Wait for the completion of the transfer request. - // =20 - Status =3D UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, = 0, Packet.Timeout); + // + Status =3D UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, Packe= t->Timeout); if (EFI_ERROR (Status)) { goto Exit; } =20 - if (QueryResp->QueryResp !=3D 0) { + if (Trd->Ocs !=3D 0 || QueryResp->QueryResp !=3D UfsUtpQueryResponseSucc= ess) { + DEBUG ((DEBUG_ERROR, "Failed to send query request, OCS =3D %X, QueryR= esp =3D %X\n", Trd->Ocs, QueryResp->QueryResp)); DumpQueryResponseResult (QueryResp->QueryResp); Status =3D EFI_DEVICE_ERROR; goto Exit; } =20 - if (Trd->Ocs =3D=3D 0) { - ReturnDataSize =3D QueryResp->Tsf.Length; - SwapLittleEndianToBigEndian ((UINT8*)&ReturnDataSize, sizeof (UINT16)); - - if (Read) { - CopyMem (Packet.InDataBuffer, (QueryResp + 1), ReturnDataSize); - Packet.InTransferLength =3D ReturnDataSize; - } else { - Packet.OutTransferLength =3D ReturnDataSize; - } - } else { - Status =3D EFI_DEVICE_ERROR; + Status =3D UfsGetReturnDataFromQueryResponse (Packet, QueryResp); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get return data from query response\n"= )); + goto Exit; } =20 Exit: @@ -997,6 +993,87 @@ Exit: } =20 /** + Sends Query Request to the device. Query is sent until device responds c= orrectly or counter runs out. + + @param[in] Private Pointer to the UFS_PASS_THRU_PRIVATE_DATA. + @param[in] Packet Pointer to the UFS_DEVICE_MANAGEMENT_PACKET. + + @retval EFI_SUCCESS The device responded correctly to the Quer= y request. + @retval EFI_DEVICE_ERROR A device error occurred while waiting for = the response from the device. + @retval EFI_TIMEOUT A timeout occurred while waiting for the c= ompletion of the operation. + +**/ +EFI_STATUS +UfsSendDmRequest ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private, + IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet + ) +{ + EFI_STATUS Status; + UINT8 Retry; + + Status =3D EFI_SUCCESS; + + for (Retry =3D 0; Retry < 5; Retry ++) { + Status =3D UfsSendDmRequestRetry (Private, Packet); + if (!EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + } + + DEBUG ((DEBUG_ERROR, "Failed to get response from the device after %d re= tries\n", Retry)); + return Status; +} + +/** + Read or write specified device descriptor of a UFS device. + + @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_D= ATA data structure. + @param[in] Read The boolean variable to show r/w direction. + @param[in] DescId The ID of device descriptor. + @param[in] Index The Index of device descriptor. + @param[in] Selector The Selector of device descriptor. + @param[in, out] Descriptor The buffer of device descriptor to be read= or written. + @param[in] DescSize The size of device descriptor buffer. + + @retval EFI_SUCCESS The device descriptor was read/written suc= cessfully. + @retval EFI_DEVICE_ERROR A device error occurred while attempting t= o r/w the device descriptor. + @retval EFI_TIMEOUT A timeout occurred while waiting for the c= ompletion of r/w the device descriptor. + +**/ +EFI_STATUS +UfsRwDeviceDesc ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private, + IN BOOLEAN Read, + IN UINT8 DescId, + IN UINT8 Index, + IN UINT8 Selector, + IN OUT VOID *Descriptor, + IN UINT32 DescSize + ) +{ + UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet; + + ZeroMem (&Packet, sizeof (UFS_DEVICE_MANAGEMENT_REQUEST_PACKET)); + + if (Read) { + Packet.DataDirection =3D UfsDataIn; + Packet.Opcode =3D UtpQueryFuncOpcodeRdDesc; + } else { + Packet.DataDirection =3D UfsDataOut; + Packet.Opcode =3D UtpQueryFuncOpcodeWrDesc; + } + Packet.DataBuffer =3D Descriptor; + Packet.TransferLength =3D DescSize; + Packet.DescId =3D DescId; + Packet.Index =3D Index; + Packet.Selector =3D Selector; + Packet.Timeout =3D UFS_TIMEOUT; + + return UfsSendDmRequest (Private, &Packet); +} + +/** Read or write specified attribute of a UFS device. =20 @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_D= ATA data structure. @@ -1021,16 +1098,7 @@ UfsRwAttributes ( IN OUT UINT32 *Attributes ) { - EFI_STATUS Status; UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet; - UINT8 Slot; - UTP_TRD *Trd; - UTP_QUERY_RESP_UPIU *QueryResp; - UINT32 CmdDescSize; - UINT32 ReturnData; - VOID *CmdDescHost; - VOID *CmdDescMapping; - EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; =20 ZeroMem (&Packet, sizeof (UFS_DEVICE_MANAGEMENT_REQUEST_PACKET)); =20 @@ -1041,77 +1109,13 @@ UfsRwAttributes ( Packet.DataDirection =3D UfsDataOut; Packet.Opcode =3D UtpQueryFuncOpcodeWrAttr; } + Packet.DataBuffer =3D Attributes; Packet.DescId =3D AttrId; Packet.Index =3D Index; Packet.Selector =3D Selector; Packet.Timeout =3D UFS_TIMEOUT; =20 - // - // Find out which slot of transfer request list is available. - // - Status =3D UfsFindAvailableSlotInTrl (Private, &Slot); - if (EFI_ERROR (Status)) { - return Status; - } - =20 - Trd =3D ((UTP_TRD*)Private->UtpTrlBase) + Slot; - // - // Fill transfer request descriptor to this slot. - // - Status =3D UfsCreateDMCommandDesc (Private, &Packet, Trd, &CmdDescHost, = &CmdDescMapping); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Check the transfer request result. - // - UfsHc =3D Private->UfsHostController; - QueryResp =3D (UTP_QUERY_RESP_UPIU*)((UINT8*)CmdDescHost + Trd->RuO * = sizeof (UINT32)); - ASSERT (QueryResp !=3D NULL); - CmdDescSize =3D Trd->RuO * sizeof (UINT32) + Trd->RuL * sizeof (UINT32); - - // - // Start to execute the transfer request. - // - UfsStartExecCmd (Private, Slot); - - // - // Wait for the completion of the transfer request. - // =20 - Status =3D UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, = 0, Packet.Timeout); - if (EFI_ERROR (Status)) { - goto Exit; - } - - if (QueryResp->QueryResp !=3D 0) { - DumpQueryResponseResult (QueryResp->QueryResp); - Status =3D EFI_DEVICE_ERROR; - goto Exit; - } - - if (Trd->Ocs =3D=3D 0) { - ReturnData =3D QueryResp->Tsf.Value; - SwapLittleEndianToBigEndian ((UINT8*)&ReturnData, sizeof (UINT32)); - *Attributes =3D ReturnData; - } else { - Status =3D EFI_DEVICE_ERROR; - } - -Exit: - UfsHc->Flush (UfsHc); - - UfsStopExecCmd (Private, Slot); - - if (CmdDescMapping !=3D NULL) { - UfsHc->Unmap (UfsHc, CmdDescMapping); - } - - if (CmdDescHost !=3D NULL) { - UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (CmdDescSize), CmdDescHost= ); - } - - return Status; + return UfsSendDmRequest (Private, &Packet); } =20 /** @@ -1135,15 +1139,7 @@ UfsRwFlags ( IN OUT UINT8 *Value ) { - EFI_STATUS Status; UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet; - UINT8 Slot; - UTP_TRD *Trd; - UTP_QUERY_RESP_UPIU *QueryResp; - UINT32 CmdDescSize; - VOID *CmdDescHost; - VOID *CmdDescMapping; - EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; =20 if (Value =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -1165,74 +1161,13 @@ UfsRwFlags ( return EFI_INVALID_PARAMETER; } } + Packet.DataBuffer =3D Value; Packet.DescId =3D FlagId; Packet.Index =3D 0; Packet.Selector =3D 0; Packet.Timeout =3D UFS_TIMEOUT; =20 - // - // Find out which slot of transfer request list is available. - // - Status =3D UfsFindAvailableSlotInTrl (Private, &Slot); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Fill transfer request descriptor to this slot. - // - Trd =3D ((UTP_TRD*)Private->UtpTrlBase) + Slot; - Status =3D UfsCreateDMCommandDesc (Private, &Packet, Trd, &CmdDescHost, = &CmdDescMapping); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Check the transfer request result. - // - UfsHc =3D Private->UfsHostController; - QueryResp =3D (UTP_QUERY_RESP_UPIU*)((UINT8*)CmdDescHost + Trd->RuO * = sizeof (UINT32)); - ASSERT (QueryResp !=3D NULL); - CmdDescSize =3D Trd->RuO * sizeof (UINT32) + Trd->RuL * sizeof (UINT32); - - // - // Start to execute the transfer request. - // - UfsStartExecCmd (Private, Slot); - - // - // Wait for the completion of the transfer request. - // =20 - Status =3D UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, = 0, Packet.Timeout); - if (EFI_ERROR (Status)) { - goto Exit; - } - - if (QueryResp->QueryResp !=3D 0) { - DumpQueryResponseResult (QueryResp->QueryResp); - Status =3D EFI_DEVICE_ERROR; - goto Exit; - } - - if (Trd->Ocs =3D=3D 0) { - *Value =3D (UINT8)QueryResp->Tsf.Value; - } else { - Status =3D EFI_DEVICE_ERROR; - } - -Exit: - UfsHc->Flush (UfsHc); - - UfsStopExecCmd (Private, Slot); - - if (CmdDescMapping !=3D NULL) { - UfsHc->Unmap (UfsHc, CmdDescMapping); - } - if (CmdDescHost !=3D NULL) { - UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (CmdDescSize), CmdDescHost= ); - } - - return Status; + return UfsSendDmRequest (Private, &Packet); } =20 /** --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel