]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/AtaAtapiPassThru: Move error check behind the place that SetupFIS frame...
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 22 Aug 2012 07:12:10 +0000 (07:12 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 22 Aug 2012 07:12:10 +0000 (07:12 +0000)
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/edk2@13663 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c

index c2c2c2869a391a33e7e2c9ca3903fd0023c48772..7101c665bfa73dde0aedb73ecbb66dcde92da5a7 100644 (file)
@@ -759,17 +759,21 @@ AhciPioTransfer (
     Status = EFI_TIMEOUT;\r
     Delay  = (UINT32) (DivU64x32 (Timeout, 1000) + 1);\r
     do {\r
-      Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;\r
-      PortTfd = AhciReadReg (PciIo, (UINT32) Offset);\r
-\r
-      if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {\r
-        Status = EFI_DEVICE_ERROR;\r
-        break;\r
-      }\r
       Offset = FisBaseAddr + EFI_AHCI_PIO_FIS_OFFSET;\r
 \r
       Status = AhciCheckMemSet (Offset, EFI_AHCI_FIS_TYPE_MASK, EFI_AHCI_FIS_PIO_SETUP, 0);\r
       if (!EFI_ERROR (Status)) {\r
+        Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;\r
+        PortTfd = AhciReadReg (PciIo, (UINT32) Offset);\r
+        //\r
+        // PxTFD will be updated if there is a D2H or SetupFIS received. \r
+        // For PIO IN transfer, D2H means a device error. Therefore we only need to check the TFD after receiving a SetupFIS.\r
+        //\r
+        if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {\r
+          Status = EFI_DEVICE_ERROR;\r
+          break;\r
+        }\r
+\r
         PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));\r
         if (PrdCount == DataCount) {\r
           break;\r