mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/ScsiDisk:If the SCSI device target status is in CHECK_CONDITION, then parse sense data to decide which actions need to be done.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tian, Feng <feng.tian@intel.com> Reviewed-by: Fu, Siyuan <siyuan.fu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15215 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
489c314207
commit
52f8e370ac
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
SCSI disk driver that layers on every SCSI IO protocol in the system.
|
SCSI disk driver that layers on every SCSI IO protocol in the system.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -2085,16 +2085,19 @@ ScsiDiskRead10 (
|
||||||
{
|
{
|
||||||
UINT8 SenseDataLength;
|
UINT8 SenseDataLength;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS ReturnStatus;
|
||||||
UINT8 HostAdapterStatus;
|
UINT8 HostAdapterStatus;
|
||||||
UINT8 TargetStatus;
|
UINT8 TargetStatus;
|
||||||
|
UINTN Action;
|
||||||
|
|
||||||
*NeedRetry = FALSE;
|
*NeedRetry = FALSE;
|
||||||
*NumberOfSenseKeys = 0;
|
*NumberOfSenseKeys = 0;
|
||||||
SenseDataLength = 0;
|
Action = ACTION_NO_ACTION;
|
||||||
Status = ScsiRead10Command (
|
SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
|
||||||
|
ReturnStatus = ScsiRead10Command (
|
||||||
ScsiDiskDevice->ScsiIo,
|
ScsiDiskDevice->ScsiIo,
|
||||||
Timeout,
|
Timeout,
|
||||||
NULL,
|
ScsiDiskDevice->SenseData,
|
||||||
&SenseDataLength,
|
&SenseDataLength,
|
||||||
&HostAdapterStatus,
|
&HostAdapterStatus,
|
||||||
&TargetStatus,
|
&TargetStatus,
|
||||||
|
@ -2103,7 +2106,60 @@ ScsiDiskRead10 (
|
||||||
StartLba,
|
StartLba,
|
||||||
SectorSize
|
SectorSize
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (ReturnStatus == EFI_NOT_READY) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return ReturnStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// go ahead to check HostAdapterStatus and TargetStatus
|
||||||
|
// (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL)
|
||||||
|
//
|
||||||
|
Status = CheckHostAdapterStatus (HostAdapterStatus);
|
||||||
|
if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
//
|
||||||
|
// reset the scsi channel
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = CheckTargetStatus (TargetStatus);
|
||||||
|
if (Status == EFI_NOT_READY) {
|
||||||
|
//
|
||||||
|
// reset the scsi device
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) {
|
||||||
|
DEBUG ((EFI_D_VERBOSE, "ScsiDiskRead10: Check Condition happened!\n"));
|
||||||
|
Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2137,17 +2193,20 @@ ScsiDiskWrite10 (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS ReturnStatus;
|
||||||
UINT8 SenseDataLength;
|
UINT8 SenseDataLength;
|
||||||
UINT8 HostAdapterStatus;
|
UINT8 HostAdapterStatus;
|
||||||
UINT8 TargetStatus;
|
UINT8 TargetStatus;
|
||||||
|
UINTN Action;
|
||||||
|
|
||||||
*NeedRetry = FALSE;
|
*NeedRetry = FALSE;
|
||||||
*NumberOfSenseKeys = 0;
|
*NumberOfSenseKeys = 0;
|
||||||
SenseDataLength = 0;
|
Action = ACTION_NO_ACTION;
|
||||||
Status = ScsiWrite10Command (
|
SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
|
||||||
|
ReturnStatus = ScsiWrite10Command (
|
||||||
ScsiDiskDevice->ScsiIo,
|
ScsiDiskDevice->ScsiIo,
|
||||||
Timeout,
|
Timeout,
|
||||||
NULL,
|
ScsiDiskDevice->SenseData,
|
||||||
&SenseDataLength,
|
&SenseDataLength,
|
||||||
&HostAdapterStatus,
|
&HostAdapterStatus,
|
||||||
&TargetStatus,
|
&TargetStatus,
|
||||||
|
@ -2156,7 +2215,59 @@ ScsiDiskWrite10 (
|
||||||
StartLba,
|
StartLba,
|
||||||
SectorSize
|
SectorSize
|
||||||
);
|
);
|
||||||
|
if (ReturnStatus == EFI_NOT_READY) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return ReturnStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// go ahead to check HostAdapterStatus and TargetStatus
|
||||||
|
// (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL)
|
||||||
|
//
|
||||||
|
Status = CheckHostAdapterStatus (HostAdapterStatus);
|
||||||
|
if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
//
|
||||||
|
// reset the scsi channel
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = CheckTargetStatus (TargetStatus);
|
||||||
|
if (Status == EFI_NOT_READY) {
|
||||||
|
//
|
||||||
|
// reset the scsi device
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) {
|
||||||
|
DEBUG ((EFI_D_VERBOSE, "ScsiDiskWrite10: Check Condition happened!\n"));
|
||||||
|
Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2190,16 +2301,19 @@ ScsiDiskRead16 (
|
||||||
{
|
{
|
||||||
UINT8 SenseDataLength;
|
UINT8 SenseDataLength;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS ReturnStatus;
|
||||||
UINT8 HostAdapterStatus;
|
UINT8 HostAdapterStatus;
|
||||||
UINT8 TargetStatus;
|
UINT8 TargetStatus;
|
||||||
|
UINTN Action;
|
||||||
|
|
||||||
*NeedRetry = FALSE;
|
*NeedRetry = FALSE;
|
||||||
*NumberOfSenseKeys = 0;
|
*NumberOfSenseKeys = 0;
|
||||||
SenseDataLength = 0;
|
Action = ACTION_NO_ACTION;
|
||||||
Status = ScsiRead16Command (
|
SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
|
||||||
|
ReturnStatus = ScsiRead16Command (
|
||||||
ScsiDiskDevice->ScsiIo,
|
ScsiDiskDevice->ScsiIo,
|
||||||
Timeout,
|
Timeout,
|
||||||
NULL,
|
ScsiDiskDevice->SenseData,
|
||||||
&SenseDataLength,
|
&SenseDataLength,
|
||||||
&HostAdapterStatus,
|
&HostAdapterStatus,
|
||||||
&TargetStatus,
|
&TargetStatus,
|
||||||
|
@ -2208,7 +2322,59 @@ ScsiDiskRead16 (
|
||||||
StartLba,
|
StartLba,
|
||||||
SectorSize
|
SectorSize
|
||||||
);
|
);
|
||||||
|
if (ReturnStatus == EFI_NOT_READY) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return ReturnStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// go ahead to check HostAdapterStatus and TargetStatus
|
||||||
|
// (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL)
|
||||||
|
//
|
||||||
|
Status = CheckHostAdapterStatus (HostAdapterStatus);
|
||||||
|
if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
//
|
||||||
|
// reset the scsi channel
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = CheckTargetStatus (TargetStatus);
|
||||||
|
if (Status == EFI_NOT_READY) {
|
||||||
|
//
|
||||||
|
// reset the scsi device
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) {
|
||||||
|
DEBUG ((EFI_D_VERBOSE, "ScsiDiskRead16: Check Condition happened!\n"));
|
||||||
|
Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2242,17 +2408,20 @@ ScsiDiskWrite16 (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS ReturnStatus;
|
||||||
UINT8 SenseDataLength;
|
UINT8 SenseDataLength;
|
||||||
UINT8 HostAdapterStatus;
|
UINT8 HostAdapterStatus;
|
||||||
UINT8 TargetStatus;
|
UINT8 TargetStatus;
|
||||||
|
UINTN Action;
|
||||||
|
|
||||||
*NeedRetry = FALSE;
|
*NeedRetry = FALSE;
|
||||||
*NumberOfSenseKeys = 0;
|
*NumberOfSenseKeys = 0;
|
||||||
SenseDataLength = 0;
|
Action = ACTION_NO_ACTION;
|
||||||
Status = ScsiWrite16Command (
|
SenseDataLength = (UINT8) (ScsiDiskDevice->SenseDataNumber * sizeof (EFI_SCSI_SENSE_DATA));
|
||||||
|
ReturnStatus = ScsiWrite16Command (
|
||||||
ScsiDiskDevice->ScsiIo,
|
ScsiDiskDevice->ScsiIo,
|
||||||
Timeout,
|
Timeout,
|
||||||
NULL,
|
ScsiDiskDevice->SenseData,
|
||||||
&SenseDataLength,
|
&SenseDataLength,
|
||||||
&HostAdapterStatus,
|
&HostAdapterStatus,
|
||||||
&TargetStatus,
|
&TargetStatus,
|
||||||
|
@ -2261,7 +2430,59 @@ ScsiDiskWrite16 (
|
||||||
StartLba,
|
StartLba,
|
||||||
SectorSize
|
SectorSize
|
||||||
);
|
);
|
||||||
|
if (ReturnStatus == EFI_NOT_READY) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if ((ReturnStatus == EFI_INVALID_PARAMETER) || (ReturnStatus == EFI_UNSUPPORTED)) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return ReturnStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// go ahead to check HostAdapterStatus and TargetStatus
|
||||||
|
// (EFI_TIMEOUT, EFI_DEVICE_ERROR, EFI_WARN_BUFFER_TOO_SMALL)
|
||||||
|
//
|
||||||
|
Status = CheckHostAdapterStatus (HostAdapterStatus);
|
||||||
|
if ((Status == EFI_TIMEOUT) || (Status == EFI_NOT_READY)) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
//
|
||||||
|
// reset the scsi channel
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetBus (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = CheckTargetStatus (TargetStatus);
|
||||||
|
if (Status == EFI_NOT_READY) {
|
||||||
|
//
|
||||||
|
// reset the scsi device
|
||||||
|
//
|
||||||
|
ScsiDiskDevice->ScsiIo->ResetDevice (ScsiDiskDevice->ScsiIo);
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) {
|
||||||
|
DEBUG ((EFI_D_VERBOSE, "ScsiDiskWrite16: Check Condition happened!\n"));
|
||||||
|
Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue