EmbeddedPkg/Lan9118Dxe: use MemoryFence
When reviewing my LAN9118 driver PCD patch [1], Ard Biesheuvel noted that most calls to gBS->Stall() in this driver seem to be used to prevent timing issues between the device updating data and the host reading the values. And that replacing most of these calls with a MemoryFence() would be more robust. The only exceptions are the stalls that are enclosed inside retry loops: - in the AutoNegotiate() function. This stall is waiting for the link to negotiate, which may require stalling until it is ready. - in the Lan9118Initialize() function. These two stalls are waiting for devices and time out after a number of retries. - in the SoftReset() function. This stall is inside a loop where the comment states: "If time taken exceeds 100us, then there was an error condition" In these instances, I kept the stall, but also added a MemoryFence(). [1] http://article.gmane.org/gmane.comp.bios.edk2.devel/7389 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
committed by
Ard Biesheuvel
parent
7d0f92e8fd
commit
a4626006bb
@@ -307,8 +307,7 @@ SnpInitialize (
|
||||
|
||||
// Write the current configuration to the register
|
||||
MmioWrite32 (LAN9118_PMT_CTRL, PmConf);
|
||||
gBS->Stall (LAN9118_STALL);
|
||||
gBS->Stall (LAN9118_STALL);
|
||||
MemoryFence();
|
||||
|
||||
// Configure GPIO and HW
|
||||
Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);
|
||||
@@ -431,7 +430,7 @@ SnpReset (
|
||||
|
||||
// Write the current configuration to the register
|
||||
MmioWrite32 (LAN9118_PMT_CTRL, PmConf);
|
||||
gBS->Stall (LAN9118_STALL);
|
||||
MemoryFence();
|
||||
|
||||
// Reactivate the LEDs
|
||||
Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);
|
||||
@@ -446,7 +445,7 @@ SnpReset (
|
||||
HwConf |= HW_CFG_TX_FIFO_SIZE(gTxBuffer); // assign size chosen in SnpInitialize
|
||||
|
||||
MmioWrite32 (LAN9118_HW_CFG, HwConf); // Write the conf
|
||||
gBS->Stall (LAN9118_STALL);
|
||||
MemoryFence();
|
||||
}
|
||||
|
||||
// Enable the receiver and transmitter and clear their contents
|
||||
@@ -701,7 +700,7 @@ SnpReceiveFilters (
|
||||
// Write the options to the MAC_CSR
|
||||
//
|
||||
IndirectMACWrite32 (INDIRECT_MAC_INDEX_CR, MacCSRValue);
|
||||
gBS->Stall (LAN9118_STALL);
|
||||
MemoryFence();
|
||||
|
||||
//
|
||||
// If we have to retrieve something, start packet reception.
|
||||
|
Reference in New Issue
Block a user