summaryrefslogtreecommitdiff
path: root/edk2/MdeModulePkg
diff options
context:
space:
mode:
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-22 07:12:10 +0000
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-22 07:12:10 +0000
commita08895bbff642d1e948ad7d65a6ad7b2e9daf84a (patch)
treec134ea5abaf6f922f33b187281dcd22602fb8e72 /edk2/MdeModulePkg
parent06bb0f70388bf2c500a7bc30cf4c277cbf261138 (diff)
MdeModulePkg/AtaAtapiPassThru: Move error check behind the place that SetupFIS frame is received.
This way is used to avoid that the subsequent operations are treated as failure if the last operation is wrong. Signed-off-by: Tian Feng <feng.tian@intel.com> Reviewed-by: Sun Rui <rui.sun@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@13663 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/MdeModulePkg')
-rw-r--r--edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index c2c2c2869..7101c665b 100644
--- a/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -759,17 +759,21 @@ AhciPioTransfer (
Status = EFI_TIMEOUT;
Delay = (UINT32) (DivU64x32 (Timeout, 1000) + 1);
do {
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
- PortTfd = AhciReadReg (PciIo, (UINT32) Offset);
-
- if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {
- Status = EFI_DEVICE_ERROR;
- break;
- }
Offset = FisBaseAddr + EFI_AHCI_PIO_FIS_OFFSET;
Status = AhciCheckMemSet (Offset, EFI_AHCI_FIS_TYPE_MASK, EFI_AHCI_FIS_PIO_SETUP, 0);
if (!EFI_ERROR (Status)) {
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
+ PortTfd = AhciReadReg (PciIo, (UINT32) Offset);
+ //
+ // PxTFD will be updated if there is a D2H or SetupFIS received.
+ // For PIO IN transfer, D2H means a device error. Therefore we only need to check the TFD after receiving a SetupFIS.
+ //
+ if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
if (PrdCount == DataCount) {
break;