public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
@ 2016-11-24  7:54 Marcin Wojtas
  2016-11-24  7:56 ` Ard Biesheuvel
  2016-11-24  8:35 ` Tian, Feng
  0 siblings, 2 replies; 8+ messages in thread
From: Marcin Wojtas @ 2016-11-24  7:54 UTC (permalink / raw)
  To: edk2-devel
  Cc: feng.tian, michael.d.kinney, liming.gao, leif.lindholm,
	ard.biesheuvel, mw, jsd

According to AHCI Spec 1.3 GHC.AE bit description:
"The implementation of this bit is dependent upon the value of the
CAP.SAM bit. If CAP.SAM is '0', then GHC.AE shall be read-write and shall
have a reset value of '0'. If CAP.SAM is '1', then AE shall be read-only
and shall have a reset value of '1'."

Being in AhciMode, for proper operation it is required, that GHC.AE bit
is always set, before any other AHCI registers are written to. Current
AhciMode implementation, both in AhciReset() and AhciModeInitialization()
functions, set GHC.AE bit only depending on 'CAP.SAM == 0' condition,
assuming (according to the AHCI spec), that otherwise it has to be set
anyway. It may however happen, that even if 'CAP.SAM == 1', GHC.AE
requires updating by software.

This patch enables in AhciMode setting GHC.AE in case its initial value
is '0'. It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC
families. The change is transparent to all other platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Signed-off-by: Jan Dabros <jsd@semihalf.com>

---
Changelog:
v1 -> v2

* Instead of doing it uncoditionally, enable setting GHC.AE bit only in
  case its initial value is '0'

---
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index 533d201..4d01c1d 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -1451,17 +1451,13 @@ AhciReset (
 {
   UINT64                 Delay;
   UINT32                 Value;
-  UINT32                 Capability;
 
   //
-  // Collect AHCI controller information
-  //
-  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-  
-  //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
+  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+
+  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
     AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
   }
 
@@ -2252,6 +2248,7 @@ AhciModeInitialization (
   EFI_ATA_COLLECTIVE_MODE          *SupportedModes;
   EFI_ATA_TRANSFER_MODE            TransferMode;
   UINT32                           PhyDetectDelay;
+  UINT32                           Value;
 
   if (Instance == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -2270,11 +2267,13 @@ AhciModeInitialization (
   // Collect AHCI controller information
   //
   Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-  
+
   //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
+  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+
+  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
     AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
   }
 
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24  7:54 [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci Marcin Wojtas
@ 2016-11-24  7:56 ` Ard Biesheuvel
  2016-11-24  8:01   ` Marcin Wojtas
  2016-11-24  8:35 ` Tian, Feng
  1 sibling, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2016-11-24  7:56 UTC (permalink / raw)
  To: Marcin Wojtas
  Cc: edk2-devel-01, Tian, Feng, Kinney, Michael D, Gao, Liming,
	Leif Lindholm, Jan Dąbroś

On 24 November 2016 at 07:54, Marcin Wojtas <mw@semihalf.com> wrote:
> According to AHCI Spec 1.3 GHC.AE bit description:
> "The implementation of this bit is dependent upon the value of the
> CAP.SAM bit. If CAP.SAM is '0', then GHC.AE shall be read-write and shall
> have a reset value of '0'. If CAP.SAM is '1', then AE shall be read-only
> and shall have a reset value of '1'."
>
> Being in AhciMode, for proper operation it is required, that GHC.AE bit
> is always set, before any other AHCI registers are written to. Current
> AhciMode implementation, both in AhciReset() and AhciModeInitialization()
> functions, set GHC.AE bit only depending on 'CAP.SAM == 0' condition,
> assuming (according to the AHCI spec), that otherwise it has to be set
> anyway. It may however happen, that even if 'CAP.SAM == 1', GHC.AE
> requires updating by software.
>
> This patch enables in AhciMode setting GHC.AE in case its initial value
> is '0'. It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC
> families. The change is transparent to all other platforms.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> Signed-off-by: Jan Dabros <jsd@semihalf.com>
>
> ---
> Changelog:
> v1 -> v2
>
> * Instead of doing it uncoditionally, enable setting GHC.AE bit only in
>   case its initial value is '0'
>
> ---
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> index 533d201..4d01c1d 100644
> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> @@ -1451,17 +1451,13 @@ AhciReset (
>  {
>    UINT64                 Delay;
>    UINT32                 Value;
> -  UINT32                 Capability;
>
>    //
> -  // Collect AHCI controller information
> -  //
> -  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
> -
> -  //
> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>    //
> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
> +
> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>    }
>

If we are ignoring the capability bits now, do we still need to read them?

> @@ -2252,6 +2248,7 @@ AhciModeInitialization (
>    EFI_ATA_COLLECTIVE_MODE          *SupportedModes;
>    EFI_ATA_TRANSFER_MODE            TransferMode;
>    UINT32                           PhyDetectDelay;
> +  UINT32                           Value;
>
>    if (Instance == NULL) {
>      return EFI_INVALID_PARAMETER;
> @@ -2270,11 +2267,13 @@ AhciModeInitialization (
>    // Collect AHCI controller information
>    //
>    Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
> -
> +
>    //
> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>    //
> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
> +
> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>    }
>
> --
> 1.8.3.1
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24  7:56 ` Ard Biesheuvel
@ 2016-11-24  8:01   ` Marcin Wojtas
  2016-11-24  8:02     ` Ard Biesheuvel
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Wojtas @ 2016-11-24  8:01 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel-01, Tian, Feng, Kinney, Michael D, Gao, Liming,
	Leif Lindholm, Jan Dąbroś

Hi Ard,

2016-11-24 8:56 GMT+01:00 Ard Biesheuvel <ard.biesheuvel@linaro.org>:
> On 24 November 2016 at 07:54, Marcin Wojtas <mw@semihalf.com> wrote:
>> According to AHCI Spec 1.3 GHC.AE bit description:
>> "The implementation of this bit is dependent upon the value of the
>> CAP.SAM bit. If CAP.SAM is '0', then GHC.AE shall be read-write and shall
>> have a reset value of '0'. If CAP.SAM is '1', then AE shall be read-only
>> and shall have a reset value of '1'."
>>
>> Being in AhciMode, for proper operation it is required, that GHC.AE bit
>> is always set, before any other AHCI registers are written to. Current
>> AhciMode implementation, both in AhciReset() and AhciModeInitialization()
>> functions, set GHC.AE bit only depending on 'CAP.SAM == 0' condition,
>> assuming (according to the AHCI spec), that otherwise it has to be set
>> anyway. It may however happen, that even if 'CAP.SAM == 1', GHC.AE
>> requires updating by software.
>>
>> This patch enables in AhciMode setting GHC.AE in case its initial value
>> is '0'. It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC
>> families. The change is transparent to all other platforms.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
>> Signed-off-by: Jan Dabros <jsd@semihalf.com>
>>
>> ---
>> Changelog:
>> v1 -> v2
>>
>> * Instead of doing it uncoditionally, enable setting GHC.AE bit only in
>>   case its initial value is '0'
>>
>> ---
>>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++++++++++-----------
>>  1 file changed, 10 insertions(+), 11 deletions(-)
>>
>> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
>> index 533d201..4d01c1d 100644
>> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
>> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
>> @@ -1451,17 +1451,13 @@ AhciReset (
>>  {
>>    UINT64                 Delay;
>>    UINT32                 Value;
>> -  UINT32                 Capability;
>>
>>    //
>> -  // Collect AHCI controller information
>> -  //
>> -  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
>> -
>> -  //
>> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
>> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>>    //
>> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
>> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
>> +
>> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>>    }
>>
>
> If we are ignoring the capability bits now, do we still need to read them?

In the context above (AhciReset() function) reading capability is
removed. In AhciModeInitialization() however, it has to remain,
because of following lines:

  //
  // Enable 64-bit DMA support in the PCI layer if this controller
  // supports it.
  //
  if ((Capability & EFI_AHCI_CAP_S64A) != 0) {

Which, I can see, were added by you:)

Best regards,
Marcin

>
>> @@ -2252,6 +2248,7 @@ AhciModeInitialization (
>>    EFI_ATA_COLLECTIVE_MODE          *SupportedModes;
>>    EFI_ATA_TRANSFER_MODE            TransferMode;
>>    UINT32                           PhyDetectDelay;
>> +  UINT32                           Value;
>>
>>    if (Instance == NULL) {
>>      return EFI_INVALID_PARAMETER;
>> @@ -2270,11 +2267,13 @@ AhciModeInitialization (
>>    // Collect AHCI controller information
>>    //
>>    Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
>> -
>> +
>>    //
>> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
>> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>>    //
>> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
>> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
>> +
>> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>>    }
>>
>> --
>> 1.8.3.1
>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24  8:01   ` Marcin Wojtas
@ 2016-11-24  8:02     ` Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2016-11-24  8:02 UTC (permalink / raw)
  To: Marcin Wojtas
  Cc: edk2-devel-01, Tian, Feng, Kinney, Michael D, Gao, Liming,
	Leif Lindholm, Jan Dąbroś

On 24 November 2016 at 08:01, Marcin Wojtas <mw@semihalf.com> wrote:
> Hi Ard,
>
> 2016-11-24 8:56 GMT+01:00 Ard Biesheuvel <ard.biesheuvel@linaro.org>:
>> On 24 November 2016 at 07:54, Marcin Wojtas <mw@semihalf.com> wrote:
>>> According to AHCI Spec 1.3 GHC.AE bit description:
>>> "The implementation of this bit is dependent upon the value of the
>>> CAP.SAM bit. If CAP.SAM is '0', then GHC.AE shall be read-write and shall
>>> have a reset value of '0'. If CAP.SAM is '1', then AE shall be read-only
>>> and shall have a reset value of '1'."
>>>
>>> Being in AhciMode, for proper operation it is required, that GHC.AE bit
>>> is always set, before any other AHCI registers are written to. Current
>>> AhciMode implementation, both in AhciReset() and AhciModeInitialization()
>>> functions, set GHC.AE bit only depending on 'CAP.SAM == 0' condition,
>>> assuming (according to the AHCI spec), that otherwise it has to be set
>>> anyway. It may however happen, that even if 'CAP.SAM == 1', GHC.AE
>>> requires updating by software.
>>>
>>> This patch enables in AhciMode setting GHC.AE in case its initial value
>>> is '0'. It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC
>>> families. The change is transparent to all other platforms.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
>>> Signed-off-by: Jan Dabros <jsd@semihalf.com>
>>>
>>> ---
>>> Changelog:
>>> v1 -> v2
>>>
>>> * Instead of doing it uncoditionally, enable setting GHC.AE bit only in
>>>   case its initial value is '0'
>>>
>>> ---
>>>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++++++++++-----------
>>>  1 file changed, 10 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
>>> index 533d201..4d01c1d 100644
>>> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
>>> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
>>> @@ -1451,17 +1451,13 @@ AhciReset (
>>>  {
>>>    UINT64                 Delay;
>>>    UINT32                 Value;
>>> -  UINT32                 Capability;
>>>
>>>    //
>>> -  // Collect AHCI controller information
>>> -  //
>>> -  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
>>> -
>>> -  //
>>> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
>>> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>>>    //
>>> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
>>> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
>>> +
>>> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>>>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>>>    }
>>>
>>
>> If we are ignoring the capability bits now, do we still need to read them?
>
> In the context above (AhciReset() function) reading capability is
> removed. In AhciModeInitialization() however, it has to remain,
> because of following lines:
>
>   //
>   // Enable 64-bit DMA support in the PCI layer if this controller
>   // supports it.
>   //
>   if ((Capability & EFI_AHCI_CAP_S64A) != 0) {
>
> Which, I can see, were added by you:)
>

Ah, apologies, I misread the patch.

In that case

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24  7:54 [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci Marcin Wojtas
  2016-11-24  7:56 ` Ard Biesheuvel
@ 2016-11-24  8:35 ` Tian, Feng
  2016-11-24  9:07   ` Marcin Wojtas
  1 sibling, 1 reply; 8+ messages in thread
From: Tian, Feng @ 2016-11-24  8:35 UTC (permalink / raw)
  To: Marcin Wojtas, edk2-devel@lists.01.org
  Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, Gao, Liming,
	Kinney, Michael D, Tian, Feng

Reviewed-by: Feng Tian <feng.tian@intel.com>

Do you want me to push it into EDKII trunk?

Thanks
Feng

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Marcin Wojtas
Sent: Thursday, November 24, 2016 3:55 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.tian@intel.com>; ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [edk2] [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci

According to AHCI Spec 1.3 GHC.AE bit description:
"The implementation of this bit is dependent upon the value of the CAP.SAM bit. If CAP.SAM is '0', then GHC.AE shall be read-write and shall have a reset value of '0'. If CAP.SAM is '1', then AE shall be read-only and shall have a reset value of '1'."

Being in AhciMode, for proper operation it is required, that GHC.AE bit is always set, before any other AHCI registers are written to. Current AhciMode implementation, both in AhciReset() and AhciModeInitialization() functions, set GHC.AE bit only depending on 'CAP.SAM == 0' condition, assuming (according to the AHCI spec), that otherwise it has to be set anyway. It may however happen, that even if 'CAP.SAM == 1', GHC.AE requires updating by software.

This patch enables in AhciMode setting GHC.AE in case its initial value is '0'. It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC families. The change is transparent to all other platforms.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Signed-off-by: Jan Dabros <jsd@semihalf.com>

---
Changelog:
v1 -> v2

* Instead of doing it uncoditionally, enable setting GHC.AE bit only in
  case its initial value is '0'

---
 MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index 533d201..4d01c1d 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -1451,17 +1451,13 @@ AhciReset (
 {
   UINT64                 Delay;
   UINT32                 Value;
-  UINT32                 Capability;
 
   //
-  // Collect AHCI controller information
-  //
-  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-
-  //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
+  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+
+  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
     AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
   }
 
@@ -2252,6 +2248,7 @@ AhciModeInitialization (
   EFI_ATA_COLLECTIVE_MODE          *SupportedModes;
   EFI_ATA_TRANSFER_MODE            TransferMode;
   UINT32                           PhyDetectDelay;
+  UINT32                           Value;
 
   if (Instance == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -2270,11 +2267,13 @@ AhciModeInitialization (
   // Collect AHCI controller information
   //
   Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-  
+
   //
-  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
+  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
   //
-  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+
+  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
     AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
   }
 
--
1.8.3.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24  8:35 ` Tian, Feng
@ 2016-11-24  9:07   ` Marcin Wojtas
  2016-11-24 15:57     ` Ard Biesheuvel
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Wojtas @ 2016-11-24  9:07 UTC (permalink / raw)
  To: Tian, Feng
  Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org,
	leif.lindholm@linaro.org, Gao, Liming, Kinney, Michael D

Hi,

Yes, it would be great.

Thanks,
Marcin

2016-11-24 9:35 GMT+01:00 Tian, Feng <feng.tian@intel.com>:
> Reviewed-by: Feng Tian <feng.tian@intel.com>
>
> Do you want me to push it into EDKII trunk?
>
> Thanks
> Feng
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Marcin Wojtas
> Sent: Thursday, November 24, 2016 3:55 PM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.tian@intel.com>; ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2] [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
>
> According to AHCI Spec 1.3 GHC.AE bit description:
> "The implementation of this bit is dependent upon the value of the CAP.SAM bit. If CAP.SAM is '0', then GHC.AE shall be read-write and shall have a reset value of '0'. If CAP.SAM is '1', then AE shall be read-only and shall have a reset value of '1'."
>
> Being in AhciMode, for proper operation it is required, that GHC.AE bit is always set, before any other AHCI registers are written to. Current AhciMode implementation, both in AhciReset() and AhciModeInitialization() functions, set GHC.AE bit only depending on 'CAP.SAM == 0' condition, assuming (according to the AHCI spec), that otherwise it has to be set anyway. It may however happen, that even if 'CAP.SAM == 1', GHC.AE requires updating by software.
>
> This patch enables in AhciMode setting GHC.AE in case its initial value is '0'. It fixes AHCI support for Marvell Armada 70x0 and 80x0 SoC families. The change is transparent to all other platforms.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> Signed-off-by: Jan Dabros <jsd@semihalf.com>
>
> ---
> Changelog:
> v1 -> v2
>
> * Instead of doing it uncoditionally, enable setting GHC.AE bit only in
>   case its initial value is '0'
>
> ---
>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> index 533d201..4d01c1d 100644
> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> @@ -1451,17 +1451,13 @@ AhciReset (
>  {
>    UINT64                 Delay;
>    UINT32                 Value;
> -  UINT32                 Capability;
>
>    //
> -  // Collect AHCI controller information
> -  //
> -  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
> -
> -  //
> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>    //
> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
> +
> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>    }
>
> @@ -2252,6 +2248,7 @@ AhciModeInitialization (
>    EFI_ATA_COLLECTIVE_MODE          *SupportedModes;
>    EFI_ATA_TRANSFER_MODE            TransferMode;
>    UINT32                           PhyDetectDelay;
> +  UINT32                           Value;
>
>    if (Instance == NULL) {
>      return EFI_INVALID_PARAMETER;
> @@ -2270,11 +2267,13 @@ AhciModeInitialization (
>    // Collect AHCI controller information
>    //
>    Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
> -
> +
>    //
> -  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only is not set
> +  // Make sure that GHC.AE bit is set before accessing any AHCI registers.
>    //
> -  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
> +  Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
> +
> +  if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
>      AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
>    }
>
> --
> 1.8.3.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24  9:07   ` Marcin Wojtas
@ 2016-11-24 15:57     ` Ard Biesheuvel
  2016-11-24 16:06       ` Marcin Wojtas
  0 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2016-11-24 15:57 UTC (permalink / raw)
  To: Marcin Wojtas
  Cc: Tian, Feng, edk2-devel@lists.01.org, leif.lindholm@linaro.org,
	Gao, Liming, Kinney, Michael D

On 24 November 2016 at 09:07, Marcin Wojtas <mw@semihalf.com> wrote:
> Hi,
>
> Yes, it would be great.
>

Pushed, thanks.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
  2016-11-24 15:57     ` Ard Biesheuvel
@ 2016-11-24 16:06       ` Marcin Wojtas
  0 siblings, 0 replies; 8+ messages in thread
From: Marcin Wojtas @ 2016-11-24 16:06 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Tian, Feng, edk2-devel@lists.01.org, leif.lindholm@linaro.org,
	Gao, Liming, Kinney, Michael D

Thank you.

2016-11-24 16:57 GMT+01:00 Ard Biesheuvel <ard.biesheuvel@linaro.org>:
> On 24 November 2016 at 09:07, Marcin Wojtas <mw@semihalf.com> wrote:
>> Hi,
>>
>> Yes, it would be great.
>>
>
> Pushed, thanks.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-24 16:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24  7:54 [PATCH v2] MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci Marcin Wojtas
2016-11-24  7:56 ` Ard Biesheuvel
2016-11-24  8:01   ` Marcin Wojtas
2016-11-24  8:02     ` Ard Biesheuvel
2016-11-24  8:35 ` Tian, Feng
2016-11-24  9:07   ` Marcin Wojtas
2016-11-24 15:57     ` Ard Biesheuvel
2016-11-24 16:06       ` Marcin Wojtas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox