On 13/08/14 01:04, Tian, Feng wrote:
> Hi, Reza
> 
> Thanks for your effort, Reza. I made a little coding style enhancement based 
> on your proposed patch. please help view it.
> 
> PS: I am a little curious on "some Marvel controllers use D2H only instead of 
> PIO Setup FIS". If it's that case, does it mean current logic will never 
> break out the loop? Do we need enhance code to handle this?
No it won't break out, but the will instead time out. A. Sava explained the
issue in his.

I'm attaching a patch with the things we talked about, but this results in
duplicate code. There is only a little thing i can think of to reduce the
duplicate breaks.
>From b362cd4e50d4d9dd55eb6adb8940e94430e94bc7 Mon Sep 17 00:00:00 2001
From: Reza Jelveh <reza.jel...@tuhh.de>
Date: Wed, 6 Aug 2014 17:47:20 +0200
Subject: [PATCH 1/3] MdeModulePkg: Check D2H register status in
 AhciPioTransfer

Some AHCI controllers such as the Marvel 9230 controllers do not send
PIO Setup FIS when the PIO data-in command is completed. Instead they
just send a D2H FIS.

To accomodate for this possibility the status code of the D2H FIS is
checked.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Reza Jelveh <reza.jel...@tuhh.de>
---
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 14 ++++++++++++--
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index 7fc7a28..487f516 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -703,6 +703,7 @@ AhciPioTransfer (
   EFI_AHCI_COMMAND_LIST         CmdList;
   UINT32                        PortTfd;
   UINT32                        PrdCount;
+  UINT8                         D2HStatus;
   BOOLEAN                       InfiniteWait;
 
   if (Timeout == 0) {
@@ -804,8 +805,17 @@ AhciPioTransfer (
       Offset = FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET;
       Status = AhciCheckMemSet (Offset, EFI_AHCI_FIS_TYPE_MASK, EFI_AHCI_FIS_REGISTER_D2H, NULL);
       if (!EFI_ERROR (Status)) {
-        Status = EFI_DEVICE_ERROR;
-        break;
+        D2HStatus = *(volatile UINT8 *) (Offset + EFI_AHCI_D2H_FIS_STATUS_OFFSET);
+
+        if ((D2HStatus & EFI_AHCI_D2H_FIS_ERR) != 0) {
+          Status = EFI_DEVICE_ERROR;
+          break;
+        }
+
+        PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
+        if (PrdCount == DataCount) {
+          break;
+        }
       }
 
       //
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
index 485b647..9fe1fb3 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
@@ -78,12 +78,15 @@ typedef union {
 #define   EFI_AHCI_FIS_SET_DEVICE_LENGTH       8
 
 #define EFI_AHCI_D2H_FIS_OFFSET                0x40
+#define   EFI_AHCI_D2H_FIS_STATUS_OFFSET       0x02
+#define   EFI_AHCI_D2H_FIS_ERR                 BIT0
 #define EFI_AHCI_DMA_FIS_OFFSET                0x00
 #define EFI_AHCI_PIO_FIS_OFFSET                0x20
 #define EFI_AHCI_SDB_FIS_OFFSET                0x58
 #define EFI_AHCI_FIS_TYPE_MASK                 0xFF
 #define EFI_AHCI_U_FIS_OFFSET                  0x60
 
+
 //
 // Port register
 //
-- 
1.9.2

------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to