]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/Lan9118Dxe: add PCD for negotiation timeout
authorRyan Harkin <ryan.harkin@linaro.org>
Mon, 8 Feb 2016 14:38:05 +0000 (14:38 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 10 Feb 2016 16:56:43 +0000 (17:56 +0100)
Add a PCD for the link negotiation timeout so the platform can over-ride
the default value.

The code previously did 2000 iterations of the loop with a 2us stall, so
the code has been changed subtly to set the number of iterations equal
to the PCD value divided by the stall time.

Since the stall time has not changed, the default PCD value is set at
4000 so the original behaviour is not changed.

The problems were discovered when the ARM Juno Development Platform used
the "EFI Network" option with then LAN9118 driver.  It fails to boot the
first time and so the board drops back to Shell again:

  Warning: LAN9118 Driver in stopped state
  Link timeout in auto-negotiation.
  Lan9118: Auto Negociation not supported.
  EhcExecTransfer: transfer failed with 2
  EhcControlTransfer: error - Device Error, transfer - 2
  Buffer: EFI Hard Drive
  Booting EFI Misc Device
  Booting EFI Misc Device 1
  Booting EFI Hard Drive
  Booting EFI Network
  Warning: LAN9118 Driver not initialized
  Link timeout in auto-negotiation.
  Lan9118: Auto Negociation not supported.
  Booting EFI Internal Shell

Exiting Shell drops the user back to the Intel BDS UI.  Selecting
"Continue" then succeeds in booting from the EFI Network:

  Booting EFI Misc Device
  Booting EFI Misc Device 1
  Booting EFI Hard Drive
  Booting EFI Network
  ..MnpFreeTxBuf: Duplicated recycle report from SNP.
  MnpFreeTxBuf: Duplicated recycle report from SNP.
  [snip repeated errors]

Discussion on the edk2-devel mailing list [1] prompted Laszlo Ersek to
suggest the time taken for the NIC to negotiate was causing a problem.
He suggested the solution contained in this patch to provide a PCD
configurable by the platform.

The default PCD value does not work for Juno.  Setting the PCD to a
larger value works for Juno R0, R1 and R2.

[1] http://article.gmane.org/gmane.comp.bios.edk2.devel/7341

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf
EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.c
EmbeddedPkg/EmbeddedPkg.dec

index 9e5f98b4bd1820f6bfa2a2a3196a47c4dd1e861f..3c2246fb8afd1a507882733e0873ad76c80ea7c2 100644 (file)
@@ -51,6 +51,7 @@
 [FixedPcd]\r
   gEmbeddedTokenSpaceGuid.PcdLan9118DxeBaseAddress\r
   gEmbeddedTokenSpaceGuid.PcdLan9118DefaultMacAddress\r
+  gEmbeddedTokenSpaceGuid.PcdLan9118DefaultNegotiationTimeout\r
 \r
 [Depex]\r
   TRUE\r
index 2ef1ecbb2887e0a1cec3b472b9b334ba60721ac7..c57c7ceff120cd2644fe041417d45eba3972a5e4 100644 (file)
@@ -586,7 +586,7 @@ AutoNegotiate (
   // Check that link is up first\r
   if ((PhyStatus & PHYSTS_LINK_STS) == 0) {\r
     // Wait until it is up or until Time Out\r
-    TimeOut = 2000;\r
+    TimeOut = FixedPcdGet32 (PcdLan9118DefaultNegotiationTimeout) / LAN9118_STALL;\r
     while ((IndirectPHYRead32 (PHY_INDEX_BASIC_STATUS) & PHYSTS_LINK_STS) == 0) {\r
       MemoryFence();\r
       gBS->Stall (LAN9118_STALL);\r
index f557527281432eef1819f32513fd429a956f9074..cd0d96f79f4f3dd21a64fbc22013c4a0a4784344 100644 (file)
   # LAN9118 Ethernet Driver PCDs\r
   gEmbeddedTokenSpaceGuid.PcdLan9118DxeBaseAddress|0x0|UINT32|0x00000025\r
   gEmbeddedTokenSpaceGuid.PcdLan9118DefaultMacAddress|0x0|UINT64|0x00000026\r
+  gEmbeddedTokenSpaceGuid.PcdLan9118DefaultNegotiationTimeout|4000|UINT32|0x00000027\r
 \r
   #\r
   # Android FastBoot\r