MdeModulePkg/NvmExpressDxe: Check if CSTS.RDY is 0 to wait NVMe Host controller disable
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tian, Feng <feng.tian@intel.com> Reviewed-by: Zeng, Star <star.zeng@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15557 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
|
||||
NVM Express specification.
|
||||
|
||||
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2013 - 2014, 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
|
||||
@@ -430,6 +430,8 @@ NvmeDisableController (
|
||||
NVME_CC Cc;
|
||||
NVME_CSTS Csts;
|
||||
EFI_STATUS Status;
|
||||
UINT32 Index;
|
||||
UINT8 Timeout;
|
||||
|
||||
//
|
||||
// Read Controller Configuration Register.
|
||||
@@ -450,19 +452,35 @@ NvmeDisableController (
|
||||
return Status;
|
||||
}
|
||||
|
||||
gBS->Stall(10000);
|
||||
|
||||
//
|
||||
// Check if the controller is reset
|
||||
// Cap.To specifies max delay time in 500ms increments for Csts.Rdy to transition from 1 to 0 after
|
||||
// Cc.Enable transition from 1 to 0. Loop produces a 1 millisecond delay per itteration, up to 500 * Cap.To.
|
||||
//
|
||||
Status = ReadNvmeControllerStatus (Private, &Csts);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
if (Private->Cap.To == 0) {
|
||||
Timeout = 1;
|
||||
} else {
|
||||
Timeout = Private->Cap.To;
|
||||
}
|
||||
|
||||
if (Csts.Rdy != 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
for(Index = (Timeout * 500); Index != 0; --Index) {
|
||||
gBS->Stall(1000);
|
||||
|
||||
//
|
||||
// Check if the controller is initialized
|
||||
//
|
||||
Status = ReadNvmeControllerStatus (Private, &Csts);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Csts.Rdy == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == 0) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
DEBUG ((EFI_D_INFO, "NVMe controller is disabled with status [%r].\n", Status));
|
||||
@@ -959,7 +977,7 @@ NvmeControllerInit (
|
||||
DEBUG ((EFI_D_INFO, " MN : %a\n", (CHAR8 *)(Private->ControllerData->Mn)));
|
||||
DEBUG ((EFI_D_INFO, " FR : 0x%x\n", *((UINT64*)Private->ControllerData->Fr)));
|
||||
DEBUG ((EFI_D_INFO, " RAB : 0x%x\n", Private->ControllerData->Rab));
|
||||
DEBUG ((EFI_D_INFO, " IEEE : 0x%x\n", *(UINT32*)Private->ControllerData->Ieee_oiu));
|
||||
DEBUG ((EFI_D_INFO, " IEEE : 0x%x\n", *(UINT32*)Private->ControllerData->Ieee_oui));
|
||||
DEBUG ((EFI_D_INFO, " AERL : 0x%x\n", Private->ControllerData->Aerl));
|
||||
DEBUG ((EFI_D_INFO, " SQES : 0x%x\n", Private->ControllerData->Sqes));
|
||||
DEBUG ((EFI_D_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes));
|
||||
|
Reference in New Issue
Block a user