EmbeddedPkg/MmcDxe: Card Presence Detect Race Condition

The MMC driver defaults to assume a card is not present.  It then starts a timer in MmcDxeInitialize to check for card presence every 200ms.

However it does not immediately check to see if a card is present so if the EFI driver connection process occurs less than 200ms after the driver load, the connection process for partition 
or filesystem drivers will fail because MediaPresent still is FALSE.  To resolve this race condition, we need to immediately perform the presence check in the Start routine.


EmbeddedPkg/MmcDxe: Media ID Handling

Initialize the MMC device on Start or when presence changes instead of doing it on the Block IO calls. This way the layered drivers can be stopped and rebuilt with new Media IDs instead of 
experiencing errors on calls to Block IO.


Proposed-by: Eugene Cohen (HP)
Reviewed-by: oliviermartin




git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12237 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin
2011-08-30 18:02:38 +00:00
parent c8ece79ccd
commit 40842a5e7c
3 changed files with 95 additions and 80 deletions

View File

@@ -299,6 +299,9 @@ MmcDriverBindingStart (
InsertMmcHost (MmcHostInstance);
MmcHostInstance->Initialized = FALSE;
// Detect card presence now
CheckCardsCallback (NULL, NULL);
}
return EFI_SUCCESS;
@@ -366,6 +369,10 @@ CheckCardsCallback (
MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
if(MmcHostInstance->BlockIo.Media->MediaPresent) {
InitializeMmcDevice(MmcHostInstance);
}
Status = gBS->ReinstallProtocolInterface (
(MmcHostInstance->MmcHandle),
&gEfiBlockIoProtocolGuid,
@@ -382,6 +389,7 @@ CheckCardsCallback (
}
}
EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
MmcDriverBindingSupported,
MmcDriverBindingStart,