Re: [edk2] [Patch] MdeModulePkg: Change the algorithm in SNP to use the first found BAR index.

2015-09-13 Thread Ye, Ting
Looks good.

Reviewed-by: Ye Ting  

-Original Message-
From: Fu, Siyuan 
Sent: Monday, September 14, 2015 9:12 AM
To: edk2-devel@lists.01.org
Cc: Tian, Feng; Ye, Ting
Subject: [Patch] MdeModulePkg: Change the algorithm in SNP to use the first 
found BAR index.

The driver binding start function in SNP.c goes through all the BARs and get
the last BAR index for use. Theoretically it should work with all valid BARs,
but we got reports some device did always use the first valid BAR, so we change
the logic in SNP to use the first found BAR index instead of the last one.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
CC: Feng Tian 
---
 MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c 
b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
index a63dd10..db5b626 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of driver entry point and driver binding protocol.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
 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
@@ -273,6 +273,8 @@ SimpleNetworkDriverStart (
   PXE_STATFLAGS InitStatFlags;
   EFI_PCI_IO_PROTOCOL   *PciIo;
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc;
+  BOOLEAN   FoundIoBar;
+  BOOLEAN   FoundMemoryBar;
   
   DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));
 
@@ -403,7 +405,7 @@ SimpleNetworkDriverStart (
   Snp->TxRxBuffer = NULL;
  
   if (Nii->Revision >= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION) {
-   Snp->IfNum = Nii->IfNum;
+Snp->IfNum = Nii->IfNum;
 
   } else {
 Snp->IfNum = (UINT8) (Nii->IfNum & 0xFF);
@@ -463,6 +465,8 @@ SimpleNetworkDriverStart (
   //
   Snp->MemoryBarIndex = 0;
   Snp->IoBarIndex = 1;
+  FoundMemoryBar  = FALSE;
+  FoundIoBar  = FALSE;
   for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {
 Status = PciIo->GetBarAttributes (
   PciIo,
@@ -476,13 +480,19 @@ SimpleNetworkDriverStart (
   goto Error_DeleteSNP;
 }
 
-if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
+if ((!FoundMemoryBar) && (BarDesc->ResType == 
ACPI_ADDRESS_SPACE_TYPE_MEM)) {
   Snp->MemoryBarIndex = BarIndex;
-} else if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {
+  FoundMemoryBar  = TRUE;
+} else if ((!FoundIoBar) && (BarDesc->ResType == 
ACPI_ADDRESS_SPACE_TYPE_IO)) {
   Snp->IoBarIndex = BarIndex;
+  FoundIoBar  = TRUE;
 }
 
 FreePool (BarDesc);
+
+if (FoundMemoryBar && FoundIoBar) {
+  break;
+}
   }
 
   Status = PxeStart (Snp);
-- 
2.5.0.windows.1

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


[edk2] [Patch] MdeModulePkg: Change the algorithm in SNP to use the first found BAR index.

2015-09-13 Thread Fu Siyuan
The driver binding start function in SNP.c goes through all the BARs and get
the last BAR index for use. Theoretically it should work with all valid BARs,
but we got reports some device did always use the first valid BAR, so we change
the logic in SNP to use the first found BAR index instead of the last one.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
CC: Feng Tian 
---
 MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c 
b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
index a63dd10..db5b626 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of driver entry point and driver binding protocol.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
 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
@@ -273,6 +273,8 @@ SimpleNetworkDriverStart (
   PXE_STATFLAGS InitStatFlags;
   EFI_PCI_IO_PROTOCOL   *PciIo;
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc;
+  BOOLEAN   FoundIoBar;
+  BOOLEAN   FoundMemoryBar;
   
   DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));
 
@@ -403,7 +405,7 @@ SimpleNetworkDriverStart (
   Snp->TxRxBuffer = NULL;
  
   if (Nii->Revision >= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION) {
-   Snp->IfNum = Nii->IfNum;
+Snp->IfNum = Nii->IfNum;
 
   } else {
 Snp->IfNum = (UINT8) (Nii->IfNum & 0xFF);
@@ -463,6 +465,8 @@ SimpleNetworkDriverStart (
   //
   Snp->MemoryBarIndex = 0;
   Snp->IoBarIndex = 1;
+  FoundMemoryBar  = FALSE;
+  FoundIoBar  = FALSE;
   for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {
 Status = PciIo->GetBarAttributes (
   PciIo,
@@ -476,13 +480,19 @@ SimpleNetworkDriverStart (
   goto Error_DeleteSNP;
 }
 
-if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
+if ((!FoundMemoryBar) && (BarDesc->ResType == 
ACPI_ADDRESS_SPACE_TYPE_MEM)) {
   Snp->MemoryBarIndex = BarIndex;
-} else if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {
+  FoundMemoryBar  = TRUE;
+} else if ((!FoundIoBar) && (BarDesc->ResType == 
ACPI_ADDRESS_SPACE_TYPE_IO)) {
   Snp->IoBarIndex = BarIndex;
+  FoundIoBar  = TRUE;
 }
 
 FreePool (BarDesc);
+
+if (FoundMemoryBar && FoundIoBar) {
+  break;
+}
   }
 
   Status = PxeStart (Snp);
-- 
2.5.0.windows.1

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