From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ml01.01.org (Postfix) with ESMTP id 606521A1E18 for ; Tue, 9 Aug 2016 01:20:49 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 09 Aug 2016 01:20:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,493,1464678000"; d="scan'208";a="152867885" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 09 Aug 2016 01:20:49 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 9 Aug 2016 01:20:48 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.107]) with mapi id 14.03.0248.002; Tue, 9 Aug 2016 16:20:46 +0800 From: "Zeng, Star" To: "Tian, Feng" CC: "edk2-devel@lists.01.org" Thread-Topic: [patch] MdeModulePkg/AtaAtapiPassThru: update AtaStatusBlock after cmd exec Thread-Index: AQHR8hGi2yf92viKaEy/gX4/qgyRXqBASaWg Date: Tue, 9 Aug 2016 08:20:46 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB048310036A1F31@shsmsx102.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/AtaAtapiPassThru: update AtaStatusBlock after cmd exec X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2016 08:20:49 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: Tian, Feng=20 Sent: Tuesday, August 9, 2016 3:42 PM To: Zeng, Star Cc: edk2-devel@lists.01.org Subject: [patch] MdeModulePkg/AtaAtapiPassThru: update AtaStatusBlock after= cmd exec AhciDumpPortStatus doesn't fully populate all the fields of AtaStatusBlock = after completing command execution, which may bring issue if someone depend= s on the return status. Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian --- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 39 ++++++++++++++++++--= ---- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePk= g/Bus/Ata/AtaAtapiPassThru/AhciMode.c index 469a40a..f4dbc92 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c @@ -371,6 +371,7 @@ AhciClearPortStatus ( in the Status Register, the Error Register's value is also be dumped. =20 @param PciIo The PCI IO protocol instance. + @param AhciRegisters The pointer to the EFI_AHCI_REGISTERS. @param Port The number of port. @param AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structur= e. =20 @@ -379,24 +380,42 @@ VOID EFIAPI AhciDumpPortStatus ( IN EFI_PCI_IO_PROTOCOL *PciIo, + IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock ) { - UINT32 Offset; + UINTN Offset; UINT32 Data; + UINTN FisBaseAddr; + EFI_STATUS Status; =20 ASSERT (PciIo !=3D NULL); =20 - Offset =3D EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AH= CI_PORT_TFD; - Data =3D AhciReadReg (PciIo, Offset); - if (AtaStatusBlock !=3D NULL) { ZeroMem (AtaStatusBlock, sizeof (EFI_ATA_STATUS_BLOCK)); =20 - AtaStatusBlock->AtaStatus =3D (UINT8)Data; - if ((AtaStatusBlock->AtaStatus & BIT0) !=3D 0) { - AtaStatusBlock->AtaError =3D (UINT8)(Data >> 8); + FisBaseAddr =3D (UINTN)AhciRegisters->AhciRFis + Port * sizeof (EFI_AH= CI_RECEIVED_FIS); + Offset =3D FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET; + + Status =3D AhciCheckMemSet (Offset, EFI_AHCI_FIS_TYPE_MASK, EFI_AHCI_F= IS_REGISTER_D2H, NULL); + if (!EFI_ERROR (Status)) { + // + // If D2H FIS is received, update StatusBlock with its content. + // + CopyMem (AtaStatusBlock, (UINT8 *)Offset, sizeof (EFI_ATA_STATUS_BLO= CK)); + } else { + // + // If D2H FIS is not received, only update Status & Error field thro= ugh PxTFD + // as there is no other way to get the content of the Shadow Registe= r Block. + // + Offset =3D EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EF= I_AHCI_PORT_TFD; + Data =3D AhciReadReg (PciIo, (UINT32)Offset); + + AtaStatusBlock->AtaStatus =3D (UINT8)Data; + if ((AtaStatusBlock->AtaStatus & BIT0) !=3D 0) { + AtaStatusBlock->AtaError =3D (UINT8)(Data >> 8); + } } } } @@ -866,7 +885,7 @@ Exit: Map ); =20 - AhciDumpPortStatus (PciIo, Port, AtaStatusBlock); + AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); =20 return Status; } @@ -1085,7 +1104,7 @@ Exit: } } =20 - AhciDumpPortStatus (PciIo, Port, AtaStatusBlock); + AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); return Status; } =20 @@ -1201,7 +1220,7 @@ Exit: Timeout ); =20 - AhciDumpPortStatus (PciIo, Port, AtaStatusBlock); + AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); =20 return Status; } -- 2.7.1.windows.2