The USB stack uses BS.SignalEvent and Timer event to initialize the USB stack.
It means a USB device initialization might not be completed when returning
from BS.ConnectController().
This behaviour is not compliant with the UEFI spec.

This change is only a _temporary hack_ as it forces the enumeration of the
entire USB bus when the USB Root Hub is initialized which makes this solution
non optimal.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.mar...@arm.com>
---
 MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c     |  6 ++++++
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c | 11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
 mode change 100644 => 100755 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c

diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c 
b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
old mode 100644
new mode 100755
index 315f2cb..edde95f
--- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
@@ -1095,6 +1095,12 @@ EhcAsyncInterruptTransfer (
   EhcLinkQhToPeriod (Ehc, Urb->Qh);
   InsertHeadList (&Ehc->AsyncIntTransfers, &Urb->UrbList);
 
+  // ARM: Force an asynchonous transfer after waiting an interval
+  //      Polling interval is in milliseconds while BS.Stall except
+  //      Microseconds.
+  gBS->Stall (PollingInterval * 1000);
+  EhcMonitorAsyncRequests (Ehc->PollTimer, Ehc);
+
 ON_EXIT:
   Ehc->PciIo->Flush (Ehc->PciIo);
   gBS->RestoreTPL (OldTpl);
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c 
b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
old mode 100644
new mode 100755
index e3752d1..be07a74
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
@@ -668,7 +668,10 @@ UsbOnHubInterrupt (
   }
 
   CopyMem (HubIf->ChangeMap, Data, DataLength);
-  gBS->SignalEvent (HubIf->HubNotify);
+
+  //ARM: We do not use BS.SignalEvent in order to initialize the new device 
immediately
+  //gBS->SignalEvent (HubIf->HubNotify);
+  UsbHubEnumeration (HubIf->HubNotify, HubIf);
 
   return EFI_SUCCESS;
 }
@@ -1112,7 +1115,11 @@ UsbRootHubInit (
   // It should signal the event immediately here, or device detection
   // by bus enumeration might be delayed by the timer interval.
   //
-  gBS->SignalEvent (HubIf->HubNotify);
+
+  //ARM: We invoke the function directly to ensure the enumeration is
+  //     done immediately.
+  //gBS->SignalEvent (HubIf->HubNotify);
+  UsbRootHubEnumeration (NULL, HubIf);
 
   Status = gBS->SetTimer (
                   HubIf->HubNotify,
-- 
2.1.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to