[edk2] [Patch] MdeModulePkg: Enhance PciBusDxe to handle high 32bit of MEM64 BAR returns 0

2015-07-29 Thread Ruiyu Ni
According to the PCI spec, when software writes all-one to BAR for size probing,
the value read back should be 0b1...10...0 after masking the BAR type bits.
But in real world, it's possible that certain device returns 0b0...01...10...0
for MEM64 BAR size probing: some bits in the high 32bit may be 0.
PciBus driver has the code to handle such case. However, it doesn't handle the
case that the high 32bit is totally 0. The patch is to handle the special case.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni ruiyu...@intel.com
Cc: Eric Dong eric.d...@intel.com
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index 9e7ac74..f46025e 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -1,7 +1,7 @@
 /** @file
   PCI emumeration support functions implementation for PCI Bus module.
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.BR
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.BR
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -1770,14 +1770,19 @@ PciParseBar (
   // some device implement MMIO bar with 0 length, need to treat it as 
no-bar
   //
   PciIoDevice-PciBar[BarIndex].BarType = PciBarTypeUnknown;
+  return Offset + 4;
 }
-return Offset + 4;
   }
 
   //
   // Fix the length to support some spefic 64 bit BAR
   //
-  Value |= ((UINT32)(-1)  HighBitSet32 (Value));
+  if (Value == 0) {
+DEBUG ((EFI_D_INFO, [PciBus]BAR probing for upper 32bit of MEM64 BAR 
returns 0, change to 0x.\n));
+Value = (UINT32) -1;
+  } else {
+Value |= ((UINT32)(-1)  HighBitSet32 (Value));
+  }
 
   //
   // Calculate the size of 64bit bar
-- 
1.9.5.msysgit.1

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


Re: [edk2] [Patch] MdeModulePkg: Enhance PciBusDxe to handle high 32bit of MEM64 BAR returns 0

2015-07-29 Thread Dong, Eric
Reviewed-by: Eric Dong eric.d...@intel.com

-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, July 30, 2015 11:11 AM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu; Dong, Eric
Subject: [Patch] MdeModulePkg: Enhance PciBusDxe to handle high 32bit of MEM64 
BAR returns 0

According to the PCI spec, when software writes all-one to BAR for size 
probing, the value read back should be 0b1...10...0 after masking the BAR type 
bits.
But in real world, it's possible that certain device returns 0b0...01...10...0 
for MEM64 BAR size probing: some bits in the high 32bit may be 0.
PciBus driver has the code to handle such case. However, it doesn't handle the 
case that the high 32bit is totally 0. The patch is to handle the special case.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni ruiyu...@intel.com
Cc: Eric Dong eric.d...@intel.com
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index 9e7ac74..f46025e 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -1,7 +1,7 @@
 /** @file
   PCI emumeration support functions implementation for PCI Bus module.
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.BR
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.BR
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -1770,14 
+1770,19 @@ PciParseBar (
   // some device implement MMIO bar with 0 length, need to treat it as 
no-bar
   //
   PciIoDevice-PciBar[BarIndex].BarType = PciBarTypeUnknown;
+  return Offset + 4;
 }
-return Offset + 4;
   }
 
   //
   // Fix the length to support some spefic 64 bit BAR
   //
-  Value |= ((UINT32)(-1)  HighBitSet32 (Value));
+  if (Value == 0) {
+DEBUG ((EFI_D_INFO, [PciBus]BAR probing for upper 32bit of MEM64 BAR 
returns 0, change to 0x.\n));
+Value = (UINT32) -1;
+  } else {
+Value |= ((UINT32)(-1)  HighBitSet32 (Value));
+  }
 
   //
   // Calculate the size of 64bit bar
--
1.9.5.msysgit.1

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