* [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
@ 2017-03-22 1:28 Hao Wu
2017-03-22 1:28 ` [PATCH 1/2] MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX' Hao Wu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hao Wu @ 2017-03-22 1:28 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Feng Tian
The series changes the UFS host to wait for the device to clear the
'fDeviceInit' bit by a device after setting this flag.
The series also cleans up the usages of 'EFI_D_XXX' and replaces them with
'DEBUG_XXX' in DEBUG().
Cc: Feng Tian <feng.tian@intel.com>
Hao Wu (2):
MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX'
MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 89 ++--
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 53 ++-
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 471 +++++++++-----------
3 files changed, 312 insertions(+), 301 deletions(-)
--
2.12.0.windows.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX'
2017-03-22 1:28 [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
@ 2017-03-22 1:28 ` Hao Wu
2017-03-22 1:28 ` [PATCH 2/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
2017-04-20 2:04 ` [PATCH 0/2] " Tian, Feng
2 siblings, 0 replies; 4+ messages in thread
From: Hao Wu @ 2017-03-22 1:28 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Feng Tian
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
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/MdeModulePkg/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
- Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
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
@@ -784,7 +784,7 @@ UfsPassThruDriverBindingStart (
Private = NULL;
UfsHcBase = 0;
- DEBUG ((EFI_D_INFO, "==UfsPassThru Start== Controller = %x\n", Controller));
+ DEBUG ((DEBUG_INFO, "==UfsPassThru Start== Controller = %x\n", Controller));
Status = gBS->OpenProtocol (
Controller,
@@ -796,7 +796,7 @@ UfsPassThruDriverBindingStart (
);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Open Ufs Host Controller Protocol Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Open Ufs Host Controller Protocol Error, Status = %r\n", Status));
goto Error;
}
@@ -805,7 +805,7 @@ UfsPassThruDriverBindingStart (
//
Status = UfsHc->GetUfsHcMmioBar (UfsHc, &UfsHcBase);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Get Ufs Host Controller Mmio Bar Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Get Ufs Host Controller Mmio Bar Error, Status = %r\n", Status));
goto Error;
}
@@ -814,7 +814,7 @@ UfsPassThruDriverBindingStart (
//
Private = AllocateCopyPool (sizeof (UFS_PASS_THRU_PRIVATE_DATA), &gUfsPassThruTemplate);
if (Private == 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 = EFI_OUT_OF_RESOURCES;
goto Error;
}
@@ -829,7 +829,7 @@ UfsPassThruDriverBindingStart (
//
Status = UfsControllerInit (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Ufs Host Controller Initialization Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Ufs Host Controller Initialization Error, Status = %r\n", Status));
goto Error;
}
@@ -840,7 +840,7 @@ UfsPassThruDriverBindingStart (
//
Status = UfsExecNopCmds (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Ufs Sending NOP IN command Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Ufs Sending NOP IN command Error, Status = %r\n", Status));
goto Error;
}
@@ -849,7 +849,7 @@ UfsPassThruDriverBindingStart (
//
Status = UfsSetFlag (Private, UfsFlagDevInit);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Ufs Set fDeviceInit Flag Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Ufs Set fDeviceInit Flag Error, Status = %r\n", Status));
goto Error;
}
@@ -858,7 +858,7 @@ UfsPassThruDriverBindingStart (
//
Status = 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 = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = %r\n", Status));
goto Error;
}
@@ -869,7 +869,7 @@ UfsPassThruDriverBindingStart (
for (Index = 0; Index < 8; Index++) {
if (Config.UnitDescConfParams[Index].LunEn != 0) {
Private->Luns.BitMask |= (BIT0 << Index);
- DEBUG ((EFI_D_INFO, "Ufs Lun %d is enabled\n", Index));
+ DEBUG ((DEBUG_INFO, "Ufs Lun %d is enabled\n", Index));
}
}
@@ -884,7 +884,7 @@ UfsPassThruDriverBindingStart (
&Private->TimerEvent
);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Ufs Create Async Tasks Event Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Ufs Create Async Tasks Event Error, Status = %r\n", Status));
goto Error;
}
@@ -894,7 +894,7 @@ UfsPassThruDriverBindingStart (
UFS_HC_ASYNC_TIMER
);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Ufs Set Periodic Timer Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Ufs Set Periodic Timer Error, Status = %r\n", Status));
goto Error;
}
@@ -986,7 +986,7 @@ UfsPassThruDriverBindingStop (
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
- DEBUG ((EFI_D_INFO, "==UfsPassThru Stop== Controller Controller = %x\n", Controller));
+ DEBUG ((DEBUG_INFO, "==UfsPassThru Stop== Controller Controller = %x\n", Controller));
Status = gBS->OpenProtocol (
Controller,
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/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_ONLY_MIB_ATTRIBUTE\n"));
+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - READ_ONLY_MIB_ATTRIBUTE\n"));
break;
case 0x04:
- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - WRITE_ONLY_MIB_ATTRIBUTE\n"));
+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - WRITE_ONLY_MIB_ATTRIBUTE\n"));
break;
case 0x05:
- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BAD_INDEX\n"));
+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BAD_INDEX\n"));
break;
case 0x06:
- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - LOCKED_MIB_ATTRIBUTE\n"));
+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - LOCKED_MIB_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_COMMUNICATION_FAILURE\n"));
+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - PEER_COMMUNICATION_FAILURE\n"));
break;
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_FAILURE\n"));
+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - DME_FAILURE\n"));
break;
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;
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 Written\n"));
+ DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Already Written\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;
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 (
if ((BufferSize & (BIT0 | BIT1)) != 0) {
BufferSize &= ~(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));
}
if (BufferSize == 0) {
@@ -1559,7 +1559,7 @@ UfsExecScsiCmds (
//
Packet->TargetStatus = Response->Status;
if (Response->Response != 0) {
- DEBUG ((EFI_D_ERROR, "UfsExecScsiCmds() fails with Target Failure\n"));
+ DEBUG ((DEBUG_ERROR, "UfsExecScsiCmds() fails with Target Failure\n"));
Status = EFI_DEVICE_ERROR;
goto Exit;
}
@@ -1717,7 +1717,7 @@ UfsExecUicCommands (
return EFI_NOT_FOUND;
}
- DEBUG ((EFI_D_INFO, "UfsPassThruDxe: found a attached UFS device\n"));
+ DEBUG ((DEBUG_INFO, "UfsPassThruDxe: found a attached UFS device\n"));
return EFI_SUCCESS;
}
@@ -2084,29 +2084,29 @@ UfsControllerInit (
Status = UfsEnableHostController (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "UfsControllerInit: Enable Host Controller Fails, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UfsControllerInit: Enable Host Controller Fails, Status = %r\n", Status));
return Status;
}
Status = UfsDeviceDetection (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "UfsControllerInit: Device Detection Fails, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UfsControllerInit: Device Detection Fails, Status = %r\n", Status));
return Status;
}
Status = UfsInitTaskManagementRequestList (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "UfsControllerInit: Task management list initialization Fails, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UfsControllerInit: Task management list initialization Fails, Status = %r\n", Status));
return Status;
}
Status = UfsInitTransferRequestList (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "UfsControllerInit: Transfer list initialization Fails, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UfsControllerInit: Transfer list initialization Fails, Status = %r\n", Status));
return Status;
}
- DEBUG ((EFI_D_INFO, "UfsControllerInit Finished\n"));
+ DEBUG ((DEBUG_INFO, "UfsControllerInit Finished\n"));
return EFI_SUCCESS;
}
@@ -2167,7 +2167,7 @@ UfsControllerStop (
return EFI_DEVICE_ERROR;
}
- DEBUG ((EFI_D_INFO, "UfsController is stopped\n"));
+ DEBUG ((DEBUG_INFO, "UfsController is stopped\n"));
return EFI_SUCCESS;
}
@@ -2274,7 +2274,7 @@ ProcessAsyncTaskList (
// case.
//
Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR;
- DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p UfsMmioRead32() Error.\n", TransReq->CallerEvent));
+ DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p UfsMmioRead32() Error.\n", TransReq->CallerEvent));
SignalCallerEvent (Private, TransReq);
continue;
}
@@ -2291,7 +2291,7 @@ ProcessAsyncTaskList (
// Timeout occurs.
//
Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_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 = Response->Status;
if (Response->Response != 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;
}
- DEBUG ((EFI_D_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p Success.\n", TransReq->CallerEvent));
+ DEBUG ((DEBUG_VERBOSE, "ProcessAsyncTaskList(): Signal Event %p Success.\n", TransReq->CallerEvent));
SignalCallerEvent (Private, TransReq);
}
}
--
2.12.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
2017-03-22 1:28 [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
2017-03-22 1:28 ` [PATCH 1/2] MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX' Hao Wu
@ 2017-03-22 1:28 ` Hao Wu
2017-04-20 2:04 ` [PATCH 0/2] " Tian, Feng
2 siblings, 0 replies; 4+ messages in thread
From: Hao Wu @ 2017-03-22 1:28 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Feng Tian, Mateusz Albecki
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 <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
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/MdeModulePkg/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 (
}
/**
+ Finishes device initialization by setting fDeviceInit flag and waiting untill 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 = 0xFF;
+
+ //
+ // The host enables the device initialization completion by setting fDeviceInit flag.
+ //
+ Status = UfsSetFlag (Private, UfsFlagDevInit);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Timeout = 5;
+ do {
+ Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ MicroSecondDelay (1);
+ Timeout--;
+ } while (DeviceInitStatus != 0 && Timeout != 0);
+
+ return EFI_SUCCESS;
+}
+
+/**
Starts a device controller or a bus controller.
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;
Status = EFI_SUCCESS;
UfsHc = NULL;
@@ -844,21 +886,9 @@ UfsPassThruDriverBindingStart (
goto Error;
}
- //
- // The host enables the device initialization completion by setting fDeviceInit flag.
- //
- Status = UfsSetFlag (Private, UfsFlagDevInit);
+ Status = UfsFinishDeviceInitialization (Private);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Ufs Set fDeviceInit Flag Error, Status = %r\n", Status));
- goto Error;
- }
-
- //
- // Get Ufs Device's Lun Info by reading Configuration Descriptor.
- //
- Status = UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config, sizeof (UFS_CONFIG_DESC));
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "Device failed to finish initialization, Status = %r\n", Status));
goto Error;
}
@@ -867,9 +897,14 @@ UfsPassThruDriverBindingStart (
// TODO: Parse device descriptor to decide if exposing RPMB LUN to upper layer for authentication access.
//
for (Index = 0; Index < 8; Index++) {
- if (Config.UnitDescConfParams[Index].LunEn != 0) {
+ Status = 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 = %X, status = %r\n", Index, Status));
+ continue;
+ }
+ if (UnitDescriptor.LunEn == 0x1) {
+ DEBUG ((DEBUG_INFO, "UFS LUN %X is enabled\n", Index));
Private->Luns.BitMask |= (BIT0 << Index);
- DEBUG ((DEBUG_INFO, "Ufs Lun %d is enabled\n", Index));
}
}
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/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
- Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
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
@@ -122,16 +122,13 @@ typedef struct {
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;
//
@@ -717,6 +714,25 @@ UfsSetFlag (
);
/**
+ Read specified flag from a UFS device.
+
+ @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA 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 to read the flag.
+ @retval EFI_TIMEOUT A timeout occurred while waiting for the completion 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.
@param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
@@ -744,6 +760,31 @@ UfsRwDeviceDesc (
);
/**
+ Read or write specified attribute of a UFS device.
+
+ @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA 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 written.
+
+ @retval EFI_SUCCESS The Attribute was read/written successfully.
+ @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the Attribute.
+ @retval EFI_TIMEOUT A timeout occurred while waiting for the completion 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.
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/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 (
}
DataDirection = Packet->DataDirection;
- if (DataDirection == UfsDataIn) {
- DataSize = Packet->InTransferLength;
- Data = Packet->InDataBuffer;
- } else if (DataDirection == UfsDataOut) {
- DataSize = Packet->OutTransferLength;
- Data = Packet->OutDataBuffer;
- } else {
- DataSize = 0;
- Data = NULL;
- }
-
- if (((Opcode != UtpQueryFuncOpcodeSetFlag) && (Opcode != UtpQueryFuncOpcodeClrFlag) && (Opcode != UtpQueryFuncOpcodeTogFlag))
- && ((DataSize == 0) || (Data == NULL))) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (((Opcode == UtpQueryFuncOpcodeSetFlag) || (Opcode == UtpQueryFuncOpcodeClrFlag) || (Opcode == UtpQueryFuncOpcodeTogFlag))
- && ((DataSize != 0) || (Data != NULL))) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Opcode == UtpQueryFuncOpcodeWrAttr) && (DataSize != sizeof (UINT32))) {
- return EFI_INVALID_PARAMETER;
- }
+ DataSize = Packet->TransferLength;
+ Data = Packet->DataBuffer;
if ((Opcode == UtpQueryFuncOpcodeWrDesc) || (Opcode == UtpQueryFuncOpcodeRdDesc)) {
+ if (DataSize == 0 || Data == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
TotalLen = ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize);
} else {
TotalLen = ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU));
@@ -868,60 +849,84 @@ UfsStopExecCmd (
}
/**
- Read or write specified device descriptor of a UFS device.
+ Extracts return data from query response upiu.
- @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA 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_PACKET.
+ @param[in] QueryResp Pointer to the query response.
- @retval EFI_SUCCESS The device descriptor was read/written successfully.
- @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.
- @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of r/w the device descriptor.
+ @retval EFI_INVALID_PARAMETER Packet or QueryResp are empty or opcode is invalid.
+ @retval EFI_SUCCESS Data extracted.
**/
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;
- ZeroMem (&Packet, sizeof (UFS_DEVICE_MANAGEMENT_REQUEST_PACKET));
+ if (Packet == NULL || QueryResp == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
- if (Read) {
- Packet.DataDirection = UfsDataIn;
- Packet.InDataBuffer = Descriptor;
- Packet.InTransferLength = DescSize;
- Packet.Opcode = UtpQueryFuncOpcodeRdDesc;
- } else {
- Packet.DataDirection = UfsDataOut;
- Packet.OutDataBuffer = Descriptor;
- Packet.OutTransferLength = DescSize;
- Packet.Opcode = UtpQueryFuncOpcodeWrDesc;
+ switch (Packet->Opcode) {
+ case UtpQueryFuncOpcodeRdDesc:
+ ReturnDataSize = QueryResp->Tsf.Length;
+ SwapLittleEndianToBigEndian ((UINT8*)&ReturnDataSize, sizeof (UINT16));
+ CopyMem (Packet->DataBuffer, (QueryResp + 1), ReturnDataSize);
+ Packet->TransferLength = ReturnDataSize;
+ break;
+ case UtpQueryFuncOpcodeWrDesc:
+ ReturnDataSize = QueryResp->Tsf.Length;
+ SwapLittleEndianToBigEndian ((UINT8*)&ReturnDataSize, sizeof (UINT16));
+ Packet->TransferLength = ReturnDataSize;
+ break;
+ case UtpQueryFuncOpcodeRdFlag:
+ case UtpQueryFuncOpcodeSetFlag:
+ case UtpQueryFuncOpcodeClrFlag:
+ case UtpQueryFuncOpcodeTogFlag:
+ CopyMem (Packet->DataBuffer, &QueryResp->Tsf.Value, sizeof (UINT8));
+ break;
+ case UtpQueryFuncOpcodeRdAttr:
+ case UtpQueryFuncOpcodeWrAttr:
+ ReturnData = QueryResp->Tsf.Value;
+ SwapLittleEndianToBigEndian ((UINT8*) &ReturnData, sizeof (UINT32));
+ CopyMem (Packet->DataBuffer, &ReturnData, sizeof (UINT32));
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
}
- Packet.DescId = DescId;
- Packet.Index = Index;
- Packet.Selector = Selector;
- Packet.Timeout = UFS_TIMEOUT;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Creates Transfer Request descriptor and sends Query Request to the device.
+
+ @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 successfully.
+ @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.
+ @retval EFI_TIMEOUT A timeout occurred while waiting for the completion 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;
//
// Find out which slot of transfer request list is available.
@@ -935,14 +940,12 @@ UfsRwDeviceDesc (
//
// Fill transfer request descriptor to this slot.
//
- Status = UfsCreateDMCommandDesc (Private, &Packet, Trd, &CmdDescHost, &CmdDescMapping);
+ Status = UfsCreateDMCommandDesc (Private, Packet, Trd, &CmdDescHost, &CmdDescMapping);
if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to create DM command descriptor\n"));
return Status;
}
- //
- // Check the transfer request result.
- //
UfsHc = Private->UfsHostController;
QueryResp = (UTP_QUERY_RESP_UPIU*)((UINT8*)CmdDescHost + Trd->RuO * sizeof (UINT32));
ASSERT (QueryResp != NULL);
@@ -955,30 +958,23 @@ UfsRwDeviceDesc (
//
// Wait for the completion of the transfer request.
- //
- Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 0, Packet.Timeout);
+ //
+ Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0, 0, Packet->Timeout);
if (EFI_ERROR (Status)) {
goto Exit;
}
- if (QueryResp->QueryResp != 0) {
+ if (Trd->Ocs != 0 || QueryResp->QueryResp != UfsUtpQueryResponseSuccess) {
+ DEBUG ((DEBUG_ERROR, "Failed to send query request, OCS = %X, QueryResp = %X\n", Trd->Ocs, QueryResp->QueryResp));
DumpQueryResponseResult (QueryResp->QueryResp);
Status = EFI_DEVICE_ERROR;
goto Exit;
}
- if (Trd->Ocs == 0) {
- ReturnDataSize = QueryResp->Tsf.Length;
- SwapLittleEndianToBigEndian ((UINT8*)&ReturnDataSize, sizeof (UINT16));
-
- if (Read) {
- CopyMem (Packet.InDataBuffer, (QueryResp + 1), ReturnDataSize);
- Packet.InTransferLength = ReturnDataSize;
- } else {
- Packet.OutTransferLength = ReturnDataSize;
- }
- } else {
- Status = EFI_DEVICE_ERROR;
+ Status = UfsGetReturnDataFromQueryResponse (Packet, QueryResp);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to get return data from query response\n"));
+ goto Exit;
}
Exit:
@@ -997,6 +993,87 @@ Exit:
}
/**
+ Sends Query Request to the device. Query is sent until device responds correctly 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 Query 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 completion 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 = EFI_SUCCESS;
+
+ for (Retry = 0; Retry < 5; Retry ++) {
+ Status = UfsSendDmRequestRetry (Private, Packet);
+ if (!EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+ }
+
+ DEBUG ((DEBUG_ERROR, "Failed to get response from the device after %d retries\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_DATA 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 successfully.
+ @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.
+ @retval EFI_TIMEOUT A timeout occurred while waiting for the completion 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 = UfsDataIn;
+ Packet.Opcode = UtpQueryFuncOpcodeRdDesc;
+ } else {
+ Packet.DataDirection = UfsDataOut;
+ Packet.Opcode = UtpQueryFuncOpcodeWrDesc;
+ }
+ Packet.DataBuffer = Descriptor;
+ Packet.TransferLength = DescSize;
+ Packet.DescId = DescId;
+ Packet.Index = Index;
+ Packet.Selector = Selector;
+ Packet.Timeout = UFS_TIMEOUT;
+
+ return UfsSendDmRequest (Private, &Packet);
+}
+
+/**
Read or write specified attribute of a UFS device.
@param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA 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;
ZeroMem (&Packet, sizeof (UFS_DEVICE_MANAGEMENT_REQUEST_PACKET));
@@ -1041,77 +1109,13 @@ UfsRwAttributes (
Packet.DataDirection = UfsDataOut;
Packet.Opcode = UtpQueryFuncOpcodeWrAttr;
}
+ Packet.DataBuffer = Attributes;
Packet.DescId = AttrId;
Packet.Index = Index;
Packet.Selector = Selector;
Packet.Timeout = UFS_TIMEOUT;
- //
- // Find out which slot of transfer request list is available.
- //
- Status = UfsFindAvailableSlotInTrl (Private, &Slot);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Trd = ((UTP_TRD*)Private->UtpTrlBase) + Slot;
- //
- // Fill transfer request descriptor to this slot.
- //
- Status = UfsCreateDMCommandDesc (Private, &Packet, Trd, &CmdDescHost, &CmdDescMapping);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Check the transfer request result.
- //
- UfsHc = Private->UfsHostController;
- QueryResp = (UTP_QUERY_RESP_UPIU*)((UINT8*)CmdDescHost + Trd->RuO * sizeof (UINT32));
- ASSERT (QueryResp != NULL);
- CmdDescSize = 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.
- //
- Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 0, Packet.Timeout);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- if (QueryResp->QueryResp != 0) {
- DumpQueryResponseResult (QueryResp->QueryResp);
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- if (Trd->Ocs == 0) {
- ReturnData = QueryResp->Tsf.Value;
- SwapLittleEndianToBigEndian ((UINT8*)&ReturnData, sizeof (UINT32));
- *Attributes = ReturnData;
- } else {
- Status = EFI_DEVICE_ERROR;
- }
-
-Exit:
- UfsHc->Flush (UfsHc);
-
- UfsStopExecCmd (Private, Slot);
-
- if (CmdDescMapping != NULL) {
- UfsHc->Unmap (UfsHc, CmdDescMapping);
- }
-
- if (CmdDescHost != NULL) {
- UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (CmdDescSize), CmdDescHost);
- }
-
- return Status;
+ return UfsSendDmRequest (Private, &Packet);
}
/**
@@ -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;
if (Value == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1165,74 +1161,13 @@ UfsRwFlags (
return EFI_INVALID_PARAMETER;
}
}
+ Packet.DataBuffer = Value;
Packet.DescId = FlagId;
Packet.Index = 0;
Packet.Selector = 0;
Packet.Timeout = UFS_TIMEOUT;
- //
- // Find out which slot of transfer request list is available.
- //
- Status = UfsFindAvailableSlotInTrl (Private, &Slot);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Fill transfer request descriptor to this slot.
- //
- Trd = ((UTP_TRD*)Private->UtpTrlBase) + Slot;
- Status = UfsCreateDMCommandDesc (Private, &Packet, Trd, &CmdDescHost, &CmdDescMapping);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Check the transfer request result.
- //
- UfsHc = Private->UfsHostController;
- QueryResp = (UTP_QUERY_RESP_UPIU*)((UINT8*)CmdDescHost + Trd->RuO * sizeof (UINT32));
- ASSERT (QueryResp != NULL);
- CmdDescSize = 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.
- //
- Status = UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << Slot, 0, Packet.Timeout);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- if (QueryResp->QueryResp != 0) {
- DumpQueryResponseResult (QueryResp->QueryResp);
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- if (Trd->Ocs == 0) {
- *Value = (UINT8)QueryResp->Tsf.Value;
- } else {
- Status = EFI_DEVICE_ERROR;
- }
-
-Exit:
- UfsHc->Flush (UfsHc);
-
- UfsStopExecCmd (Private, Slot);
-
- if (CmdDescMapping != NULL) {
- UfsHc->Unmap (UfsHc, CmdDescMapping);
- }
- if (CmdDescHost != NULL) {
- UfsHc->FreeBuffer (UfsHc, EFI_SIZE_TO_PAGES (CmdDescSize), CmdDescHost);
- }
-
- return Status;
+ return UfsSendDmRequest (Private, &Packet);
}
/**
--
2.12.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
2017-03-22 1:28 [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
2017-03-22 1:28 ` [PATCH 1/2] MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX' Hao Wu
2017-03-22 1:28 ` [PATCH 2/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
@ 2017-04-20 2:04 ` Tian, Feng
2 siblings, 0 replies; 4+ messages in thread
From: Tian, Feng @ 2017-04-20 2:04 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Tian, Feng
Reviewed-by: Feng Tian <feng.tian@intel.com>
-----Original Message-----
From: Wu, Hao A
Sent: Wednesday, March 22, 2017 9:28 AM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Tian, Feng <feng.tian@intel.com>
Subject: [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
The series changes the UFS host to wait for the device to clear the 'fDeviceInit' bit by a device after setting this flag.
The series also cleans up the usages of 'EFI_D_XXX' and replaces them with 'DEBUG_XXX' in DEBUG().
Cc: Feng Tian <feng.tian@intel.com>
Hao Wu (2):
MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX'
MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 89 ++--
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 53 ++-
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 471 +++++++++-----------
3 files changed, 312 insertions(+), 301 deletions(-)
--
2.12.0.windows.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-20 2:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-22 1:28 [PATCH 0/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
2017-03-22 1:28 ` [PATCH 1/2] MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX' Hao Wu
2017-03-22 1:28 ` [PATCH 2/2] MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init Hao Wu
2017-04-20 2:04 ` [PATCH 0/2] " Tian, Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox