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,25 +2085,81 @@ 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));
|
||||||
ScsiDiskDevice->ScsiIo,
|
ReturnStatus = ScsiRead10Command (
|
||||||
Timeout,
|
ScsiDiskDevice->ScsiIo,
|
||||||
NULL,
|
Timeout,
|
||||||
&SenseDataLength,
|
ScsiDiskDevice->SenseData,
|
||||||
&HostAdapterStatus,
|
&SenseDataLength,
|
||||||
&TargetStatus,
|
&HostAdapterStatus,
|
||||||
DataBuffer,
|
&TargetStatus,
|
||||||
DataLength,
|
DataBuffer,
|
||||||
StartLba,
|
DataLength,
|
||||||
SectorSize
|
StartLba,
|
||||||
);
|
SectorSize
|
||||||
return Status;
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2137,26 +2193,81 @@ 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));
|
||||||
ScsiDiskDevice->ScsiIo,
|
ReturnStatus = ScsiWrite10Command (
|
||||||
Timeout,
|
ScsiDiskDevice->ScsiIo,
|
||||||
NULL,
|
Timeout,
|
||||||
&SenseDataLength,
|
ScsiDiskDevice->SenseData,
|
||||||
&HostAdapterStatus,
|
&SenseDataLength,
|
||||||
&TargetStatus,
|
&HostAdapterStatus,
|
||||||
DataBuffer,
|
&TargetStatus,
|
||||||
DataLength,
|
DataBuffer,
|
||||||
StartLba,
|
DataLength,
|
||||||
SectorSize
|
StartLba,
|
||||||
);
|
SectorSize
|
||||||
return Status;
|
);
|
||||||
|
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;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2190,25 +2301,80 @@ 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));
|
||||||
ScsiDiskDevice->ScsiIo,
|
ReturnStatus = ScsiRead16Command (
|
||||||
Timeout,
|
ScsiDiskDevice->ScsiIo,
|
||||||
NULL,
|
Timeout,
|
||||||
&SenseDataLength,
|
ScsiDiskDevice->SenseData,
|
||||||
&HostAdapterStatus,
|
&SenseDataLength,
|
||||||
&TargetStatus,
|
&HostAdapterStatus,
|
||||||
DataBuffer,
|
&TargetStatus,
|
||||||
DataLength,
|
DataBuffer,
|
||||||
StartLba,
|
DataLength,
|
||||||
SectorSize
|
StartLba,
|
||||||
);
|
SectorSize
|
||||||
return Status;
|
);
|
||||||
|
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;
|
||||||
|
} else if (Action == ACTION_RETRY_COMMAND_LATER) {
|
||||||
|
*NeedRetry = TRUE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
*NeedRetry = FALSE;
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2242,26 +2408,81 @@ 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));
|
||||||
ScsiDiskDevice->ScsiIo,
|
ReturnStatus = ScsiWrite16Command (
|
||||||
Timeout,
|
ScsiDiskDevice->ScsiIo,
|
||||||
NULL,
|
Timeout,
|
||||||
&SenseDataLength,
|
ScsiDiskDevice->SenseData,
|
||||||
&HostAdapterStatus,
|
&SenseDataLength,
|
||||||
&TargetStatus,
|
&HostAdapterStatus,
|
||||||
DataBuffer,
|
&TargetStatus,
|
||||||
DataLength,
|
DataBuffer,
|
||||||
StartLba,
|
DataLength,
|
||||||
SectorSize
|
StartLba,
|
||||||
);
|
SectorSize
|
||||||
return Status;
|
);
|
||||||
|
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;
|
||||||
|
} 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