public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path
@ 2019-05-30  7:57 Wu, Hao A
  2019-05-31  2:57 ` [edk2-devel] " Ni, Ray
  0 siblings, 1 reply; 3+ messages in thread
From: Wu, Hao A @ 2019-05-30  7:57 UTC (permalink / raw)
  To: devel; +Cc: Hao A Wu, Ray Ni, Maggie Chu, Jian J Wang

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1862

Current implementation of function AhciModeInitialization() has an
incorrect assumption that the value in the CAP (offset 00h) register will
always be greater than the highest bit set for the value in the PI (offset
0Ch) register.

This will lead to an issue that hard disk devices may not be found in the
non-S3 boot path for some AHCI controller capabilities.

More specifically, variable 'PortInitializeBitMap' will have the value
from 'Private->PortBitMap', which will be 0xFFFFFFFF in non-S3 boot path.
When the CAP register is of value 0x1 and PI register with value 0x4
(meaning port 2 is available), the current logic will only enumerate port
0. And the device attached behind port 2 will not be enumerated.

To address this issue, variable 'PortInitializeBitMap' will now take the
bitwise and result between 'Private->PortBitMap' and the value read from
the PI register.

Please note that there will be no function impact for S3 path, since in
this case, the bits being set in 'Private->PortBitMap' will be a subset
of the bits being set in the PI register. Their bitwise and operation will
still be the value of 'Private->PortBitMap'.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Maggie Chu <maggie.chu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Hao A Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
index 7287f8290e..8c491bd138 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
@@ -1713,7 +1713,7 @@ AhciModeInitialization (
   MaxPortNumber = MIN (MaxPortNumber, (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1));
   MaxPortNumber = MIN (MaxPortNumber, AhciGetNumberOfPortsFromMap (Private->PortBitMap));
 
-  PortInitializeBitMap = Private->PortBitMap;
+  PortInitializeBitMap = Private->PortBitMap & PortImplementBitMap;
   AhciRegisters        = &Private->AhciRegisters;
   DeviceIndex          = 0;
   //
@@ -1721,6 +1721,13 @@ AhciModeInitialization (
   //
   for (PortIndex = 1; PortIndex <= MaxPortNumber; PortIndex ++) {
     Status = AhciGetPortFromMap (PortInitializeBitMap, PortIndex, &Port);
+    if (EFI_ERROR (Status)) {
+      //
+      // No more available port, just break out of the loop.
+      //
+      break;
+    }
+
     if ((PortImplementBitMap & (BIT0 << Port)) != 0) {
       //
       // Initialize FIS Base Address Register and Command List Base Address
-- 
2.12.0.windows.1


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

* Re: [edk2-devel] [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path
  2019-05-30  7:57 [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path Wu, Hao A
@ 2019-05-31  2:57 ` Ni, Ray
  2019-05-31  8:02   ` Wu, Hao A
  0 siblings, 1 reply; 3+ messages in thread
From: Ni, Ray @ 2019-05-31  2:57 UTC (permalink / raw)
  To: Wu, Hao A, devel

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

Reviewed-by: Ray Ni <ray.ni@intel.com>

[-- Attachment #2: Type: text/html, Size: 99 bytes --]

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

* Re: [edk2-devel] [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path
  2019-05-31  2:57 ` [edk2-devel] " Ni, Ray
@ 2019-05-31  8:02   ` Wu, Hao A
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2019-05-31  8:02 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io

Thanks.
Pushed via commit e2afc8ab59.

Best Regards,
Hao Wu

From: Ni, Ray [mailto:ray.ni@intel.com] 
Sent: Friday, May 31, 2019 10:57 AM
To: Wu; Wu, Hao A; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path

Reviewed-by: Ray Ni ray.ni@intel.com

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

end of thread, other threads:[~2019-05-31  8:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30  7:57 [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path Wu, Hao A
2019-05-31  2:57 ` [edk2-devel] " Ni, Ray
2019-05-31  8:02   ` Wu, Hao A

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