From 15cc67e616cad2dad3d3b6f9ba1cba856b5de414 Mon Sep 17 00:00:00 2001 From: erictian Date: Wed, 5 May 2010 05:21:38 +0000 Subject: [PATCH] raise TPL to TPL_CALLBACK level at DriverBindingStart() for all usb-related modules, which prevent DriverBindingStop() from being invoked when DriverBindingStart() runs. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10460 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 9 ++++++++- .../Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c | 13 +++++++++---- .../UsbMouseAbsolutePointer.c | 8 +++++++- MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 8 +++++++- MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c | 6 +++++- .../Universal/Disk/PartitionDxe/Partition.c | 13 +++++++++---- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c index 2733d562d7..278c2da19a 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -154,7 +154,9 @@ USBKeyboardDriverBindingStart ( UINT8 PollingInterval; UINT8 PacketSize; BOOLEAN Found; + EFI_TPL OldTpl; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); // // Open USB I/O Protocol // @@ -167,7 +169,7 @@ USBKeyboardDriverBindingStart ( EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { - return Status; + goto ErrorExit1; } UsbKeyboardDevice = AllocateZeroPool (sizeof (USB_KB_DEV)); @@ -381,6 +383,7 @@ USBKeyboardDriverBindingStart ( FALSE ); + gBS->RestoreTPL (OldTpl); return EFI_SUCCESS; // @@ -407,6 +410,10 @@ ErrorExit: This->DriverBindingHandle, Controller ); + +ErrorExit1: + gBS->RestoreTPL (OldTpl); + return Status; } diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c index 9137075d86..f440e9fd7c 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c @@ -833,7 +833,10 @@ USBMassDriverBindingStart ( UINT8 MaxLun; EFI_STATUS Status; EFI_USB_IO_PROTOCOL *UsbIo; - + EFI_TPL OldTpl; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + Transport = NULL; Context = NULL; MaxLun = 0; @@ -842,7 +845,7 @@ USBMassDriverBindingStart ( if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitTransport (%r)\n", Status)); - return Status; + goto Exit; } if (MaxLun == 0) { // @@ -867,7 +870,7 @@ USBMassDriverBindingStart ( if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: OpenDevicePathProtocol By Driver (%r)\n", Status)); - return Status; + goto Exit; } Status = gBS->OpenProtocol ( @@ -887,7 +890,7 @@ USBMassDriverBindingStart ( This->DriverBindingHandle, Controller ); - return Status; + goto Exit; } // @@ -911,6 +914,8 @@ USBMassDriverBindingStart ( DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitMultiLun (%r) with Maxlun=%d\n", Status, MaxLun)); } } +Exit: + gBS->RestoreTPL (OldTpl); return Status; } diff --git a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c index 35be8b0397..2f3cf9aae2 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c @@ -149,7 +149,9 @@ USBMouseAbsolutePointerDriverBindingStart ( UINT8 PollingInterval; UINT8 PacketSize; BOOLEAN Found; + EFI_TPL OldTpl; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); // // Open USB I/O Protocol // @@ -162,7 +164,7 @@ USBMouseAbsolutePointerDriverBindingStart ( EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { - return Status; + goto ErrorExit1; } UsbMouseAbsolutePointerDevice = AllocateZeroPool (sizeof (USB_MOUSE_ABSOLUTE_POINTER_DEV)); @@ -324,6 +326,7 @@ USBMouseAbsolutePointerDriverBindingStart ( FALSE ); + gBS->RestoreTPL (OldTpl); return EFI_SUCCESS; // @@ -348,6 +351,9 @@ ErrorExit: } } +ErrorExit1: + gBS->RestoreTPL (OldTpl); + return Status; } diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c index 8b8a21eae8..f51dbfa1cf 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c @@ -149,7 +149,9 @@ USBMouseDriverBindingStart ( UINT8 PollingInterval; UINT8 PacketSize; BOOLEAN Found; + EFI_TPL OldTpl; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); // // Open USB I/O Protocol // @@ -162,7 +164,7 @@ USBMouseDriverBindingStart ( EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { - return Status; + goto ErrorExit1; } UsbMouseDevice = AllocateZeroPool (sizeof (USB_MOUSE_DEV)); @@ -324,6 +326,8 @@ USBMouseDriverBindingStart ( FALSE ); + gBS->RestoreTPL (OldTpl); + return EFI_SUCCESS; // @@ -348,6 +352,8 @@ ErrorExit: } } +ErrorExit1: + gBS->RestoreTPL (OldTpl); return Status; } diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c index 0b1ea6ff3e..0175465ade 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c @@ -125,7 +125,9 @@ DiskIoDriverBindingStart ( { EFI_STATUS Status; DISK_IO_PRIVATE_DATA *Private; + EFI_TPL OldTpl; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); Private = NULL; // @@ -140,7 +142,7 @@ DiskIoDriverBindingStart ( EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { - return Status; + goto ErrorExit1; } // @@ -177,6 +179,8 @@ ErrorExit: ); } +ErrorExit1: + gBS->RestoreTPL (OldTpl); return Status; } diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c index 73278e9c35..5629a74656 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c @@ -194,7 +194,9 @@ PartitionDriverBindingStart ( EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; PARTITION_DETECT_ROUTINE *Routine; BOOLEAN MediaPresent; + EFI_TPL OldTpl; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); // // Check RemainingDevicePath validation // @@ -204,7 +206,8 @@ PartitionDriverBindingStart ( // if yes, return EFI_SUCCESS // if (IsDevicePathEnd (RemainingDevicePath)) { - return EFI_SUCCESS; + Status = EFI_SUCCESS; + goto Exit; } } @@ -217,7 +220,7 @@ PartitionDriverBindingStart ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - return Status; + goto Exit; } // // Get the Device Path Protocol on ControllerHandle's handle @@ -231,7 +234,7 @@ PartitionDriverBindingStart ( EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { - return Status; + goto Exit; } Status = gBS->OpenProtocol ( @@ -249,7 +252,7 @@ PartitionDriverBindingStart ( This->DriverBindingHandle, ControllerHandle ); - return Status; + goto Exit; } OpenStatus = Status; @@ -312,6 +315,8 @@ PartitionDriverBindingStart ( ); } +Exit: + gBS->RestoreTPL (OldTpl); return Status; } -- 2.39.2